From 9a9f95eec23746f8316e9245b2c4e6f1c7595593 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 9 Aug 2016 15:00:26 +0200 Subject: [PATCH] Added extra class for BlockExplodeEvent BlockExplodeEvent class is not found in v1.8_R1, and if a class is not found in a listener, the whole listener with all its event won't get registered. --- .../java/de/epiceric/shopchest/ShopChest.java | 4 +++ .../listeners/BlockExplodeListener.java | 32 +++++++++++++++++++ .../listeners/ChestProtectListener.java | 12 ------- 3 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 src/main/java/de/epiceric/shopchest/listeners/BlockExplodeListener.java diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java index 073e1b9..1a09ef7 100644 --- a/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -285,6 +285,10 @@ public class ShopChest extends JavaPlugin { getServer().getPluginManager().registerEvents(new ShopInteractListener(this), this); getServer().getPluginManager().registerEvents(new NotifyUpdateOnJoinListener(this), this); getServer().getPluginManager().registerEvents(new ChestProtectListener(this), this); + + if (!Utils.getServerVersion().equals("v1_8_R1")) + getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this); + } @Override diff --git a/src/main/java/de/epiceric/shopchest/listeners/BlockExplodeListener.java b/src/main/java/de/epiceric/shopchest/listeners/BlockExplodeListener.java new file mode 100644 index 0000000..7f60e3d --- /dev/null +++ b/src/main/java/de/epiceric/shopchest/listeners/BlockExplodeListener.java @@ -0,0 +1,32 @@ +package de.epiceric.shopchest.listeners; + +import de.epiceric.shopchest.ShopChest; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockExplodeEvent; + +import java.util.ArrayList; + +public class BlockExplodeListener implements Listener { + + private ShopChest plugin; + + public BlockExplodeListener(ShopChest plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onBlockExplode(BlockExplodeEvent e) { + if (plugin.getShopChestConfig().explosion_protection) { + ArrayList bl = new ArrayList<>(e.blockList()); + for (Block b : bl) { + if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) { + if (plugin.getShopUtils().isShop(b.getLocation())) e.blockList().remove(b); + } + } + } + } + +} diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java index 47e5242..bae382f 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java @@ -41,18 +41,6 @@ public class ChestProtectListener implements Listener { } } - @EventHandler - public void onBlockExplode(BlockExplodeEvent e) { - if (plugin.getShopChestConfig().explosion_protection) { - ArrayList bl = new ArrayList<>(e.blockList()); - for (Block b : bl) { - if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) { - if (shopUtils.isShop(b.getLocation())) e.blockList().remove(b); - } - } - } - } - @EventHandler public void onEntityExplode(EntityExplodeEvent e) { if (plugin.getShopChestConfig().explosion_protection) {