// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com package engine.workthreads; import engine.Enum; import engine.InterestManagement.InterestManager; import engine.InterestManagement.WorldGrid; import engine.gameManager.*; import engine.math.Vector3fImmutable; import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; public class BoxFlagThread implements Runnable { public final static int THREAD_DELAY_SECONDS = 10; public BoxFlagThread() { } @Override public void run() { LocalDateTime nextPulse = LocalDateTime.now().minusMinutes(1); while(true){ if(LocalDateTime.now().isAfter(nextPulse)) { HashMap> PlayersByMachineID = new HashMap<>(); for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){ if(PlayersByMachineID.containsKey(pc.getClientConnection().machineID)){ if(PlayersByMachineID.get(pc.getClientConnection().machineID).contains(pc) == false) PlayersByMachineID.get(pc.getClientConnection().machineID).add(pc); }else{ ArrayList newList = new ArrayList<>(); newList.add(pc); PlayersByMachineID.put(pc.getClientConnection().machineID,newList); } } for(String key : PlayersByMachineID.keySet()){ ArrayList machinePlayers = PlayersByMachineID.get(key); if(machinePlayers.size() > 1){ int unboxedCount = 0; for(PlayerCharacter pc : machinePlayers){ if(!pc.isBoxed) unboxedCount++; } if(unboxedCount > 1){ for(PlayerCharacter pc : machinePlayers){ pc.isBoxed = true; } machinePlayers.get(0).isBoxed = false; } }else{ machinePlayers.get(0).isBoxed = false; } } nextPulse = nextPulse.plusSeconds(THREAD_DELAY_SECONDS); } } } public static void startBoxFlagThread() { Thread boxFlag; boxFlag = new Thread(new BoxFlagThread()); boxFlag.setName("boxFlagThread"); boxFlag.start(); } }