box flag checker

This commit is contained in:
2024-05-28 21:30:54 -05:00
parent 6313182c4f
commit 3815f9df8e
+5 -4
View File
@@ -21,22 +21,23 @@ import engine.objects.*;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
public class BoxFlagThread implements Runnable { public class BoxFlagThread implements Runnable {
public final static int THREAD_DELAY = 5000; public final static int THREAD_DELAY_SECONDS = 10;
public BoxFlagThread() { public BoxFlagThread() {
} }
@Override @Override
public void run() { public void run() {
long nextPulse = System.currentTimeMillis(); LocalDateTime nextPulse = LocalDateTime.now();
while(true){ while(true){
if(System.currentTimeMillis() > nextPulse) { if(LocalDateTime.now().isAfter(nextPulse)) {
for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){ for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){
if(pc.isEnteredWorld() && pc.isActive()){ if(pc.isEnteredWorld() && pc.isActive()){
@@ -58,7 +59,7 @@ public class BoxFlagThread implements Runnable {
} }
} }
} }
nextPulse += THREAD_DELAY; nextPulse = nextPulse.plusSeconds(THREAD_DELAY_SECONDS);
} }
} }
} }