Preparing for release
Solving conflicts. Set constants to GMS-like. Ready for release.
This commit is contained in:
@@ -365,7 +365,7 @@ public class Server implements Runnable {
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.setProperty("wzpath", "wz");
|
||||
System.setProperty("wzpath", "wz");
|
||||
Server.getInstance().run();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,15 +35,15 @@ import java.util.Arrays;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import server.MapleInventoryManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.maps.MapleMiniGame;
|
||||
import server.maps.MaplePlayerShop;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.MapleTrade;
|
||||
import constants.GameConstants;
|
||||
import server.maps.FieldLimit;
|
||||
import server.maps.MapleHiredMerchant;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.MapleMapObjectType;
|
||||
import server.maps.MapleMiniGame;
|
||||
import server.maps.MaplePlayerShop;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
|
||||
@@ -46,11 +46,11 @@ import net.server.Server;
|
||||
import scripting.npc.NPCScriptManager;
|
||||
import server.MapleInventoryManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.MapleShop;
|
||||
import server.MapleShopFactory;
|
||||
import server.TimerManager;
|
||||
import server.maps.AbstractMapleMapObject;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleTVEffect;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
@@ -21,11 +21,16 @@
|
||||
*/
|
||||
package net.server.handlers.login;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import constants.ServerConstants;
|
||||
import net.MaplePacketHandler;
|
||||
import net.server.Server;
|
||||
import server.TimerManager;
|
||||
import tools.BCrypt;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
import client.MapleClient;
|
||||
@@ -36,17 +41,51 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
|
||||
public boolean validateState(MapleClient c) {
|
||||
return !c.isLoggedIn();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
|
||||
|
||||
String login = slea.readMapleAsciiString();
|
||||
String pwd = slea.readMapleAsciiString();
|
||||
String bcryptedpass = BCrypt.hashpw(pwd, BCrypt.gensalt(12));
|
||||
c.setAccountName(login);
|
||||
|
||||
|
||||
int loginok = c.login(login, pwd);
|
||||
|
||||
|
||||
Connection con = null;
|
||||
PreparedStatement ps = null;
|
||||
|
||||
if (ServerConstants.AUTOMATIC_REGISTER && loginok == 5) {
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("INSERT INTO accounts (name, password) VALUES (?, ?);");
|
||||
ps.setString(1, login);
|
||||
ps.setString(2, bcryptedpass);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
disposeSql(con, ps);
|
||||
loginok = c.login(login, pwd);
|
||||
}
|
||||
}
|
||||
|
||||
if (ServerConstants.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 = ?;");
|
||||
ps.setString(1, bcryptedpass);
|
||||
ps.setString(2, login);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
disposeSql(con, ps);
|
||||
loginok = (loginok == -10) ? 0 : 23;
|
||||
}
|
||||
}
|
||||
|
||||
if (c.hasBannedIP() || c.hasBannedMac()) {
|
||||
c.announce(MaplePacketCreator.getLoginFailed(3));
|
||||
return;
|
||||
@@ -71,10 +110,24 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
|
||||
c.announce(MaplePacketCreator.getLoginFailed(7));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void login(MapleClient c){
|
||||
c.announce(MaplePacketCreator.getAuthSuccess(c));//why the fk did I do c.getAccountName()?
|
||||
|
||||
|
||||
Server.getInstance().registerLoginState(c);
|
||||
}
|
||||
|
||||
private static void disposeSql(Connection con, PreparedStatement ps) {
|
||||
try {
|
||||
if (con != null) {
|
||||
con.close();
|
||||
}
|
||||
|
||||
if (ps != null) {
|
||||
ps.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ import server.TimerManager;
|
||||
import server.maps.MapleHiredMerchant;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MaplePlayerShop;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.maps.AbstractMapleMapObject;
|
||||
import net.server.worker.CharacterAutosaverWorker;
|
||||
import net.server.worker.MountTirednessWorker;
|
||||
import net.server.worker.PetFullnessWorker;
|
||||
@@ -63,8 +65,6 @@ import net.server.channel.CharacterIdChannelPair;
|
||||
import net.server.guild.MapleGuild;
|
||||
import net.server.guild.MapleGuildCharacter;
|
||||
import net.server.guild.MapleGuildSummary;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.maps.AbstractMapleMapObject;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
Reference in New Issue
Block a user