From a219a2d0722be4531fcc045dbfac603c780a5163 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 30 Oct 2016 14:22:02 -0400 Subject: [PATCH] Fix TNT breaking bedrock, increase build height and add a minimum chest place height --- .../clans/siege/weapon/projectile/Crater.java | 4 ++-- .../mineplex/game/clans/gameplay/Gameplay.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 0b78bfa26..0b1630995 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -54,7 +54,7 @@ public class Crater { noRepeats.add(locID); } - if (block.getType() == Material.AIR || block.isLiquid()) + if (block.getType() == Material.AIR || block.isLiquid() || block.getType() == Material.BEDROCK) { continue; } @@ -81,7 +81,7 @@ public class Crater UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _origin, null, 0, 1, ViewDist.NORMAL); for (Block block : event.getBlocks()) { - if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.BED_BLOCK) { block.breakNaturally(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 2c7a971f1..cafa0fe65 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -80,6 +80,8 @@ import org.bukkit.plugin.java.JavaPlugin; public class Gameplay extends MiniPlugin { + private static final int MAX_BUILD_HEIGHT = 120; + private static final int MIN_CHEST_HEIGHT = 30; private ClansManager _clansManager; private BlockRestore _blockRestore; private DamageManager _damageManager; @@ -230,19 +232,27 @@ public class Gameplay extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void MaxHeight(BlockPlaceEvent event) { - if (event.getBlock().getLocation().getBlockY() > 100) + if (event.getBlock().getLocation().getBlockY() > MAX_BUILD_HEIGHT) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high.")); event.setCancelled(true); - } else if(event.getBlock().getLocation().getBlockY() == 99 && event.getBlock().getType().name().contains("DOOR") && !event.getBlock().getType().equals(Material.TRAP_DOOR)) { + } + else if(event.getBlock().getLocation().getBlockY() == (MAX_BUILD_HEIGHT - 1) && event.getBlock().getType().name().contains("DOOR") && event.getBlock().getType() != Material.TRAP_DOOR && event.getBlock().getType() != Material.IRON_TRAPDOOR) + { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high.")); event.setCancelled(true); } + + if (event.getBlock().getLocation().getBlockY() < MIN_CHEST_HEIGHT && (event.getBlock().getType() == Material.CHEST || event.getBlock().getType() == Material.TRAPPED_CHEST)) + { + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) - public void GrowTree(StructureGrowEvent event) { - event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > 100).forEach(blockState -> blockState.setType(Material.AIR) ); + public void GrowTree(StructureGrowEvent event) + { + event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > MAX_BUILD_HEIGHT).forEach(blockState -> blockState.setType(Material.AIR) ); } /**