From a7f1df1a38c026d35d46d32cc5c37c64293388a2 Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Tue, 29 Jan 2019 23:43:44 -0500 Subject: [PATCH] You can no longer move the spawn block with a piston. --- .../goodandevil/skyblock/listeners/Block.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/goodandevil/skyblock/listeners/Block.java b/src/main/java/me/goodandevil/skyblock/listeners/Block.java index a9c41993..e84591c4 100644 --- a/src/main/java/me/goodandevil/skyblock/listeners/Block.java +++ b/src/main/java/me/goodandevil/skyblock/listeners/Block.java @@ -198,10 +198,20 @@ public class Block implements Listener { Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld()); + Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + for (org.bukkit.block.Block block : event.getBlocks()) { if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 2.0D)) { event.setCancelled(true); + } else if (LocationUtil.isLocationLocation(block.getLocation(), + island.getLocation(world, IslandEnvironment.Main) + .clone() + .subtract(0.0D, 1.0D, 0.0D))) { + if (configLoad.getBoolean("Island.Spawn.Protection")) { + event.setCancelled(true); + } } } @@ -228,10 +238,20 @@ public class Block implements Listener { Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld()); + Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + for (org.bukkit.block.Block block : event.getBlocks()) { if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 2.0D)) { event.setCancelled(true); + } else if (LocationUtil.isLocationLocation(block.getLocation(), + island.getLocation(world, IslandEnvironment.Main) + .clone() + .subtract(0.0D, 1.0D, 0.0D))) { + if (configLoad.getBoolean("Island.Spawn.Protection")) { + event.setCancelled(true); + } } } @@ -253,7 +273,6 @@ public class Block implements Listener { org.bukkit.block.Block block = event.getBlock(); IslandManager islandManager = skyblock.getIslandManager(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); GeneratorManager generatorManager = skyblock.getGeneratorManager(); WorldManager worldManager = skyblock.getWorldManager();