Files
prestonbane/src/engine/workthreads/UpdateThread.java
T

60 lines
2.0 KiB
Java
Raw Normal View History

2025-01-01 10:31:46 -06:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.workthreads;
import engine.Enum;
import engine.gameManager.SessionManager;
import engine.gameManager.SimulationManager;
import engine.objects.Bane;
import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger;
public class UpdateThread implements Runnable {
public Long lastRun;
public static int instancedelay = 1000;
public UpdateThread() {
Logger.info(" UpdateThread thread has started!");
}
public void processPlayerUpdate() {
try {
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
2025-01-12 00:13:21 -06:00
//player.update(true);
2025-01-12 16:18:47 -06:00
player.doRegen();
2025-01-01 10:31:46 -06:00
}
} catch (Exception e) {
Logger.error("UPDATE ERROR");
}
}
public void run() {
lastRun = System.currentTimeMillis();
while (true) {
if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
this.processPlayerUpdate();
lastRun = System.currentTimeMillis(); // Update lastRun after processing
}
}
}
public static void startUpdateThread() {
Thread updateThread;
updateThread = new Thread(new UpdateThread());
updateThread.setName("updateThread");
updateThread.start();
}
}