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.
This commit is contained in:
Eric 2016-08-09 15:00:26 +02:00
parent c713d0f014
commit 9a9f95eec2
3 changed files with 36 additions and 12 deletions

View File

@ -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

View File

@ -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<Block> 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);
}
}
}
}
}

View File

@ -41,18 +41,6 @@ public class ChestProtectListener implements Listener {
}
}
@EventHandler
public void onBlockExplode(BlockExplodeEvent e) {
if (plugin.getShopChestConfig().explosion_protection) {
ArrayList<Block> 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) {