Changes names of some variables and one method to increase readability

This commit is contained in:
Kristian Knarvik 2021-02-22 20:36:37 +01:00
parent e5fef0b16a
commit 151c242e69
3 changed files with 27 additions and 22 deletions

View File

@ -60,7 +60,7 @@ public class BloxPopulator {
*
* @return <p>The material used for population</p>
*/
public Material getMat() {
public Material getMaterial() {
return nextMat;
}

View File

@ -12,20 +12,22 @@ 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) {
BloxPopulator bloxPopulator = Stargate.blockPopulatorQueue.poll();
if (bloxPopulator == null) {
return;
}
Block block = bloxPopulator.getBlockLocation().getBlock();
block.setType(bloxPopulator.getMaterial(), false);
if (bloxPopulator.getMaterial() == Material.END_GATEWAY && block.getWorld().getEnvironment() == World.Environment.THE_END) {
// force a location to prevent exit gateway generation
EndGateway gateway = (EndGateway) blk.getState();
gateway.setExitLocation(blk.getWorld().getSpawnLocation());
EndGateway gateway = (EndGateway) block.getState();
gateway.setExitLocation(block.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);
} else if (bloxPopulator.getAxis() != null) {
Orientable orientable = (Orientable) block.getBlockData();
orientable.setAxis(bloxPopulator.getAxis());
block.setBlockData(orientable);
}
}
}

View File

@ -14,21 +14,24 @@ public class StarGateThread implements Runnable {
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);
Portal portal = iterator.next();
// Skip always open and non-open gates
if (portal.isAlwaysOn() || !portal.isOpen()) {
continue;
}
if (time > portal.getOpenTime() + Stargate.getOpenTime()) {
portal.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();
Portal portal = iterator.next();
if (!portal.isActive()) {
continue;
}
if (time > portal.getOpenTime() + Stargate.getActiveTime()) {
portal.deactivate();
iterator.remove();
}
}