From 81e6724e37ca174d2d85165e6cc9c4682da384cd Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 1 May 2021 22:03:13 +0000 Subject: [PATCH] ItemsAutoDestroy class is a task manager. --- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java} | 18 ++-- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java} | 18 ++-- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java} | 18 ++-- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java} | 18 ++-- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../gameserver/model/actor/Attackable.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java} | 16 +-- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../gameserver/model/actor/Attackable.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java} | 16 +-- .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ .../org/l2jmobius/gameserver/GameServer.java | 3 +- .../gameserver/ItemsAutoDestroy.java | 99 ------------------- .../instancemanager/ItemsOnGroundManager.java | 4 +- .../l2jmobius/gameserver/model/actor/Npc.java | 4 +- .../model/actor/instance/PlayerInstance.java | 6 +- .../ItemsAutoDestroyTaskManager.java | 99 +++++++++++++++++++ 132 files changed, 1942 insertions(+), 1919 deletions(-) rename L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/{ItemsAutoDestroy.java => taskmanager/ItemsAutoDestroyTaskManager.java} (86%) rename L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/{ItemsAutoDestroy.java => taskmanager/ItemsAutoDestroyTaskManager.java} (86%) rename L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/{ItemsAutoDestroy.java => taskmanager/ItemsAutoDestroyTaskManager.java} (86%) rename L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/{ItemsAutoDestroy.java => taskmanager/ItemsAutoDestroyTaskManager.java} (86%) delete mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java rename L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/{ItemsAutoDestroy.java => taskmanager/ItemsAutoDestroyTaskManager.java} (81%) rename L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/{ItemsAutoDestroy.java => taskmanager/ItemsAutoDestroyTaskManager.java} (83%) delete mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java delete mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java create mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java index 089ac383d5..e87382f4de 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java @@ -152,6 +152,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -394,7 +395,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java index d041ee95a1..043e357963 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 8bf26f4e39..c6433e0e9e 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -51,7 +51,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -345,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3720,7 +3720,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3796,7 +3796,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java similarity index 86% rename from L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java rename to L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java index cfb16ebb07..3801c5e071 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.taskmanager; import java.util.Iterator; import java.util.LinkedList; @@ -27,20 +27,15 @@ import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; -public class ItemsAutoDestroy +public class ItemsAutoDestroyTaskManager { private final List _items = new LinkedList<>(); - protected ItemsAutoDestroy() + protected ItemsAutoDestroyTaskManager() { ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); } - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - public synchronized void addItem(ItemInstance item) { item.setDropTime(Chronos.currentTimeMillis()); @@ -92,8 +87,13 @@ public class ItemsAutoDestroy } } + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + private static class SingletonHolder { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); } } \ No newline at end of file diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java index 25b3b668da..7fc0802de6 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java @@ -156,6 +156,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -402,7 +403,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 3c6fd99af1..d136baca1e 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -51,7 +51,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -347,6 +346,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3726,7 +3726,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3802,7 +3802,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java similarity index 86% rename from L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java rename to L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java index cfb16ebb07..3801c5e071 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.taskmanager; import java.util.Iterator; import java.util.LinkedList; @@ -27,20 +27,15 @@ import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; -public class ItemsAutoDestroy +public class ItemsAutoDestroyTaskManager { private final List _items = new LinkedList<>(); - protected ItemsAutoDestroy() + protected ItemsAutoDestroyTaskManager() { ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); } - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - public synchronized void addItem(ItemInstance item) { item.setDropTime(Chronos.currentTimeMillis()); @@ -92,8 +87,13 @@ public class ItemsAutoDestroy } } + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + private static class SingletonHolder { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); } } \ No newline at end of file diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java index 25b3b668da..7fc0802de6 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java @@ -156,6 +156,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -402,7 +403,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 2acc8b79f7..40f014adcc 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -51,7 +51,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -349,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3728,7 +3728,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3804,7 +3804,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java similarity index 86% rename from L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java rename to L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java index cfb16ebb07..3801c5e071 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.taskmanager; import java.util.Iterator; import java.util.LinkedList; @@ -27,20 +27,15 @@ import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; -public class ItemsAutoDestroy +public class ItemsAutoDestroyTaskManager { private final List _items = new LinkedList<>(); - protected ItemsAutoDestroy() + protected ItemsAutoDestroyTaskManager() { ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); } - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - public synchronized void addItem(ItemInstance item) { item.setDropTime(Chronos.currentTimeMillis()); @@ -92,8 +87,13 @@ public class ItemsAutoDestroy } } + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + private static class SingletonHolder { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); } } \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java index cfdac0ed6f..ec594ba6f1 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java @@ -156,6 +156,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -402,7 +403,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 011e8107ca..a1beb75c67 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -50,7 +50,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -353,6 +352,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3724,7 +3724,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3800,7 +3800,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java similarity index 86% rename from L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java rename to L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java index cfb16ebb07..3801c5e071 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.taskmanager; import java.util.Iterator; import java.util.LinkedList; @@ -27,20 +27,15 @@ import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; -public class ItemsAutoDestroy +public class ItemsAutoDestroyTaskManager { private final List _items = new LinkedList<>(); - protected ItemsAutoDestroy() + protected ItemsAutoDestroyTaskManager() { ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); } - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - public synchronized void addItem(ItemInstance item) { item.setDropTime(Chronos.currentTimeMillis()); @@ -92,8 +87,13 @@ public class ItemsAutoDestroy } } + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + private static class SingletonHolder { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); } } \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java index 9f9cd23296..35e9c5f946 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java @@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -406,7 +407,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 5ce5d271ca..30d5c67e15 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -50,7 +50,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -351,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3703,7 +3703,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3779,7 +3779,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java index 9f9cd23296..35e9c5f946 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java @@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -406,7 +407,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index ae0adce8d7..1251d0731b 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -50,7 +50,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -351,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3703,7 +3703,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3779,7 +3779,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java index 206cf86d3c..d37ab9a4e8 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java @@ -159,6 +159,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -408,7 +409,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index de0c4cfa42..e45a622dcc 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -50,7 +50,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -351,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3704,7 +3704,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3780,7 +3780,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java index 3156ab5e86..f6e31744bc 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java @@ -162,6 +162,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -414,7 +415,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index cb7334bcf5..8c2ca00d60 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -51,7 +51,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -362,6 +361,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookR import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3638,7 +3638,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3714,7 +3714,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java index 2a5edbe856..e52e8a6998 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java @@ -161,6 +161,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -412,7 +413,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 9dfdc6dd95..9a1de0dcfd 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -51,7 +51,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -358,6 +357,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3646,7 +3646,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3722,7 +3722,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java index 2a5edbe856..e52e8a6998 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java @@ -161,6 +161,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -412,7 +413,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java index 903629fe24..bc73bc959f 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 6803cd6f9c..c42e6018d6 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -51,7 +51,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CreatureAI.IntentionCommand; @@ -358,6 +357,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3646,7 +3646,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3722,7 +3722,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java index 8805487aae..3575319211 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java @@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.network.ClientNetworkManager; import org.l2jmobius.gameserver.script.EventDroplist; import org.l2jmobius.gameserver.script.faenor.FaenorScriptEngine; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.telnet.TelnetStatusThread; @@ -306,7 +307,7 @@ public class GameServer } if (Config.AUTODESTROY_ITEM_AFTER > 0) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } Util.printSection("Manor"); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index b614bc9741..c26dcf1eb8 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -28,11 +28,11 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.type.EtcItemType; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground @@ -139,7 +139,7 @@ public class ItemsOnGroundManager // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && (result.getLong(8) > -1) && ((Config.AUTODESTROY_ITEM_AFTER > 0) && (item.getItemType() != EtcItemType.HERB))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java index d5897f5cd6..2f6e951d83 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -25,7 +25,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.ai.AttackableAI; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CtrlEvent; @@ -66,6 +65,7 @@ import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.script.EventDroplist; import org.l2jmobius.gameserver.script.EventDroplist.DateDrop; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Util; /** @@ -1978,7 +1978,7 @@ public class Attackable extends NpcInstance // Add drop to auto destroy item task if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && ((Config.AUTODESTROY_ITEM_AFTER > 0) && (ditem.getItemType() != EtcItemType.HERB))) { - ItemsAutoDestroy.getInstance().addItem(ditem); + ItemsAutoDestroyTaskManager.getInstance().addItem(ditem); } ditem.setProtected(false); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 7d300c305f..9e8d52dd4e 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -40,7 +40,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -221,6 +220,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradePressOwnOk; import org.l2jmobius.gameserver.network.serverpackets.TradeStart; import org.l2jmobius.gameserver.network.serverpackets.UserInfo; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -4019,7 +4019,7 @@ public class PlayerInstance extends Playable if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getItemId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { @@ -4100,7 +4100,7 @@ public class PlayerInstance extends Playable if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getItemId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java similarity index 81% rename from L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java rename to L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java index 1625fd0a02..b2958d271f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.taskmanager; -import java.util.Collection; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -27,13 +27,13 @@ import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; -public class ItemsAutoDestroy +public class ItemsAutoDestroyTaskManager { - protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroy.class.getName()); + protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroyTaskManager.class.getName()); - private final Collection _items = ConcurrentHashMap.newKeySet(); + private final Set _items = ConcurrentHashMap.newKeySet(); - protected ItemsAutoDestroy() + protected ItemsAutoDestroyTaskManager() { ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); } @@ -72,13 +72,13 @@ public class ItemsAutoDestroy } } - public static ItemsAutoDestroy getInstance() + public static ItemsAutoDestroyTaskManager getInstance() { return SingletonHolder.INSTANCE; } private static class SingletonHolder { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java index 6d3206dbe6..e71c151b6b 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java @@ -124,6 +124,7 @@ import org.l2jmobius.gameserver.network.ClientNetworkManager; import org.l2jmobius.gameserver.script.EventDroplist; import org.l2jmobius.gameserver.script.faenor.FaenorScriptEngine; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.telnet.TelnetStatusThread; @@ -313,7 +314,7 @@ public class GameServer } if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } Util.printSection("Manor"); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index a26db94b5e..f64d1a80fa 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -28,11 +28,11 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.type.EtcItemType; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground @@ -139,7 +139,7 @@ public class ItemsOnGroundManager // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && (result.getLong(8) > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && (item.getItemType() != EtcItemType.HERB)) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && (item.getItemType() == EtcItemType.HERB)))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java index 3a86ef010b..4ffd4957e2 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -25,7 +25,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.ai.AttackableAI; import org.l2jmobius.gameserver.ai.CreatureAI; import org.l2jmobius.gameserver.ai.CtrlEvent; @@ -67,6 +66,7 @@ import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.script.EventDroplist; import org.l2jmobius.gameserver.script.EventDroplist.DateDrop; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Util; /** @@ -2330,7 +2330,7 @@ public class Attackable extends NpcInstance // Add drop to auto destroy item task if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && (ditem.getItemType() != EtcItemType.HERB)) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && (ditem.getItemType() == EtcItemType.HERB)))) { - ItemsAutoDestroy.getInstance().addItem(ditem); + ItemsAutoDestroyTaskManager.getInstance().addItem(ditem); } ditem.setProtected(false); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 16fbf4fe60..ebd5a3f8cb 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -40,7 +40,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -229,6 +228,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradePressOwnOk; import org.l2jmobius.gameserver.network.serverpackets.TradeStart; import org.l2jmobius.gameserver.network.serverpackets.UserInfo; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -4095,7 +4095,7 @@ public class PlayerInstance extends Playable if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getItemId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { @@ -4176,7 +4176,7 @@ public class PlayerInstance extends Playable if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getItemId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java similarity index 83% rename from L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java rename to L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java index da0bd01a3e..15ede96256 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.taskmanager; -import java.util.Collection; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; @@ -28,13 +28,13 @@ import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.type.EtcItemType; -public class ItemsAutoDestroy +public class ItemsAutoDestroyTaskManager { - protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroy.class.getName()); + protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroyTaskManager.class.getName()); - private final Collection _items = ConcurrentHashMap.newKeySet(); + private final Set _items = ConcurrentHashMap.newKeySet(); - protected ItemsAutoDestroy() + protected ItemsAutoDestroyTaskManager() { ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); } @@ -87,13 +87,13 @@ public class ItemsAutoDestroy } } - public static ItemsAutoDestroy getInstance() + public static ItemsAutoDestroyTaskManager getInstance() { return SingletonHolder.INSTANCE; } private static class SingletonHolder { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java index e631419f73..163a9a4322 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java @@ -152,6 +152,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -387,7 +388,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index 7b85138fa5..9f3d182f41 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java index 9f6d1518e5..a03ca2e2a7 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -28,7 +28,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.NpcPersonalAIData; @@ -101,6 +100,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1828,7 +1828,7 @@ public class Npc extends Creature { if (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } item.setProtected(false); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 03dab26a8b..f823c1b9d0 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -49,7 +49,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -322,6 +321,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeStart; import org.l2jmobius.gameserver.network.serverpackets.UserInfo; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3751,7 +3751,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3832,7 +3832,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java index 726e403b02..6880fbeaba 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java @@ -153,6 +153,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -389,7 +390,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index 7b85138fa5..9f3d182f41 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java index 9f6d1518e5..a03ca2e2a7 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -28,7 +28,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.NpcPersonalAIData; @@ -101,6 +100,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1828,7 +1828,7 @@ public class Npc extends Creature { if (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } item.setProtected(false); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 314f2e9af5..3446d37d91 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -49,7 +49,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -327,6 +326,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeStart; import org.l2jmobius.gameserver.network.serverpackets.UserInfo; import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3662,7 +3662,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3743,7 +3743,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java index ce3a3abb45..08810b4b83 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java @@ -155,6 +155,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -403,7 +404,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java index f90ac3523d..588693e68a 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 3190272037..9bb11c887c 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -52,7 +52,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -350,6 +349,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3699,7 +3699,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3775,7 +3775,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java index ce3a3abb45..08810b4b83 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java @@ -155,6 +155,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -403,7 +404,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java index f90ac3523d..588693e68a 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index e2b12db0f0..795eed78f7 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -52,7 +52,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -350,6 +349,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3699,7 +3699,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3775,7 +3775,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java index dcdf5c3ad8..d5863219e0 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java @@ -156,6 +156,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -405,7 +406,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java index f90ac3523d..588693e68a 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -103,6 +102,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1581,7 +1581,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index ca8b75ff20..7b5c729265 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -52,7 +52,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -348,6 +347,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3683,7 +3683,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3759,7 +3759,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java index 21e00af824..3a09410047 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java @@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -407,7 +408,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java index 03f6443c84..402e0206cb 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -104,6 +103,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1593,7 +1593,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 2f570f1826..6595d42f62 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -53,7 +53,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -351,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3695,7 +3695,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3771,7 +3771,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java index 3bd95e8f1a..92c4877ea2 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java @@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -409,7 +410,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java index 03f6443c84..402e0206cb 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -104,6 +103,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1593,7 +1593,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 69d3708d99..a5ea894ac3 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -53,7 +53,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -351,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3695,7 +3695,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3771,7 +3771,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java index 616bdf5f4e..26cf10aa24 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java @@ -161,6 +161,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -415,7 +416,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java index 03f6443c84..402e0206cb 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -104,6 +103,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1593,7 +1593,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index f8752df2d0..bfd69b24b5 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -54,7 +54,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -364,6 +363,7 @@ import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3619,7 +3619,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3695,7 +3695,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java index 8965a94443..bcab93721b 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java @@ -153,6 +153,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -398,7 +399,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java index ee79382c14..788593b58b 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -101,6 +100,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1565,7 +1565,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4533b9720d..e730803d96 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -50,7 +50,6 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -345,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3680,7 +3680,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3756,7 +3756,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java index ecc47e8d17..f36d86cf52 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java @@ -165,6 +165,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -423,7 +424,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java index 03f6443c84..402e0206cb 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -104,6 +103,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1593,7 +1593,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 847b79431d..81cb5a2931 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -54,7 +54,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -371,6 +370,7 @@ import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3663,7 +3663,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3745,7 +3745,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java index ba556ce9f1..a1bcd408cd 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java @@ -166,6 +166,7 @@ import org.l2jmobius.gameserver.network.NpcStringId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.telnet.TelnetServer; import org.l2jmobius.gameserver.scripting.ScriptEngineManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.TaskManager; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.gameserver.util.Broadcast; @@ -425,7 +426,7 @@ public class GameServer if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0)) { - ItemsAutoDestroy.getInstance(); + ItemsAutoDestroyTaskManager.getInstance(); } MonsterRace.getInstance(); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java deleted file mode 100644 index cfb16ebb07..0000000000 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ItemsAutoDestroy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.concurrent.ThreadPool; -import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.enums.ItemLocation; -import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.model.items.instance.ItemInstance; - -public class ItemsAutoDestroy -{ - private final List _items = new LinkedList<>(); - - protected ItemsAutoDestroy() - { - ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); - } - - public static ItemsAutoDestroy getInstance() - { - return SingletonHolder.INSTANCE; - } - - public synchronized void addItem(ItemInstance item) - { - item.setDropTime(Chronos.currentTimeMillis()); - _items.add(item); - } - - private synchronized void removeItems() - { - if (_items.isEmpty()) - { - return; - } - - final long curtime = Chronos.currentTimeMillis(); - final Iterator itemIterator = _items.iterator(); - while (itemIterator.hasNext()) - { - final ItemInstance item = itemIterator.next(); - if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) - { - itemIterator.remove(); - } - else - { - final long autoDestroyTime; - if (item.getItem().getAutoDestroyTime() > 0) - { - autoDestroyTime = item.getItem().getAutoDestroyTime(); - } - else if (item.getItem().hasExImmediateEffect()) - { - autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; - } - else - { - autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); - } - - if ((curtime - item.getDropTime()) > autoDestroyTime) - { - item.decayMe(); - itemIterator.remove(); - if (Config.SAVE_DROPPED_ITEM) - { - ItemsOnGroundManager.getInstance().removeObject(item); - } - } - } - } - } - - private static class SingletonHolder - { - protected static final ItemsAutoDestroy INSTANCE = new ItemsAutoDestroy(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java index dfb4734ca5..d8cfeac500 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ItemsOnGroundManager.java @@ -30,9 +30,9 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Chronos; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; /** * This class manage all items on ground. @@ -128,7 +128,7 @@ public class ItemsOnGroundManager implements Runnable // add to ItemsAutoDestroy only items not protected if (!Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && (dropTime > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } } } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Npc.java index 03f6443c84..402e0206cb 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -24,7 +24,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.ItemTable; import org.l2jmobius.gameserver.data.xml.ClanHallData; @@ -104,6 +103,7 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcSay; import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.taskmanager.DecayTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.util.Broadcast; /** @@ -1593,7 +1593,7 @@ public class Npc extends Creature // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } item.setProtected(false); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 6c09567cb4..2eebe08179 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -54,7 +54,6 @@ import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.GameTimeController; -import org.l2jmobius.gameserver.ItemsAutoDestroy; import org.l2jmobius.gameserver.LoginServerThread; import org.l2jmobius.gameserver.RecipeController; import org.l2jmobius.gameserver.ai.CreatureAI; @@ -371,6 +370,7 @@ import org.l2jmobius.gameserver.network.serverpackets.vip.ReceiveVipInfo; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; +import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager; import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager; import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager; import org.l2jmobius.gameserver.util.Broadcast; @@ -3663,7 +3663,7 @@ public class PlayerInstance extends Playable droppedItem.dropMe(this, (getX() + Rnd.get(50)) - 25, (getY() + Rnd.get(50)) - 25, getZ() + 20); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(droppedItem.getId()) && ((droppedItem.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !droppedItem.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(droppedItem); + ItemsAutoDestroyTaskManager.getInstance().addItem(droppedItem); } // protection against auto destroy dropped item @@ -3745,7 +3745,7 @@ public class PlayerInstance extends Playable item.dropMe(this, x, y, z); if ((Config.AUTODESTROY_ITEM_AFTER > 0) && Config.DESTROY_DROPPED_PLAYER_ITEM && !Config.LIST_PROTECTED_ITEMS.contains(item.getId()) && ((item.isEquipable() && Config.DESTROY_EQUIPABLE_PLAYER_ITEM) || !item.isEquipable())) { - ItemsAutoDestroy.getInstance().addItem(item); + ItemsAutoDestroyTaskManager.getInstance().addItem(item); } if (Config.DESTROY_DROPPED_PLAYER_ITEM) { diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java new file mode 100644 index 0000000000..3801c5e071 --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/taskmanager/ItemsAutoDestroyTaskManager.java @@ -0,0 +1,99 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.taskmanager; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.commons.util.Chronos; +import org.l2jmobius.gameserver.enums.ItemLocation; +import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; + +public class ItemsAutoDestroyTaskManager +{ + private final List _items = new LinkedList<>(); + + protected ItemsAutoDestroyTaskManager() + { + ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000); + } + + public synchronized void addItem(ItemInstance item) + { + item.setDropTime(Chronos.currentTimeMillis()); + _items.add(item); + } + + private synchronized void removeItems() + { + if (_items.isEmpty()) + { + return; + } + + final long curtime = Chronos.currentTimeMillis(); + final Iterator itemIterator = _items.iterator(); + while (itemIterator.hasNext()) + { + final ItemInstance item = itemIterator.next(); + if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) + { + itemIterator.remove(); + } + else + { + final long autoDestroyTime; + if (item.getItem().getAutoDestroyTime() > 0) + { + autoDestroyTime = item.getItem().getAutoDestroyTime(); + } + else if (item.getItem().hasExImmediateEffect()) + { + autoDestroyTime = Config.HERB_AUTO_DESTROY_TIME; + } + else + { + autoDestroyTime = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000); + } + + if ((curtime - item.getDropTime()) > autoDestroyTime) + { + item.decayMe(); + itemIterator.remove(); + if (Config.SAVE_DROPPED_ITEM) + { + ItemsOnGroundManager.getInstance().removeObject(item); + } + } + } + } + } + + public static ItemsAutoDestroyTaskManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final ItemsAutoDestroyTaskManager INSTANCE = new ItemsAutoDestroyTaskManager(); + } +} \ No newline at end of file