ItemsAutoDestroy class is a task manager.

This commit is contained in:
MobiusDevelopment
2021-05-01 22:03:13 +00:00
parent 5d09adde70
commit 81e6724e37
132 changed files with 1942 additions and 1919 deletions
@@ -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();
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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();
}
}
@@ -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();
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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();
}
}
@@ -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();
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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();
}
}
@@ -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();
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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");
@@ -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);
}
}
@@ -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);
@@ -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)
{
@@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _items = ConcurrentHashMap.newKeySet();
private final Set<ItemInstance> _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();
}
}
@@ -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");
@@ -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);
}
}
@@ -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);
@@ -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)
{
@@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _items = ConcurrentHashMap.newKeySet();
private final Set<ItemInstance> _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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);
@@ -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)
{
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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();
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemInstance> _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<ItemInstance> 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();
}
}
@@ -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);
}
}
}
@@ -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);

Some files were not shown because too many files have changed in this diff Show More