Files
prestonbane/src/engine/mobileAI/Threads/Respawner.java
T

52 lines
1.7 KiB
Java
Raw Normal View History

2023-10-23 00:32:59 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.mobileAI.Threads;
2024-03-24 09:42:27 -04:00
2023-10-23 00:32:59 -04:00
import engine.objects.Mob;
import org.pmw.tinylog.Logger;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
public enum Respawner implements Runnable {
2024-04-26 08:21:15 -04:00
// MB Dev Notes:
//
// Thread acts as a throttle for messages to the client. Mobiles are
// respawned over a short time so as not to flood the client when
// an entire camp respawns at once.
2023-10-23 00:39:12 -04:00
RESPAWNER;
2024-04-26 08:21:15 -04:00
2023-10-23 00:32:59 -04:00
public static BlockingQueue<Mob> respawnQueue = new DelayQueue();
@Override
public void run() {
while (true) {
try {
Mob mobile = respawnQueue.take();
mobile.respawn();
} catch (InterruptedException e) {
Logger.error(e.toString());
}
}
}
2023-10-23 00:39:12 -04:00
public static void start() {
2023-10-23 00:32:59 -04:00
Thread respawnThread;
2023-10-23 00:39:12 -04:00
respawnThread = new Thread(RESPAWNER);
2023-10-23 00:32:59 -04:00
respawnThread.setName("respawnThread");
respawnThread.start();
}
}