respawn while loop addition

This commit is contained in:
2023-08-01 19:50:52 -05:00
parent 370efe1092
commit 5e0b4ad763
2 changed files with 14 additions and 10 deletions
+2
View File
@@ -604,8 +604,10 @@ public class MobileFSM {
} }
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
//aiAgent.respawn(); //aiAgent.respawn();
if(aiAgent.getParentZone().respawnQue.contains(aiAgent) == false) {
aiAgent.getParentZone().respawnQue.add(aiAgent); aiAgent.getParentZone().respawnQue.add(aiAgent);
} }
}
} catch(Exception e){ } catch(Exception e){
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage());
} }
+4 -2
View File
@@ -26,6 +26,7 @@ import engine.objects.Zone;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.LongAdder;
/** /**
* Thread blocks until MagicBane dispatch messages are * Thread blocks until MagicBane dispatch messages are
@@ -41,17 +42,17 @@ public class MobRespawnThread implements Runnable {
// Instance variables // Instance variables
// Thread constructor // Thread constructor
public MobRespawnThread() { public MobRespawnThread() {
Boolean isAlive = false;
Logger.info(" MobRespawnThread thread has started!"); Logger.info(" MobRespawnThread thread has started!");
} }
@Override @Override
public void run() { public void run() {
while(true) {
for (Zone zone : ZoneManager.getAllZones()) { for (Zone zone : ZoneManager.getAllZones()) {
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
if (zone.respawnQue.iterator().next() != null) { if (zone.respawnQue.iterator().next() != null) {
@@ -63,6 +64,7 @@ public class MobRespawnThread implements Runnable {
} }
} }
} }
}
public static void startRespawnThread() { public static void startRespawnThread() {
Thread respawnThread; Thread respawnThread;