Moves a bunch of inner classes to their own files
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
package net.knarcraft.stargate.thread;
|
||||
|
||||
import net.knarcraft.stargate.BloxPopulator;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.EndGateway;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
public class BlockPopulatorThread implements Runnable {
|
||||
public void run() {
|
||||
long sTime = System.nanoTime();
|
||||
while (System.nanoTime() - sTime < 25000000) {
|
||||
BloxPopulator b = Stargate.blockPopulatorQueue.poll();
|
||||
if (b == null) return;
|
||||
Block blk = b.getBlockLocation().getBlock();
|
||||
blk.setType(b.getMat(), false);
|
||||
if (b.getMat() == Material.END_GATEWAY && blk.getWorld().getEnvironment() == World.Environment.THE_END) {
|
||||
// force a location to prevent exit gateway generation
|
||||
EndGateway gateway = (EndGateway) blk.getState();
|
||||
gateway.setExitLocation(blk.getWorld().getSpawnLocation());
|
||||
gateway.setExactTeleport(true);
|
||||
gateway.update(false, false);
|
||||
} else if (b.getAxis() != null) {
|
||||
Orientable orientable = (Orientable) blk.getBlockData();
|
||||
orientable.setAxis(b.getAxis());
|
||||
blk.setBlockData(orientable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.knarcraft.stargate.thread;
|
||||
|
||||
import net.knarcraft.stargate.Portal;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* This class contains the function used to close servers which should no longer be open/active
|
||||
*/
|
||||
public class StarGateThread implements Runnable {
|
||||
|
||||
public void run() {
|
||||
long time = System.currentTimeMillis() / 1000;
|
||||
// Close open portals
|
||||
for (Iterator<Portal> iterator = Stargate.openList.iterator(); iterator.hasNext(); ) {
|
||||
Portal p = iterator.next();
|
||||
// Skip always open gates
|
||||
if (p.isAlwaysOn()) continue;
|
||||
if (!p.isOpen()) continue;
|
||||
if (time > p.getOpenTime() + Stargate.getOpenTime()) {
|
||||
p.close(false);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
// Deactivate active portals
|
||||
for (Iterator<Portal> iterator = Stargate.activeList.iterator(); iterator.hasNext(); ) {
|
||||
Portal p = iterator.next();
|
||||
if (!p.isActive()) continue;
|
||||
if (time > p.getOpenTime() + Stargate.getActiveTime()) {
|
||||
p.deactivate();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user