Remove meta/durability checks from AntiBuild

This commit is contained in:
md678685 2018-11-19 11:38:50 +00:00
parent 982b358bf8
commit 8cc448efcf

View File

@ -40,7 +40,7 @@ public class EssentialsAntiBuildListener implements Listener {
}
return false;
}
return metaPermCheck(user, action, block.getType(), block.getData());
return metaPermCheck(user, action, block.getType());
}
private boolean metaPermCheck(final User user, final String action, final Material material) {
@ -48,21 +48,6 @@ public class EssentialsAntiBuildListener implements Listener {
return user.isAuthorized(blockPerm);
}
private boolean metaPermCheck(final User user, final String action, final Material material, final short data) {
final String blockPerm = "essentials.build." + action + "." + material;
final String dataPerm = blockPerm + ":" + data;
if (user.getBase().isPermissionSet(dataPerm)) {
return user.isAuthorized(dataPerm);
} else {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "DataValue perm on " + user.getName() + " is not directly set: " + dataPerm);
}
}
return user.isAuthorized(blockPerm);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event) {
final User user = ess.getUser(event.getPlayer());
@ -180,7 +165,7 @@ public class EssentialsAntiBuildListener implements Listener {
}
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
if (event.hasItem() && !metaPermCheck(user, "interact", item.getType(), item.getDurability())) {
if (event.hasItem() && !metaPermCheck(user, "interact", item.getType())) {
event.setCancelled(true);
if (ess.getSettings().warnOnBuildDisallow()) {
user.sendMessage(tl("antiBuildUse", item.getType().toString()));
@ -205,7 +190,7 @@ public class EssentialsAntiBuildListener implements Listener {
final ItemStack item = event.getRecipe().getResult();
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
if (!metaPermCheck(user, "craft", item.getType(), item.getDurability())) {
if (!metaPermCheck(user, "craft", item.getType())) {
event.setCancelled(true);
if (ess.getSettings().warnOnBuildDisallow()) {
user.sendMessage(tl("antiBuildCraft", item.getType().toString()));
@ -222,7 +207,7 @@ public class EssentialsAntiBuildListener implements Listener {
final ItemStack item = event.getItem().getItemStack();
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
if (!metaPermCheck(user, "pickup", item.getType(), item.getDurability())) {
if (!metaPermCheck(user, "pickup", item.getType())) {
event.setCancelled(true);
event.getItem().setPickupDelay(50);
}
@ -236,7 +221,7 @@ public class EssentialsAntiBuildListener implements Listener {
final ItemStack item = event.getItemDrop().getItemStack();
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
if (!metaPermCheck(user, "drop", item.getType(), item.getDurability())) {
if (!metaPermCheck(user, "drop", item.getType())) {
event.setCancelled(true);
user.getBase().updateInventory();
if (ess.getSettings().warnOnBuildDisallow()) {