From dec162744cec6fcdc84acd9ed4eadf1edf23a931 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 23 Jun 2018 19:20:02 -0700 Subject: [PATCH] Code clean up --- .../listeners/flags/PlaceBlocksListener.java | 16 ++++++++-------- .../listeners/flags/RemoveMobsListener.java | 18 +++++++----------- .../us/tastybento/bskyblock/lists/Flags.java | 3 +++ .../bskyblock/util/DeleteIslandChunks.java | 2 -- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/main/java/us/tastybento/bskyblock/listeners/flags/PlaceBlocksListener.java b/src/main/java/us/tastybento/bskyblock/listeners/flags/PlaceBlocksListener.java index 743fa0f7e..ae2b8aa4a 100644 --- a/src/main/java/us/tastybento/bskyblock/listeners/flags/PlaceBlocksListener.java +++ b/src/main/java/us/tastybento/bskyblock/listeners/flags/PlaceBlocksListener.java @@ -65,14 +65,14 @@ public class PlaceBlocksListener extends AbstractFlagListener { return; default: // Check in-hand items - if (e.getMaterial() != null) { - // This check protects against an exploit in 1.7.9 against cactus - // and sugar cane and placing boats on non-liquids - if (e.getMaterial().equals(Material.END_CRYSTAL) || e.getMaterial() == Material.WOOD_DOOR || e.getMaterial() == Material.CHEST - || e.getMaterial() == Material.TRAPPED_CHEST || e.getMaterial() == Material.IRON_DOOR - || (e.getMaterial().name().contains("BOAT") && !e.getClickedBlock().isLiquid())) { - checkIsland(e, e.getPlayer().getLocation(), Flags.PLACE_BLOCKS); - } + // This check protects against an exploit in 1.7.9 against cactus + // and sugar cane and placing boats on non-liquids + if (e.getMaterial() != null + && (e.getMaterial().equals(Material.END_CRYSTAL) || e.getMaterial().equals(Material.WOOD_DOOR) + || e.getMaterial().equals(Material.CHEST) || e.getMaterial().equals(Material.TRAPPED_CHEST) + || e.getMaterial().equals(Material.IRON_DOOR) || (e.getMaterial().name().contains("BOAT") + && !e.getClickedBlock().isLiquid()))) { + checkIsland(e, e.getPlayer().getLocation(), Flags.PLACE_BLOCKS); } } } diff --git a/src/main/java/us/tastybento/bskyblock/listeners/flags/RemoveMobsListener.java b/src/main/java/us/tastybento/bskyblock/listeners/flags/RemoveMobsListener.java index 793c39be9..ba92ba5ce 100644 --- a/src/main/java/us/tastybento/bskyblock/listeners/flags/RemoveMobsListener.java +++ b/src/main/java/us/tastybento/bskyblock/listeners/flags/RemoveMobsListener.java @@ -23,17 +23,6 @@ import us.tastybento.bskyblock.lists.Flags; */ public class RemoveMobsListener extends AbstractFlagListener { - private static Set keepers; - - public RemoveMobsListener() { - keepers = new HashSet<>(); - keepers.add(EntityType.ZOMBIE_VILLAGER); - keepers.add(EntityType.PIG_ZOMBIE); - keepers.add(EntityType.WITHER); - keepers.add(EntityType.ENDERMAN); - keepers.add(EntityType.GHAST); - } - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onUserTeleport(PlayerTeleportEvent e) { // Only process if flag is active @@ -43,6 +32,13 @@ public class RemoveMobsListener extends AbstractFlagListener { } public static void clearArea(Location loc) { + Set keepers = new HashSet<>(); + keepers.add(EntityType.ZOMBIE_VILLAGER); + keepers.add(EntityType.PIG_ZOMBIE); + keepers.add(EntityType.WITHER); + keepers.add(EntityType.ENDERMAN); + keepers.add(EntityType.GHAST); + loc.getWorld().getNearbyEntities(loc, 5D, 5D, 5D).stream() .filter(en -> (en instanceof Monster)) .filter(en -> !keepers.contains(en.getType())) diff --git a/src/main/java/us/tastybento/bskyblock/lists/Flags.java b/src/main/java/us/tastybento/bskyblock/lists/Flags.java index 51e2ae7ca..a03cf8306 100644 --- a/src/main/java/us/tastybento/bskyblock/lists/Flags.java +++ b/src/main/java/us/tastybento/bskyblock/lists/Flags.java @@ -39,6 +39,9 @@ import us.tastybento.bskyblock.listeners.flags.clicklisteners.WorldToggleClickLi import us.tastybento.bskyblock.managers.RanksManager; public class Flags { + + private Flags() {} + // Disabled setting 'rank' private static final int DISABLED = -1; diff --git a/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java b/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java index 80ef547ec..ef99047b3 100644 --- a/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java +++ b/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java @@ -8,8 +8,6 @@ import us.tastybento.bskyblock.api.events.island.IslandEvent; import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason; import us.tastybento.bskyblock.database.objects.Island; -//import com.wasteofplastic.askyblock.nms.NMSAbstraction; - /** * Deletes islands fast using chunk regeneration *