forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
3.0 KiB
68 lines
3.0 KiB
1 year ago
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||
|
// Magicbane Emulator Project © 2013 - 2022
|
||
|
// www.magicbane.com
|
||
|
|
||
|
|
||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||
|
// Magicbane Emulator Project © 2013 - 2022
|
||
|
// www.magicbane.com
|
||
|
|
||
|
|
||
1 year ago
|
package engine.mobileAI.Threads;
|
||
1 year ago
|
import engine.gameManager.ZoneManager;
|
||
|
import engine.objects.Mob;
|
||
|
import engine.objects.Zone;
|
||
|
import org.pmw.tinylog.Logger;
|
||
|
|
||
|
/**
|
||
|
* Thread blocks until MagicBane dispatch messages are
|
||
|
* enqueued then processes them in FIFO order. The collection
|
||
|
* is thread safe.
|
||
|
* <p>
|
||
|
* Any large messages not time sensitive such as load object
|
||
|
* sent to more than a single individual should be spawned
|
||
|
* individually on a DispatchMessageThread.
|
||
|
*/
|
||
|
|
||
|
public class MobRespawnThread implements Runnable {
|
||
|
|
||
|
// Instance variables
|
||
|
|
||
|
// Thread constructor
|
||
|
|
||
|
public MobRespawnThread() {
|
||
|
Logger.info(" MobRespawnThread thread has started!");
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void run() {
|
||
1 year ago
|
while(true) {
|
||
|
for (Zone zone : ZoneManager.getAllZones()) {
|
||
|
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
|
||
|
if (zone.respawnQue.iterator().next() != null) {
|
||
|
Mob respawner = zone.respawnQue.iterator().next();
|
||
|
respawner.respawn();
|
||
|
zone.respawnQue.remove(respawner);
|
||
|
zone.lastRespawn = System.currentTimeMillis();
|
||
|
}
|
||
1 year ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public static void startRespawnThread() {
|
||
|
Thread respawnThread;
|
||
1 year ago
|
respawnThread = new Thread(new MobRespawnThread());
|
||
1 year ago
|
respawnThread.setName("respawnThread");
|
||
|
respawnThread.start();
|
||
|
}
|
||
|
}
|