Runnable implementations for task manager classes.
This commit is contained in:
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
@@ -40,9 +40,16 @@ public class CreatureFollowTaskManager
|
||||
private static boolean _workingNormal = false;
|
||||
private static boolean _workingAttack = false;
|
||||
|
||||
public CreatureFollowTaskManager()
|
||||
protected CreatureFollowTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowNormalTask(), 1000, 1000);
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowAttackTask(), 500, 500);
|
||||
}
|
||||
|
||||
protected class CreatureFollowNormalTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingNormal)
|
||||
{
|
||||
@@ -56,9 +63,13 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingNormal = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class CreatureFollowAttackTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingAttack)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingAttack = false;
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void follow(Creature creature, int range)
|
||||
|
@@ -25,14 +25,18 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class CreatureSeeTaskManager
|
||||
public class CreatureSeeTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public CreatureSeeTaskManager()
|
||||
protected CreatureSeeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -46,7 +50,6 @@ public class CreatureSeeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Creature creature)
|
||||
|
@@ -30,14 +30,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DecayTaskManager
|
||||
public class DecayTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public DecayTaskManager()
|
||||
protected DecayTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -57,7 +61,6 @@ public class DecayTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemAppearanceTaskManager
|
||||
public class ItemAppearanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemAppearanceTaskManager()
|
||||
protected ItemAppearanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemAppearanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemLifeTimeTaskManager
|
||||
public class ItemLifeTimeTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemLifeTimeTaskManager()
|
||||
protected ItemLifeTimeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemLifeTimeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,15 +27,19 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemManaTaskManager
|
||||
public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static final int MANA_CONSUMPTION_RATE = 60000;
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemManaTaskManager()
|
||||
protected ItemManaTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -55,7 +59,6 @@ public class ItemManaTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item)
|
||||
|
@@ -16,9 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -27,22 +26,17 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
public class ItemsAutoDestroyTaskManager
|
||||
public class ItemsAutoDestroyTaskManager implements Runnable
|
||||
{
|
||||
private final List<ItemInstance> _items = new LinkedList<>();
|
||||
private final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected ItemsAutoDestroyTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
|
||||
ThreadPool.scheduleAtFixedRate(this, 5000, 5000);
|
||||
}
|
||||
|
||||
public synchronized void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
private synchronized void removeItems()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
@@ -50,13 +44,11 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
|
||||
final long curtime = Chronos.currentTimeMillis();
|
||||
final Iterator<ItemInstance> itemIterator = _items.iterator();
|
||||
while (itemIterator.hasNext())
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
final ItemInstance item = itemIterator.next();
|
||||
if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
|
||||
{
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +69,7 @@ public class ItemsAutoDestroyTaskManager
|
||||
if ((curtime - item.getDropTime()) > autoDestroyTime)
|
||||
{
|
||||
item.decayMe();
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().removeObject(item);
|
||||
@@ -87,6 +79,12 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public static ItemsAutoDestroyTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -32,14 +32,18 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class MessageDeletionTaskManager
|
||||
public class MessageDeletionTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Integer, Long> PENDING_MESSAGES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public MessageDeletionTaskManager()
|
||||
protected MessageDeletionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -90,7 +94,6 @@ public class MessageDeletionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 10000, 10000);
|
||||
}
|
||||
|
||||
public void add(int msgId, long deletionTime)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
public class PlayerAutoSaveTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
protected PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class PlayerAutoSaveTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
public class PvpFlagTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
protected PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -62,7 +66,6 @@ public class PvpFlagTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -29,14 +29,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RandomAnimationTaskManager
|
||||
public class RandomAnimationTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RandomAnimationTaskManager()
|
||||
protected RandomAnimationTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class RandomAnimationTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RespawnTaskManager
|
||||
public class RespawnTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RespawnTaskManager()
|
||||
protected RespawnTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -60,7 +64,6 @@ public class RespawnTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc, long time)
|
||||
|
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
@@ -40,9 +40,16 @@ public class CreatureFollowTaskManager
|
||||
private static boolean _workingNormal = false;
|
||||
private static boolean _workingAttack = false;
|
||||
|
||||
public CreatureFollowTaskManager()
|
||||
protected CreatureFollowTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowNormalTask(), 1000, 1000);
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowAttackTask(), 500, 500);
|
||||
}
|
||||
|
||||
protected class CreatureFollowNormalTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingNormal)
|
||||
{
|
||||
@@ -56,9 +63,13 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingNormal = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class CreatureFollowAttackTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingAttack)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingAttack = false;
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void follow(Creature creature, int range)
|
||||
|
@@ -25,14 +25,18 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class CreatureSeeTaskManager
|
||||
public class CreatureSeeTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public CreatureSeeTaskManager()
|
||||
protected CreatureSeeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -46,7 +50,6 @@ public class CreatureSeeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Creature creature)
|
||||
|
@@ -30,14 +30,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DecayTaskManager
|
||||
public class DecayTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public DecayTaskManager()
|
||||
protected DecayTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -57,7 +61,6 @@ public class DecayTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemAppearanceTaskManager
|
||||
public class ItemAppearanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemAppearanceTaskManager()
|
||||
protected ItemAppearanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemAppearanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemLifeTimeTaskManager
|
||||
public class ItemLifeTimeTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemLifeTimeTaskManager()
|
||||
protected ItemLifeTimeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemLifeTimeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,15 +27,19 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemManaTaskManager
|
||||
public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static final int MANA_CONSUMPTION_RATE = 60000;
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemManaTaskManager()
|
||||
protected ItemManaTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -55,7 +59,6 @@ public class ItemManaTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item)
|
||||
|
@@ -16,9 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -27,22 +26,17 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
public class ItemsAutoDestroyTaskManager
|
||||
public class ItemsAutoDestroyTaskManager implements Runnable
|
||||
{
|
||||
private final List<ItemInstance> _items = new LinkedList<>();
|
||||
private final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected ItemsAutoDestroyTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
|
||||
ThreadPool.scheduleAtFixedRate(this, 5000, 5000);
|
||||
}
|
||||
|
||||
public synchronized void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
private synchronized void removeItems()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
@@ -50,13 +44,11 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
|
||||
final long curtime = Chronos.currentTimeMillis();
|
||||
final Iterator<ItemInstance> itemIterator = _items.iterator();
|
||||
while (itemIterator.hasNext())
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
final ItemInstance item = itemIterator.next();
|
||||
if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
|
||||
{
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +69,7 @@ public class ItemsAutoDestroyTaskManager
|
||||
if ((curtime - item.getDropTime()) > autoDestroyTime)
|
||||
{
|
||||
item.decayMe();
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().removeObject(item);
|
||||
@@ -87,6 +79,12 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public static ItemsAutoDestroyTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -32,14 +32,18 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class MessageDeletionTaskManager
|
||||
public class MessageDeletionTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Integer, Long> PENDING_MESSAGES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public MessageDeletionTaskManager()
|
||||
protected MessageDeletionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -90,7 +94,6 @@ public class MessageDeletionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 10000, 10000);
|
||||
}
|
||||
|
||||
public void add(int msgId, long deletionTime)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
public class PlayerAutoSaveTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
protected PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class PlayerAutoSaveTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
public class PvpFlagTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
protected PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -62,7 +66,6 @@ public class PvpFlagTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -29,14 +29,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RandomAnimationTaskManager
|
||||
public class RandomAnimationTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RandomAnimationTaskManager()
|
||||
protected RandomAnimationTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class RandomAnimationTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RespawnTaskManager
|
||||
public class RespawnTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RespawnTaskManager()
|
||||
protected RespawnTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -60,7 +64,6 @@ public class RespawnTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc, long time)
|
||||
|
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
@@ -40,9 +40,16 @@ public class CreatureFollowTaskManager
|
||||
private static boolean _workingNormal = false;
|
||||
private static boolean _workingAttack = false;
|
||||
|
||||
public CreatureFollowTaskManager()
|
||||
protected CreatureFollowTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowNormalTask(), 1000, 1000);
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowAttackTask(), 500, 500);
|
||||
}
|
||||
|
||||
protected class CreatureFollowNormalTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingNormal)
|
||||
{
|
||||
@@ -56,9 +63,13 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingNormal = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class CreatureFollowAttackTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingAttack)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingAttack = false;
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void follow(Creature creature, int range)
|
||||
|
@@ -25,14 +25,18 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class CreatureSeeTaskManager
|
||||
public class CreatureSeeTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public CreatureSeeTaskManager()
|
||||
protected CreatureSeeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -46,7 +50,6 @@ public class CreatureSeeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Creature creature)
|
||||
|
@@ -30,14 +30,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DecayTaskManager
|
||||
public class DecayTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public DecayTaskManager()
|
||||
protected DecayTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -57,7 +61,6 @@ public class DecayTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemAppearanceTaskManager
|
||||
public class ItemAppearanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemAppearanceTaskManager()
|
||||
protected ItemAppearanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemAppearanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemLifeTimeTaskManager
|
||||
public class ItemLifeTimeTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemLifeTimeTaskManager()
|
||||
protected ItemLifeTimeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemLifeTimeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,15 +27,19 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemManaTaskManager
|
||||
public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static final int MANA_CONSUMPTION_RATE = 60000;
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemManaTaskManager()
|
||||
protected ItemManaTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -55,7 +59,6 @@ public class ItemManaTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item)
|
||||
|
@@ -16,9 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -27,22 +26,17 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
public class ItemsAutoDestroyTaskManager
|
||||
public class ItemsAutoDestroyTaskManager implements Runnable
|
||||
{
|
||||
private final List<ItemInstance> _items = new LinkedList<>();
|
||||
private final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected ItemsAutoDestroyTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
|
||||
ThreadPool.scheduleAtFixedRate(this, 5000, 5000);
|
||||
}
|
||||
|
||||
public synchronized void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
private synchronized void removeItems()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
@@ -50,13 +44,11 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
|
||||
final long curtime = Chronos.currentTimeMillis();
|
||||
final Iterator<ItemInstance> itemIterator = _items.iterator();
|
||||
while (itemIterator.hasNext())
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
final ItemInstance item = itemIterator.next();
|
||||
if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
|
||||
{
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +69,7 @@ public class ItemsAutoDestroyTaskManager
|
||||
if ((curtime - item.getDropTime()) > autoDestroyTime)
|
||||
{
|
||||
item.decayMe();
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().removeObject(item);
|
||||
@@ -87,6 +79,12 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public static ItemsAutoDestroyTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -32,14 +32,18 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class MessageDeletionTaskManager
|
||||
public class MessageDeletionTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Integer, Long> PENDING_MESSAGES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public MessageDeletionTaskManager()
|
||||
protected MessageDeletionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -90,7 +94,6 @@ public class MessageDeletionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 10000, 10000);
|
||||
}
|
||||
|
||||
public void add(int msgId, long deletionTime)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
public class PlayerAutoSaveTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
protected PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class PlayerAutoSaveTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
public class PvpFlagTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
protected PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -62,7 +66,6 @@ public class PvpFlagTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -29,14 +29,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RandomAnimationTaskManager
|
||||
public class RandomAnimationTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RandomAnimationTaskManager()
|
||||
protected RandomAnimationTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class RandomAnimationTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RespawnTaskManager
|
||||
public class RespawnTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RespawnTaskManager()
|
||||
protected RespawnTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -60,7 +64,6 @@ public class RespawnTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc, long time)
|
||||
|
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
@@ -40,9 +40,16 @@ public class CreatureFollowTaskManager
|
||||
private static boolean _workingNormal = false;
|
||||
private static boolean _workingAttack = false;
|
||||
|
||||
public CreatureFollowTaskManager()
|
||||
protected CreatureFollowTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowNormalTask(), 1000, 1000);
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowAttackTask(), 500, 500);
|
||||
}
|
||||
|
||||
protected class CreatureFollowNormalTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingNormal)
|
||||
{
|
||||
@@ -56,9 +63,13 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingNormal = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class CreatureFollowAttackTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingAttack)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingAttack = false;
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void follow(Creature creature, int range)
|
||||
|
@@ -25,14 +25,18 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class CreatureSeeTaskManager
|
||||
public class CreatureSeeTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public CreatureSeeTaskManager()
|
||||
protected CreatureSeeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -46,7 +50,6 @@ public class CreatureSeeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Creature creature)
|
||||
|
@@ -30,14 +30,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DecayTaskManager
|
||||
public class DecayTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public DecayTaskManager()
|
||||
protected DecayTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -57,7 +61,6 @@ public class DecayTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemAppearanceTaskManager
|
||||
public class ItemAppearanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemAppearanceTaskManager()
|
||||
protected ItemAppearanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemAppearanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemLifeTimeTaskManager
|
||||
public class ItemLifeTimeTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemLifeTimeTaskManager()
|
||||
protected ItemLifeTimeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemLifeTimeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,15 +27,19 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemManaTaskManager
|
||||
public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static final int MANA_CONSUMPTION_RATE = 60000;
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemManaTaskManager()
|
||||
protected ItemManaTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -55,7 +59,6 @@ public class ItemManaTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item)
|
||||
|
@@ -16,9 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -27,22 +26,17 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
public class ItemsAutoDestroyTaskManager
|
||||
public class ItemsAutoDestroyTaskManager implements Runnable
|
||||
{
|
||||
private final List<ItemInstance> _items = new LinkedList<>();
|
||||
private final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected ItemsAutoDestroyTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
|
||||
ThreadPool.scheduleAtFixedRate(this, 5000, 5000);
|
||||
}
|
||||
|
||||
public synchronized void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
private synchronized void removeItems()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
@@ -50,13 +44,11 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
|
||||
final long curtime = Chronos.currentTimeMillis();
|
||||
final Iterator<ItemInstance> itemIterator = _items.iterator();
|
||||
while (itemIterator.hasNext())
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
final ItemInstance item = itemIterator.next();
|
||||
if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
|
||||
{
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +69,7 @@ public class ItemsAutoDestroyTaskManager
|
||||
if ((curtime - item.getDropTime()) > autoDestroyTime)
|
||||
{
|
||||
item.decayMe();
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().removeObject(item);
|
||||
@@ -87,6 +79,12 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public static ItemsAutoDestroyTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -32,14 +32,18 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class MessageDeletionTaskManager
|
||||
public class MessageDeletionTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Integer, Long> PENDING_MESSAGES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public MessageDeletionTaskManager()
|
||||
protected MessageDeletionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -90,7 +94,6 @@ public class MessageDeletionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 10000, 10000);
|
||||
}
|
||||
|
||||
public void add(int msgId, long deletionTime)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
public class PlayerAutoSaveTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
protected PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class PlayerAutoSaveTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
public class PvpFlagTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
protected PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -62,7 +66,6 @@ public class PvpFlagTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -29,14 +29,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RandomAnimationTaskManager
|
||||
public class RandomAnimationTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RandomAnimationTaskManager()
|
||||
protected RandomAnimationTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class RandomAnimationTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RespawnTaskManager
|
||||
public class RespawnTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RespawnTaskManager()
|
||||
protected RespawnTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -60,7 +64,6 @@ public class RespawnTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc, long time)
|
||||
|
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
@@ -40,9 +40,16 @@ public class CreatureFollowTaskManager
|
||||
private static boolean _workingNormal = false;
|
||||
private static boolean _workingAttack = false;
|
||||
|
||||
public CreatureFollowTaskManager()
|
||||
protected CreatureFollowTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowNormalTask(), 1000, 1000);
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowAttackTask(), 500, 500);
|
||||
}
|
||||
|
||||
protected class CreatureFollowNormalTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingNormal)
|
||||
{
|
||||
@@ -56,9 +63,13 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingNormal = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class CreatureFollowAttackTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingAttack)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingAttack = false;
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void follow(Creature creature, int range)
|
||||
|
@@ -25,14 +25,18 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class CreatureSeeTaskManager
|
||||
public class CreatureSeeTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public CreatureSeeTaskManager()
|
||||
protected CreatureSeeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -46,7 +50,6 @@ public class CreatureSeeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Creature creature)
|
||||
|
@@ -30,14 +30,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DecayTaskManager
|
||||
public class DecayTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public DecayTaskManager()
|
||||
protected DecayTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -57,7 +61,6 @@ public class DecayTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemAppearanceTaskManager
|
||||
public class ItemAppearanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemAppearanceTaskManager()
|
||||
protected ItemAppearanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemAppearanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemLifeTimeTaskManager
|
||||
public class ItemLifeTimeTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemLifeTimeTaskManager()
|
||||
protected ItemLifeTimeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemLifeTimeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,15 +27,19 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemManaTaskManager
|
||||
public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static final int MANA_CONSUMPTION_RATE = 60000;
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemManaTaskManager()
|
||||
protected ItemManaTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -55,7 +59,6 @@ public class ItemManaTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item)
|
||||
|
@@ -16,9 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -27,22 +26,17 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
public class ItemsAutoDestroyTaskManager
|
||||
public class ItemsAutoDestroyTaskManager implements Runnable
|
||||
{
|
||||
private final List<ItemInstance> _items = new LinkedList<>();
|
||||
private final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected ItemsAutoDestroyTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
|
||||
ThreadPool.scheduleAtFixedRate(this, 5000, 5000);
|
||||
}
|
||||
|
||||
public synchronized void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
private synchronized void removeItems()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
@@ -50,13 +44,11 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
|
||||
final long curtime = Chronos.currentTimeMillis();
|
||||
final Iterator<ItemInstance> itemIterator = _items.iterator();
|
||||
while (itemIterator.hasNext())
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
final ItemInstance item = itemIterator.next();
|
||||
if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
|
||||
{
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +69,7 @@ public class ItemsAutoDestroyTaskManager
|
||||
if ((curtime - item.getDropTime()) > autoDestroyTime)
|
||||
{
|
||||
item.decayMe();
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().removeObject(item);
|
||||
@@ -87,6 +79,12 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public static ItemsAutoDestroyTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -32,14 +32,18 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class MessageDeletionTaskManager
|
||||
public class MessageDeletionTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Integer, Long> PENDING_MESSAGES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public MessageDeletionTaskManager()
|
||||
protected MessageDeletionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -90,7 +94,6 @@ public class MessageDeletionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 10000, 10000);
|
||||
}
|
||||
|
||||
public void add(int msgId, long deletionTime)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
public class PlayerAutoSaveTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
protected PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class PlayerAutoSaveTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
public class PvpFlagTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
protected PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -62,7 +66,6 @@ public class PvpFlagTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -29,14 +29,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RandomAnimationTaskManager
|
||||
public class RandomAnimationTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RandomAnimationTaskManager()
|
||||
protected RandomAnimationTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class RandomAnimationTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RespawnTaskManager
|
||||
public class RespawnTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RespawnTaskManager()
|
||||
protected RespawnTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -60,7 +64,6 @@ public class RespawnTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc, long time)
|
||||
|
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
@@ -40,9 +40,16 @@ public class CreatureFollowTaskManager
|
||||
private static boolean _workingNormal = false;
|
||||
private static boolean _workingAttack = false;
|
||||
|
||||
public CreatureFollowTaskManager()
|
||||
protected CreatureFollowTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowNormalTask(), 1000, 1000);
|
||||
ThreadPool.scheduleAtFixedRate(new CreatureFollowAttackTask(), 500, 500);
|
||||
}
|
||||
|
||||
protected class CreatureFollowNormalTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingNormal)
|
||||
{
|
||||
@@ -56,9 +63,13 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingNormal = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class CreatureFollowAttackTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingAttack)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public class CreatureFollowTaskManager
|
||||
}
|
||||
|
||||
_workingAttack = false;
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void follow(Creature creature, int range)
|
||||
|
@@ -25,14 +25,18 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class CreatureSeeTaskManager
|
||||
public class CreatureSeeTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public CreatureSeeTaskManager()
|
||||
protected CreatureSeeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -46,7 +50,6 @@ public class CreatureSeeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Creature creature)
|
||||
|
@@ -30,14 +30,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DecayTaskManager
|
||||
public class DecayTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public DecayTaskManager()
|
||||
protected DecayTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -57,7 +61,6 @@ public class DecayTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemAppearanceTaskManager
|
||||
public class ItemAppearanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemAppearanceTaskManager()
|
||||
protected ItemAppearanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemAppearanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,14 +27,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemLifeTimeTaskManager
|
||||
public class ItemLifeTimeTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemLifeTimeTaskManager()
|
||||
protected ItemLifeTimeTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -54,7 +58,6 @@ public class ItemLifeTimeTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item, long endTime)
|
||||
|
@@ -27,15 +27,19 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ItemManaTaskManager
|
||||
public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<ItemInstance, Long> ITEMS = new ConcurrentHashMap<>();
|
||||
private static final int MANA_CONSUMPTION_RATE = 60000;
|
||||
private static boolean _working = false;
|
||||
|
||||
public ItemManaTaskManager()
|
||||
protected ItemManaTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -55,7 +59,6 @@ public class ItemManaTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(ItemInstance item)
|
||||
|
@@ -16,9 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -27,22 +26,17 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
public class ItemsAutoDestroyTaskManager
|
||||
public class ItemsAutoDestroyTaskManager implements Runnable
|
||||
{
|
||||
private final List<ItemInstance> _items = new LinkedList<>();
|
||||
private final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected ItemsAutoDestroyTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(this::removeItems, 5000, 5000);
|
||||
ThreadPool.scheduleAtFixedRate(this, 5000, 5000);
|
||||
}
|
||||
|
||||
public synchronized void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
private synchronized void removeItems()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
@@ -50,13 +44,11 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
|
||||
final long curtime = Chronos.currentTimeMillis();
|
||||
final Iterator<ItemInstance> itemIterator = _items.iterator();
|
||||
while (itemIterator.hasNext())
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
final ItemInstance item = itemIterator.next();
|
||||
if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
|
||||
{
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +69,7 @@ public class ItemsAutoDestroyTaskManager
|
||||
if ((curtime - item.getDropTime()) > autoDestroyTime)
|
||||
{
|
||||
item.decayMe();
|
||||
itemIterator.remove();
|
||||
_items.remove(item);
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().removeObject(item);
|
||||
@@ -87,6 +79,12 @@ public class ItemsAutoDestroyTaskManager
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ItemInstance item)
|
||||
{
|
||||
item.setDropTime(Chronos.currentTimeMillis());
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public static ItemsAutoDestroyTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -32,14 +32,18 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class MessageDeletionTaskManager
|
||||
public class MessageDeletionTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Integer, Long> PENDING_MESSAGES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public MessageDeletionTaskManager()
|
||||
protected MessageDeletionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 10000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -90,7 +94,6 @@ public class MessageDeletionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 10000, 10000);
|
||||
}
|
||||
|
||||
public void add(int msgId, long deletionTime)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
public class PlayerAutoSaveTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
protected PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class PlayerAutoSaveTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
public class PvpFlagTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
protected PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -62,7 +66,6 @@ public class PvpFlagTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -29,14 +29,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RandomAnimationTaskManager
|
||||
public class RandomAnimationTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RandomAnimationTaskManager()
|
||||
protected RandomAnimationTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -59,7 +63,6 @@ public class RandomAnimationTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RespawnTaskManager
|
||||
public class RespawnTaskManager implements Runnable
|
||||
{
|
||||
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public RespawnTaskManager()
|
||||
protected RespawnTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -60,7 +64,6 @@ public class RespawnTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(Npc npc, long time)
|
||||
|
@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AutoAttackStop;
|
||||
* Attack stance task manager.
|
||||
* @author Luca Baldi
|
||||
*/
|
||||
public class AttackStanceTaskManager
|
||||
public class AttackStanceTaskManager implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AttackStanceTaskManager.class.getName());
|
||||
|
||||
@@ -42,12 +42,13 @@ public class AttackStanceTaskManager
|
||||
private static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new attack stance task manager.
|
||||
*/
|
||||
protected AttackStanceTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -92,7 +93,6 @@ public class AttackStanceTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,14 +26,18 @@ import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AttackableThinkTaskManager
|
||||
public class AttackableThinkTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<Attackable> ATTACKABLES = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AttackableThinkTaskManager()
|
||||
protected AttackableThinkTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -63,7 +67,6 @@ public class AttackableThinkTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(Attackable attackable)
|
||||
|
@@ -28,14 +28,18 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author Mobius, Gigi
|
||||
*/
|
||||
public class AutoPotionTaskManager
|
||||
public class AutoPotionTaskManager implements Runnable
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public AutoPotionTaskManager()
|
||||
protected AutoPotionTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(this, 0, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
@@ -114,7 +118,6 @@ public class AutoPotionTaskManager
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
|
@@ -36,9 +36,16 @@ public class BuyListTaskManager
|
||||
private static boolean _workingProducts = false;
|
||||
private static boolean _workingSaves = false;
|
||||
|
||||
public BuyListTaskManager()
|
||||
protected BuyListTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListProductTask(), 1000, 60000);
|
||||
ThreadPool.scheduleAtFixedRate(new BuyListSaveTask(), 50, 50);
|
||||
}
|
||||
|
||||
protected class BuyListProductTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingProducts)
|
||||
{
|
||||
@@ -64,9 +71,13 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingProducts = false;
|
||||
}, 1000, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
protected class BuyListSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_workingSaves)
|
||||
{
|
||||
@@ -86,7 +97,7 @@ public class BuyListTaskManager
|
||||
}
|
||||
|
||||
_workingSaves = false;
|
||||
}, 50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Product product, long endTime)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user