Skip task manager tasks when working.

This commit is contained in:
MobiusDevelopment
2020-03-30 17:21:37 +00:00
parent c9601fac2a
commit 7cd9f35b43
71 changed files with 507 additions and 24 deletions

View File

@ -38,7 +38,7 @@ public class AttackStanceTaskManager
protected static final Map<Creature, Long> _attackStanceTasks = new ConcurrentHashMap<>();
public static final long COMBAT_TIME = 15_000;
public static final long COMBAT_TIME = 15000;
/**
* Instantiates a new attack stance task manager.

View File

@ -32,11 +32,18 @@ import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
public class DecayTaskManager
{
private static final Map<Creature, Long> DECAY_SCHEDULES = new ConcurrentHashMap<>();
private static boolean _working = false;
public DecayTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
final long time = System.currentTimeMillis();
for (Entry<Creature, Long> entry : DECAY_SCHEDULES.entrySet())
{
@ -47,6 +54,8 @@ public class DecayTaskManager
creature.onDecay();
}
}
_working = false;
}, 0, 1000);
}

View File

@ -31,11 +31,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
public class RandomAnimationTaskManager
{
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
private static boolean _working = false;
public RandomAnimationTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
final long time = System.currentTimeMillis();
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
{
@ -49,6 +56,8 @@ public class RandomAnimationTaskManager
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
}
}
_working = false;
}, 0, 1000);
}

View File

@ -30,11 +30,18 @@ import org.l2jmobius.gameserver.model.actor.Npc;
public class RespawnTaskManager
{
private static final Map<Npc, Long> PENDING_RESPAWNS = new ConcurrentHashMap<>();
private static boolean _working = false;
public RespawnTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
final long time = System.currentTimeMillis();
for (Entry<Npc, Long> entry : PENDING_RESPAWNS.entrySet())
{
@ -50,6 +57,8 @@ public class RespawnTaskManager
}
}
}
_working = false;
}, 0, 1000);
}