diff --git a/src/main/java/client/Character.java b/src/main/java/client/Character.java index bef0ebe9fb..cb551f18fe 100644 --- a/src/main/java/client/Character.java +++ b/src/main/java/client/Character.java @@ -7990,53 +7990,6 @@ public class Character extends AbstractCharacterObject { } } - public synchronized void saveCooldowns() { - List listcd = getAllCooldowns(); - - if (!listcd.isEmpty()) { - try (Connection con = DatabaseConnection.getConnection()) { - deleteWhereCharacterId(con, "DELETE FROM cooldowns WHERE charid = ?"); - try (PreparedStatement ps = con.prepareStatement("INSERT INTO cooldowns (charid, SkillID, StartTime, length) VALUES (?, ?, ?, ?)")) { - ps.setInt(1, getId()); - for (PlayerCoolDownValueHolder cooling : listcd) { - ps.setInt(2, cooling.skillId); - ps.setLong(3, cooling.startTime); - ps.setLong(4, cooling.length); - ps.addBatch(); - } - ps.executeBatch(); - } - } catch (SQLException se) { - se.printStackTrace(); - } - } - - Map> listds = getAllDiseases(); - if (!listds.isEmpty()) { - try (Connection con = DatabaseConnection.getConnection()) { - deleteWhereCharacterId(con, "DELETE FROM playerdiseases WHERE charid = ?"); - try (PreparedStatement ps = con.prepareStatement("INSERT INTO playerdiseases (charid, disease, mobskillid, mobskilllv, length) VALUES (?, ?, ?, ?, ?)")) { - ps.setInt(1, getId()); - - for (Entry> e : listds.entrySet()) { - ps.setInt(2, e.getKey().ordinal()); - - MobSkill ms = e.getValue().getRight(); - MobSkillId msId = ms.getId(); - ps.setInt(3, msId.type().getId()); - ps.setInt(4, msId.level()); - ps.setInt(5, e.getValue().getLeft().intValue()); - ps.addBatch(); - } - - ps.executeBatch(); - } - } catch (SQLException se) { - se.printStackTrace(); - } - } - } - public void saveGuildStatus() { try (Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("UPDATE characters SET guildid = ?, guildrank = ?, allianceRank = ? WHERE id = ?")) { @@ -8614,9 +8567,11 @@ public class Character extends AbstractCharacterObject { } } } - } + saveCooldowns(con); + saveDiseases(con); + if (cashshop != null) { cashshop.save(con); } @@ -8639,6 +8594,50 @@ public class Character extends AbstractCharacterObject { } } + private void saveCooldowns(Connection con) throws SQLException { + deleteWhereCharacterId(con, "DELETE FROM cooldowns WHERE charid = ?"); + + List cooldowns = getAllCooldowns(); + if (cooldowns.isEmpty()) { + return; + } + try (PreparedStatement ps = con.prepareStatement("INSERT INTO cooldowns (charid, SkillID, StartTime, length) VALUES (?, ?, ?, ?)")) { + ps.setInt(1, getId()); + for (PlayerCoolDownValueHolder cooling : cooldowns) { + ps.setInt(2, cooling.skillId); + ps.setLong(3, cooling.startTime); + ps.setLong(4, cooling.length); + ps.addBatch(); + } + ps.executeBatch(); + } + } + + private void saveDiseases(Connection con) throws SQLException { + deleteWhereCharacterId(con, "DELETE FROM playerdiseases WHERE charid = ?"); + + Map> diseases = getAllDiseases(); + if (diseases.isEmpty()) { + return; + } + try (PreparedStatement ps = con.prepareStatement("INSERT INTO playerdiseases (charid, disease, mobskillid, mobskilllv, length) VALUES (?, ?, ?, ?, ?)")) { + ps.setInt(1, getId()); + + for (Entry> e : diseases.entrySet()) { + ps.setInt(2, e.getKey().ordinal()); + + MobSkill ms = e.getValue().getRight(); + MobSkillId msId = ms.getId(); + ps.setInt(3, msId.type().getId()); + ps.setInt(4, msId.level()); + ps.setInt(5, e.getValue().getLeft().intValue()); + ps.addBatch(); + } + + ps.executeBatch(); + } + } + public void sendPolice(int greason, String reason, int duration) { sendPacket(PacketCreator.sendPolice(String.format("You have been blocked by the#b %s Police for %s.#k", "Cosmic", reason))); this.isbanned = true; diff --git a/src/main/java/client/Client.java b/src/main/java/client/Client.java index ee868491d4..a8b6aeb0e2 100644 --- a/src/main/java/client/Client.java +++ b/src/main/java/client/Client.java @@ -1017,7 +1017,6 @@ public class Client extends ChannelInboundHandlerAdapter { wserv.removePlayer(player); //getChannelServer().removePlayer(player); already being done - player.saveCooldowns(); player.cancelAllDebuffs(); player.saveCharToDB(true); @@ -1029,7 +1028,6 @@ public class Client extends ChannelInboundHandlerAdapter { } else { getChannelServer().removePlayer(player); - player.saveCooldowns(); player.cancelAllDebuffs(); player.saveCharToDB(); }