From 5e0b4ad763f5f264f054ac2ff3d1a73ad43ecd22 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 19:50:52 -0500 Subject: [PATCH] respawn while loop addition --- src/engine/ai/MobileFSM.java | 4 +++- src/engine/workthreads/MobRespawnThread.java | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index a1529795..9649a730 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -604,7 +604,9 @@ public class MobileFSM { } } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { //aiAgent.respawn(); - aiAgent.getParentZone().respawnQue.add(aiAgent); + if(aiAgent.getParentZone().respawnQue.contains(aiAgent) == false) { + aiAgent.getParentZone().respawnQue.add(aiAgent); + } } } catch(Exception e){ Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); diff --git a/src/engine/workthreads/MobRespawnThread.java b/src/engine/workthreads/MobRespawnThread.java index 1d2bb4f5..61f009c1 100644 --- a/src/engine/workthreads/MobRespawnThread.java +++ b/src/engine/workthreads/MobRespawnThread.java @@ -26,6 +26,7 @@ import engine.objects.Zone; import org.pmw.tinylog.Logger; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.LongAdder; /** * Thread blocks until MagicBane dispatch messages are @@ -41,24 +42,25 @@ public class MobRespawnThread implements Runnable { // Instance variables - // Thread constructor public MobRespawnThread() { - + Boolean isAlive = false; Logger.info(" MobRespawnThread thread has started!"); } @Override public void run() { - for (Zone zone : ZoneManager.getAllZones()) { - if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { - if (zone.respawnQue.iterator().next() != null) { - Mob respawner = zone.respawnQue.iterator().next(); - respawner.respawn(); - zone.respawnQue.remove(respawner); - zone.lastRespawn = System.currentTimeMillis(); + while(true) { + for (Zone zone : ZoneManager.getAllZones()) { + if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { + if (zone.respawnQue.iterator().next() != null) { + Mob respawner = zone.respawnQue.iterator().next(); + respawner.respawn(); + zone.respawnQue.remove(respawner); + zone.lastRespawn = System.currentTimeMillis(); + } } } }