forked from SteamWar/SteamWar
Fix IngameListener, OutsideWincondition, TowerGenerator
This commit is contained in:
@@ -159,8 +159,8 @@ public class TowerGenerator {
|
||||
noKeyFloors--;
|
||||
if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) {
|
||||
noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Container container = chestBlocks.get(random.nextInt(chestBlocks.size()));
|
||||
for (int i = 0; i < 2 && !chestBlocks.isEmpty(); i++) {
|
||||
Container container = chestBlocks.remove(random.nextInt(chestBlocks.size()));
|
||||
keys.add(container.getLocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ public class IngameListener extends GameStateBukkitListener {
|
||||
event.setCancelled(true);
|
||||
if (!event.hasBlock()) return;
|
||||
if (event.getClickedBlock().getType() != Material.IRON_DOOR) return;
|
||||
event.getPlayer().getInventory().setItemInMainHand(null);
|
||||
event.getPlayer().getInventory().remove(event.getItem());
|
||||
event.getClickedBlock().breakNaturally();
|
||||
}
|
||||
|
||||
@@ -223,6 +223,8 @@ public class IngameListener extends GameStateBukkitListener {
|
||||
shouldMelt(block.getRelative(0, 0, -1));
|
||||
}
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
private void shouldMelt(Block block) {
|
||||
if (block.getType().isBurnable()) return;
|
||||
if (block.getType().isAir()) return;
|
||||
@@ -269,7 +271,9 @@ public class IngameListener extends GameStateBukkitListener {
|
||||
break;
|
||||
}
|
||||
Pos pos = new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ());
|
||||
blocksToMelt.putIfAbsent(pos, time + meltingTime + 1);
|
||||
int delay = meltingTime + 1 + RANDOM.nextInt(30*20)-30*10;
|
||||
if (delay < 0) delay = meltingTime + 1;
|
||||
blocksToMelt.putIfAbsent(pos, time + delay);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -42,6 +42,10 @@ public abstract class OutsideWincondition extends WinCondition {
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.getTo().getY() > WorldConfig.ESCAPE_HEIGHT) {
|
||||
if (Arrays.stream(WorldConfig.REGIONS).noneMatch(region -> region.contains(event.getTo().toVector()))) {
|
||||
TowerRunPlayer tPlayer = TowerRunPlayer.get(event.getPlayer());
|
||||
tPlayer.player().damage(Integer.MAX_VALUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user