Only check main hand

Former-commit-id: e4e438c84b8782ebcf5ac4734f96a8974dd23ebe [formerly f745ee67532661d0ecd07a856481fb9e862eb941]
Former-commit-id: ec36ecec252cddc5d8575732187461cb51318827
This commit is contained in:
Ghost_chu committed 2019-06-02 21:47:11 +08:00
1 parent 46e90c008a
commit 6a1f90b73d
1 file changed
-11
@@ -32,32 +32,21 @@ public class PermissionChecker {
if (!usePermissionChecker)
return true;
BlockEvent beMainHand;
BlockEvent beOffHand;
if (place) {
beMainHand = new BlockPlaceEvent(block, block.getState(), block.getRelative(0, -1, 0), player.getInventory()
.getItemInMainHand(), player, true, EquipmentSlot.HAND);
beOffHand = new BlockPlaceEvent(block, block.getState(), block.getRelative(0, -1, 0), player.getInventory()
.getItemInOffHand(), player, true, EquipmentSlot.OFF_HAND);
} else {
beMainHand = new BlockBreakEvent(block, player);
beOffHand = new BlockBreakEvent(block, player);
}
Bukkit.getPluginManager().callEvent(beMainHand);
Bukkit.getPluginManager().callEvent(beOffHand);
if (((Cancellable) beMainHand).isCancelled())
return false;
if (((Cancellable) beOffHand).isCancelled())
return false;
if (beMainHand instanceof BlockPlaceEvent)
if (!((BlockPlaceEvent) beMainHand).canBuild())
return false;
if (beOffHand instanceof BlockPlaceEvent)
if (!((BlockPlaceEvent) beOffHand).canBuild())
return false;
return true;
}