From cabfc01be6eaf3240c2716d31e3e84cbdb3ab41a Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 27 Jun 2021 14:58:44 +0000 Subject: [PATCH] DailyTaskManager weekly reset improvements. Thanks to nasseka. --- .../dist/game/data/TimedHuntingZoneData.xml | 2 - .../dist/game/data/events/DailyTasks.xml | 10 ++++ .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 38 ++++++++++++++ .../dist/game/data/TimedHuntingZoneData.xml | 20 +++----- .../dist/game/data/events/DailyTasks.xml | 10 ++++ .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 50 ++++++++++++++++--- .../dist/game/data/TimedHuntingZoneData.xml | 33 ++++++------ .../dist/game/data/events/DailyTasks.xml | 10 ++++ .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 50 ++++++++++++++++--- .../dist/game/data/TimedHuntingZoneData.xml | 1 - .../dist/game/data/events/DailyTasks.xml | 6 ++- .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 38 ++++++++++++++ .../dist/game/data/TimedHuntingZoneData.xml | 10 ---- .../dist/game/data/events/DailyTasks.xml | 5 ++ .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 38 ++++++++++++++ .../dist/game/data/TimedHuntingZoneData.xml | 10 ---- .../dist/game/data/events/DailyTasks.xml | 5 ++ .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 38 ++++++++++++++ .../dist/game/data/TimedHuntingZoneData.xml | 10 ---- .../dist/game/data/events/DailyTasks.xml | 5 ++ .../game/data/xsd/TimedHuntingZoneData.xsd | 2 +- .../instancemanager/DailyTaskManager.java | 38 ++++++++++++++ 28 files changed, 360 insertions(+), 81 deletions(-) diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml index efa9eb03f0..65e6ed26b0 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml @@ -3,7 +3,6 @@ 194291,176604,-1888 3600 - 36000 21600 3600 3600 @@ -14,7 +13,6 @@ 9400,-21720,-3634 3600 - 36000 21600 3600 3600 diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/events/DailyTasks.xml index d3d1052861..15eea98f96 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/events/DailyTasks.xml @@ -22,6 +22,16 @@ + + + + + + + + + + diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd index 7c75375766..d3aa0612e6 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd @@ -7,7 +7,7 @@ - + diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java index 3b3396c316..029315cc0c 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java @@ -27,6 +27,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.xml.DailyMissionData; +import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData; import org.l2jmobius.gameserver.model.DailyMissionDataHolder; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; @@ -38,6 +39,7 @@ import org.l2jmobius.gameserver.model.eventengine.AbstractEventManager; import org.l2jmobius.gameserver.model.eventengine.ScheduleTarget; import org.l2jmobius.gameserver.model.holders.SkillHolder; import org.l2jmobius.gameserver.model.holders.SubClassHolder; +import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder; import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.network.serverpackets.ExVoteSystemInfo; @@ -67,6 +69,7 @@ public class DailyTaskManager extends AbstractEventManager> resetRecommends(); resetWorldChatPoints(); resetTrainingCamp(); + onResetTimedHuntingZones(); } @ScheduleTarget @@ -252,6 +255,41 @@ public class DailyTaskManager extends AbstractEventManager> DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset); } + @ScheduleTarget + public void onResetTimedHuntingZones() + { + for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones()) + { + if (holder.getResetDelay() > 0) + { + continue; + } + + // Update data for offline players. + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var IN (?, ?)")) + { + ps.setString(1, PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + ps.setString(2, PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + ps.executeUpdate(); + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not reset Training Camp: ", e); + } + + // Update data for online players. + World.getInstance().getPlayers().stream().forEach(player -> + { + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + player.getVariables().storeMe(); + }); + } + + LOGGER.info("Special Hunting Zones has been resetted."); + } + public static DailyTaskManager getInstance() { return SingletonHolder.INSTANCE; diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_8.0_Homunculus/dist/game/data/TimedHuntingZoneData.xml index a0b382f7ed..cc8c523c56 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/TimedHuntingZoneData.xml +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/TimedHuntingZoneData.xml @@ -3,9 +3,8 @@ 194291,176604,-1888 3600 - 36000 21600 - 43200 + 7200 3600 150000 100 @@ -14,9 +13,8 @@ 9400,-21720,-3634 3600 - 36000 21600 - 43200 + 7200 3600 150000 105 @@ -25,9 +23,8 @@ -122259,73678,-2872 3600 - 36000 21600 - 43200 + 7200 3600 150000 107 @@ -36,9 +33,8 @@ 139411,-169382,-1600 3600 - 36000 21600 - 43200 + 18000 3600 150000 99 @@ -47,9 +43,8 @@ -82014,16247,-15416 36000 - 604800 - 43200 - 43200 + 36000 + 0 3600 150000 110 @@ -59,9 +54,8 @@ 181409,-78389,-2728 3600 - 36000 3600 - 43200 + 0 3600 150000 105 diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_8.0_Homunculus/dist/game/data/events/DailyTasks.xml index e70b936c3c..105f829cfe 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/events/DailyTasks.xml @@ -22,6 +22,16 @@ + + + + + + + + + + diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_8.0_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd index 7c75375766..d3aa0612e6 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd @@ -7,7 +7,7 @@ - + diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java index c1295a3c29..d7160c4685 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java @@ -29,6 +29,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.xml.DailyMissionData; +import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData; import org.l2jmobius.gameserver.model.DailyMissionDataHolder; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; @@ -40,6 +41,7 @@ import org.l2jmobius.gameserver.model.eventengine.AbstractEventManager; import org.l2jmobius.gameserver.model.eventengine.ScheduleTarget; import org.l2jmobius.gameserver.model.holders.SkillHolder; import org.l2jmobius.gameserver.model.holders.SubClassHolder; +import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder; import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.network.serverpackets.ExVoteSystemInfo; @@ -69,8 +71,8 @@ public class DailyTaskManager extends AbstractEventManager> resetRecommends(); resetWorldChatPoints(); resetTrainingCamp(); - resetThroneOfHeroes(); resetHomunculusResetPoints(); + onResetTimedHuntingZones(); } @ScheduleTarget @@ -299,7 +301,8 @@ public class DailyTaskManager extends AbstractEventManager> DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset); } - public void resetThroneOfHeroes() + @ScheduleTarget + public void onResetThroneOfHeroes() { // Update data for offline players. try (Connection con = DatabaseFactory.getConnection()) @@ -334,6 +337,41 @@ public class DailyTaskManager extends AbstractEventManager> LOGGER.info("Throne of Heroes Entry has been resetted."); } + @ScheduleTarget + public void onResetTimedHuntingZones() + { + for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones()) + { + if (holder.getResetDelay() > 0) + { + continue; + } + + // Update data for offline players. + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var IN (?, ?)")) + { + ps.setString(1, PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + ps.setString(2, PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + ps.executeUpdate(); + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not reset Training Camp: ", e); + } + + // Update data for online players. + World.getInstance().getPlayers().stream().forEach(player -> + { + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + player.getVariables().storeMe(); + }); + } + + LOGGER.info("Special Hunting Zones has been resetted."); + } + public void resetHomunculusResetPoints() { // Update data for offline players. @@ -357,10 +395,10 @@ public class DailyTaskManager extends AbstractEventManager> // Update data for online players. for (PlayerInstance player : World.getInstance().getPlayers()) { - player.getVariables().set("HOMUNCULUS_USED_RESET_KILLS", 0); - player.getVariables().set("HOMUNCULUS_USED_KILL_CONVERT", 0); - player.getVariables().set("HOMUNCULUS_USED_RESET_VP", 0); - player.getVariables().set("HOMUNCULUS_USED_VP_CONVERT", 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_VP, 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0); player.getVariables().storeMe(); } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml index 0659cbb744..4e472c2bf9 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml @@ -3,9 +3,8 @@ 194291,176604,-1888 3600 - 36000 21600 - 43200 + 7200 3600 150000 100 @@ -14,9 +13,8 @@ 9400,-21720,-3634 3600 - 36000 21600 - 43200 + 7200 3600 150000 105 @@ -25,9 +23,8 @@ -122259,73678,-2872 3600 - 36000 21600 - 43200 + 7200 3600 150000 107 @@ -36,9 +33,8 @@ 139411,-169382,-1600 3600 - 36000 21600 - 43200 + 18000 3600 150000 99 @@ -47,9 +43,8 @@ -82014,16247,-15416 36000 - 604800 - 43200 - 43200 + 36000 + 0 3600 150000 110 @@ -59,20 +54,28 @@ 181409,-78389,-2728 3600 - 36000 3600 - 43200 + 0 3600 150000 105 130 + -49013,15351,-8808 3600 - 36000 21600 - 43200 + 7200 3600 150000 112 diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/events/DailyTasks.xml index e70b936c3c..105f829cfe 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/events/DailyTasks.xml @@ -22,6 +22,16 @@ + + + + + + + + + + diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd index 7c75375766..d3aa0612e6 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd @@ -7,7 +7,7 @@ - + diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java index c1295a3c29..d7160c4685 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java @@ -29,6 +29,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.xml.DailyMissionData; +import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData; import org.l2jmobius.gameserver.model.DailyMissionDataHolder; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; @@ -40,6 +41,7 @@ import org.l2jmobius.gameserver.model.eventengine.AbstractEventManager; import org.l2jmobius.gameserver.model.eventengine.ScheduleTarget; import org.l2jmobius.gameserver.model.holders.SkillHolder; import org.l2jmobius.gameserver.model.holders.SubClassHolder; +import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder; import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.network.serverpackets.ExVoteSystemInfo; @@ -69,8 +71,8 @@ public class DailyTaskManager extends AbstractEventManager> resetRecommends(); resetWorldChatPoints(); resetTrainingCamp(); - resetThroneOfHeroes(); resetHomunculusResetPoints(); + onResetTimedHuntingZones(); } @ScheduleTarget @@ -299,7 +301,8 @@ public class DailyTaskManager extends AbstractEventManager> DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset); } - public void resetThroneOfHeroes() + @ScheduleTarget + public void onResetThroneOfHeroes() { // Update data for offline players. try (Connection con = DatabaseFactory.getConnection()) @@ -334,6 +337,41 @@ public class DailyTaskManager extends AbstractEventManager> LOGGER.info("Throne of Heroes Entry has been resetted."); } + @ScheduleTarget + public void onResetTimedHuntingZones() + { + for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones()) + { + if (holder.getResetDelay() > 0) + { + continue; + } + + // Update data for offline players. + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var IN (?, ?)")) + { + ps.setString(1, PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + ps.setString(2, PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + ps.executeUpdate(); + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not reset Training Camp: ", e); + } + + // Update data for online players. + World.getInstance().getPlayers().stream().forEach(player -> + { + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + player.getVariables().storeMe(); + }); + } + + LOGGER.info("Special Hunting Zones has been resetted."); + } + public void resetHomunculusResetPoints() { // Update data for offline players. @@ -357,10 +395,10 @@ public class DailyTaskManager extends AbstractEventManager> // Update data for online players. for (PlayerInstance player : World.getInstance().getPlayers()) { - player.getVariables().set("HOMUNCULUS_USED_RESET_KILLS", 0); - player.getVariables().set("HOMUNCULUS_USED_KILL_CONVERT", 0); - player.getVariables().set("HOMUNCULUS_USED_RESET_VP", 0); - player.getVariables().set("HOMUNCULUS_USED_VP_CONVERT", 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_VP, 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, 0); + player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0); player.getVariables().storeMe(); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml index 663de6c94e..71ba03e97e 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml @@ -3,7 +3,6 @@ 17613,-76862,-6265 3600 - 36000 18000 3600 3600 diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/events/DailyTasks.xml index 506b90a11f..172ba86ce9 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/events/DailyTasks.xml @@ -23,12 +23,16 @@ + + + + + - - 36000 46800 43200 3600 @@ -14,7 +13,6 @@ -112937,213590,-13248 3600 - 36000 21600 18000 3600 @@ -25,7 +23,6 @@ 115528,191580,-3371 3600 - 36000 46800 7200 3600 @@ -36,7 +33,6 @@ 133247,114445,-3724 25200 - 604800 151200 126000 3600 @@ -48,7 +44,6 @@ 63443,26304,-3755 3600 - 36000 46800 3600 3600 @@ -60,7 +55,6 @@ 125277,70262,-4408 3600 - 36000 46800 3600 3600 @@ -72,7 +66,6 @@ 148724,-22366,-3436 3600 - 36000 46800 3600 3600 @@ -84,7 +77,6 @@ 167965,28800,-3606 3600 - 36000 46800 3600 3600 @@ -96,7 +88,6 @@ 99797,110524,-3702 3600 - 36000 46800 3600 3600 @@ -108,7 +99,6 @@ -50416,145363,-2825 3600 - 36000 46800 3600 3600 diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/events/DailyTasks.xml index 8841899bf0..089f115019 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/events/DailyTasks.xml @@ -22,6 +22,11 @@ + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd index 7c75375766..d3aa0612e6 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd @@ -7,7 +7,7 @@ - + diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java index b4f79804eb..8a2b5158c5 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java @@ -31,6 +31,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.xml.DailyMissionData; +import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData; import org.l2jmobius.gameserver.model.DailyMissionDataHolder; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; @@ -42,6 +43,7 @@ import org.l2jmobius.gameserver.model.eventengine.AbstractEventManager; import org.l2jmobius.gameserver.model.eventengine.ScheduleTarget; import org.l2jmobius.gameserver.model.holders.SkillHolder; import org.l2jmobius.gameserver.model.holders.SubClassHolder; +import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder; import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -76,6 +78,7 @@ public class DailyTaskManager extends AbstractEventManager> resetTrainingCamp(); resetVitality(); resetVip(); + onResetTimedHuntingZones(); } @ScheduleTarget @@ -350,6 +353,41 @@ public class DailyTaskManager extends AbstractEventManager> DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset); } + @ScheduleTarget + public void onResetTimedHuntingZones() + { + for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones()) + { + if (holder.getResetDelay() > 0) + { + continue; + } + + // Update data for offline players. + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var IN (?, ?)")) + { + ps.setString(1, PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + ps.setString(2, PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + ps.executeUpdate(); + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not reset Training Camp: ", e); + } + + // Update data for online players. + World.getInstance().getPlayers().stream().forEach(player -> + { + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + player.getVariables().storeMe(); + }); + } + + LOGGER.info("Special Hunting Zones has been resetted."); + } + public static DailyTaskManager getInstance() { return SingletonHolder.INSTANCE; diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/TimedHuntingZoneData.xml index 5aa75351af..6a1e0d5f8d 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/TimedHuntingZoneData.xml +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/TimedHuntingZoneData.xml @@ -3,7 +3,6 @@ 6025,-2274,-2990 3600 - 36000 46800 43200 3600 @@ -14,7 +13,6 @@ -112937,213590,-13248 3600 - 36000 21600 18000 3600 @@ -25,7 +23,6 @@ 115528,191580,-3371 3600 - 36000 46800 7200 3600 @@ -36,7 +33,6 @@ 133247,114445,-3724 25200 - 604800 151200 126000 3600 @@ -48,7 +44,6 @@ 63443,26304,-3755 3600 - 36000 46800 3600 3600 @@ -60,7 +55,6 @@ 125277,70262,-4408 3600 - 36000 46800 3600 3600 @@ -72,7 +66,6 @@ 148724,-22366,-3436 3600 - 36000 46800 3600 3600 @@ -84,7 +77,6 @@ 167965,28800,-3606 3600 - 36000 46800 3600 3600 @@ -96,7 +88,6 @@ 99797,110524,-3702 3600 - 36000 46800 3600 3600 @@ -108,7 +99,6 @@ -50416,145363,-2825 3600 - 36000 46800 3600 3600 diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/events/DailyTasks.xml index 8841899bf0..820b83296a 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/events/DailyTasks.xml @@ -22,6 +22,11 @@ + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/xsd/TimedHuntingZoneData.xsd index 7c75375766..d3aa0612e6 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/xsd/TimedHuntingZoneData.xsd +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/xsd/TimedHuntingZoneData.xsd @@ -7,7 +7,7 @@ - + diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java index f9f8e4222d..545e549250 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java @@ -31,6 +31,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.xml.DailyMissionData; +import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData; import org.l2jmobius.gameserver.model.DailyMissionDataHolder; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; @@ -42,6 +43,7 @@ import org.l2jmobius.gameserver.model.eventengine.AbstractEventManager; import org.l2jmobius.gameserver.model.eventengine.ScheduleTarget; import org.l2jmobius.gameserver.model.holders.SkillHolder; import org.l2jmobius.gameserver.model.holders.SubClassHolder; +import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder; import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -77,6 +79,7 @@ public class DailyTaskManager extends AbstractEventManager> resetVitality(); resetVip(); resetClanDonationPoints(); + onResetTimedHuntingZones(); } @ScheduleTarget @@ -381,6 +384,41 @@ public class DailyTaskManager extends AbstractEventManager> DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset); } + @ScheduleTarget + public void onResetTimedHuntingZones() + { + for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones()) + { + if (holder.getResetDelay() > 0) + { + continue; + } + + // Update data for offline players. + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var IN (?, ?)")) + { + ps.setString(1, PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + ps.setString(2, PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + ps.executeUpdate(); + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not reset Training Camp: ", e); + } + + // Update data for online players. + World.getInstance().getPlayers().stream().forEach(player -> + { + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + player.getVariables().storeMe(); + }); + } + + LOGGER.info("Special Hunting Zones has been resetted."); + } + public static DailyTaskManager getInstance() { return SingletonHolder.INSTANCE; diff --git a/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/TimedHuntingZoneData.xml index 5aa75351af..6a1e0d5f8d 100644 --- a/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/TimedHuntingZoneData.xml +++ b/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/TimedHuntingZoneData.xml @@ -3,7 +3,6 @@ 6025,-2274,-2990 3600 - 36000 46800 43200 3600 @@ -14,7 +13,6 @@ -112937,213590,-13248 3600 - 36000 21600 18000 3600 @@ -25,7 +23,6 @@ 115528,191580,-3371 3600 - 36000 46800 7200 3600 @@ -36,7 +33,6 @@ 133247,114445,-3724 25200 - 604800 151200 126000 3600 @@ -48,7 +44,6 @@ 63443,26304,-3755 3600 - 36000 46800 3600 3600 @@ -60,7 +55,6 @@ 125277,70262,-4408 3600 - 36000 46800 3600 3600 @@ -72,7 +66,6 @@ 148724,-22366,-3436 3600 - 36000 46800 3600 3600 @@ -84,7 +77,6 @@ 167965,28800,-3606 3600 - 36000 46800 3600 3600 @@ -96,7 +88,6 @@ 99797,110524,-3702 3600 - 36000 46800 3600 3600 @@ -108,7 +99,6 @@ -50416,145363,-2825 3600 - 36000 46800 3600 3600 diff --git a/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/events/DailyTasks.xml b/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/events/DailyTasks.xml index 8841899bf0..820b83296a 100644 --- a/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/events/DailyTasks.xml +++ b/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/events/DailyTasks.xml @@ -22,6 +22,11 @@ + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd index 7c75375766..d3aa0612e6 100644 --- a/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd +++ b/L2J_Mobius_Essence_5.5_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd @@ -7,7 +7,7 @@ - + diff --git a/L2J_Mobius_Essence_5.5_FrostLord/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java b/L2J_Mobius_Essence_5.5_FrostLord/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java index f9f8e4222d..545e549250 100644 --- a/L2J_Mobius_Essence_5.5_FrostLord/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java +++ b/L2J_Mobius_Essence_5.5_FrostLord/java/org/l2jmobius/gameserver/instancemanager/DailyTaskManager.java @@ -31,6 +31,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.xml.DailyMissionData; +import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData; import org.l2jmobius.gameserver.model.DailyMissionDataHolder; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; @@ -42,6 +43,7 @@ import org.l2jmobius.gameserver.model.eventengine.AbstractEventManager; import org.l2jmobius.gameserver.model.eventengine.ScheduleTarget; import org.l2jmobius.gameserver.model.holders.SkillHolder; import org.l2jmobius.gameserver.model.holders.SubClassHolder; +import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder; import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -77,6 +79,7 @@ public class DailyTaskManager extends AbstractEventManager> resetVitality(); resetVip(); resetClanDonationPoints(); + onResetTimedHuntingZones(); } @ScheduleTarget @@ -381,6 +384,41 @@ public class DailyTaskManager extends AbstractEventManager> DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset); } + @ScheduleTarget + public void onResetTimedHuntingZones() + { + for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones()) + { + if (holder.getResetDelay() > 0) + { + continue; + } + + // Update data for offline players. + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var IN (?, ?)")) + { + ps.setString(1, PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + ps.setString(2, PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + ps.executeUpdate(); + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not reset Training Camp: ", e); + } + + // Update data for online players. + World.getInstance().getPlayers().stream().forEach(player -> + { + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_ENTRY + holder.getZoneId()); + player.getVariables().remove(PlayerVariables.HUNTING_ZONE_TIME + holder.getZoneId()); + player.getVariables().storeMe(); + }); + } + + LOGGER.info("Special Hunting Zones has been resetted."); + } + public static DailyTaskManager getInstance() { return SingletonHolder.INSTANCE;