Fixed Custom Mining priorities.

This commit is contained in:
Aria 2019-09-27 23:00:28 +02:00
parent 783782f44f
commit 5c608b8439

View File

@ -37,7 +37,22 @@ public class BlockListener implements Listener {
*/
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player);
ItemStack item = player.getInventory().getItemInMainHand();
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block.getType());
if (info == null)
return;
if (customMine) {
/*
* calls the event and listen for cancel & for drops changes... also
* allows to apply tool durability & enchants to drops, etc.
*/
CustomBlockMineEvent called = new CustomBlockMineEvent(PlayerData.get(player), block, info);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled()) {
event.setCancelled(true);
return;
}
BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item.getType());
if (perms == null) {
@ -50,22 +65,7 @@ public class BlockListener implements Listener {
event.setCancelled(true);
return;
}
}
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block.getType());
if (info == null)
return;
/*
* calls the event and listen for cancel & for drops changes... also
* allows to apply tool durability & enchants to drops, etc.
*/
CustomBlockMineEvent called = new CustomBlockMineEvent(PlayerData.get(player), block, info);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled()) {
event.setCancelled(true);
return;
}
/*
* remove vanilla drops if needed
@ -98,6 +98,7 @@ public class BlockListener implements Listener {
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
block.getWorld().dropItemNaturally(dropLocation, drop);
}
}
/*
* enable block regen only if custom mine is enabled.