Riizade/config file (#520)

* added POJO + yaml file

* made config members public

* switched to yaml

* modified files to use YamlConfig over ServerConstants

* removed constants from ServerConstants

* removed unused imports

* removed unused import

* removed world ini

* removed now unused .ini files

* fixed docker-launch.sh

* added jackson dependency JARs

* fixed errors

* removed unused server config values, added world defaults

* don't use env variables for docker

* fixed package imports/specifiers for js files
This commit is contained in:
Adam James-Liebau Johnson
2019-09-20 20:49:24 -03:00
committed by Ronan Lana
parent e169971384
commit 181573dc74
163 changed files with 1531 additions and 1113 deletions
@@ -26,6 +26,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;
import config.YamlConfig;
import constants.ServerConstants;
import net.MaplePacketHandler;
import net.server.Server;
@@ -64,14 +65,14 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
String remoteHost = getRemoteIp(c.getSession());
if (!remoteHost.contentEquals("null")) {
if (ServerConstants.USE_IP_VALIDATION) { // thanks Alex (CanIGetaPR) for suggesting IP validation as a server flag
if (YamlConfig.config.server.USE_IP_VALIDATION) { // thanks Alex (CanIGetaPR) for suggesting IP validation as a server flag
if (remoteHost.startsWith("127.")) {
if (!ServerConstants.LOCALSERVER) { // thanks Mills for noting HOST can also have a field named "localhost"
if (!YamlConfig.config.server.LOCALSERVER) { // thanks Mills for noting HOST can also have a field named "localhost"
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as localhost if it's not a local server
return;
}
} else {
if (ServerConstants.LOCALSERVER) {
if (YamlConfig.config.server.LOCALSERVER) {
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as non-localhost if it's a local server
return;
}
@@ -93,12 +94,12 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
Connection con = null;
PreparedStatement ps = null;
if (ServerConstants.AUTOMATIC_REGISTER && loginok == 5) {
if (YamlConfig.config.server.AUTOMATIC_REGISTER && loginok == 5) {
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("INSERT INTO accounts (name, password, birthday, tempban) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS); //Jayd: Added birthday, tempban
ps.setString(1, login);
ps.setString(2, ServerConstants.BCRYPT_MIGRATION ? BCrypt.hashpw(pwd, BCrypt.gensalt(12)) : hashpwSHA512(pwd));
ps.setString(2, YamlConfig.config.server.BCRYPT_MIGRATION ? BCrypt.hashpw(pwd, BCrypt.gensalt(12)) : hashpwSHA512(pwd));
ps.setString(3, "2018-06-20"); //Jayd's idea: was added to solve the MySQL 5.7 strict checking (birthday)
ps.setString(4, "2018-06-20"); //Jayd's idea: was added to solve the MySQL 5.7 strict checking (tempban)
ps.executeUpdate();
@@ -116,7 +117,7 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
}
}
if (ServerConstants.BCRYPT_MIGRATION && (loginok <= -10)) { // -10 means migration to bcrypt, -23 means TOS wasn't accepted
if (YamlConfig.config.server.BCRYPT_MIGRATION && (loginok <= -10)) { // -10 means migration to bcrypt, -23 means TOS wasn't accepted
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("UPDATE accounts SET password = ? WHERE name = ?;");