summaryrefslogtreecommitdiffstats
path: root/EssentialsAntiBuild/src
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-19 21:20:55 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-19 21:20:55 +0100
commitfa2a041102952ce16705c4ba235cea5c07595f6b (patch)
tree817fe80e3a385253958f2869af56f61fe67a0876 /EssentialsAntiBuild/src
parente359e8ab6e577d050631771fec0e9685ca70fd4c (diff)
downloadEssentials-fa2a041102952ce16705c4ba235cea5c07595f6b.tar
Essentials-fa2a041102952ce16705c4ba235cea5c07595f6b.tar.gz
Essentials-fa2a041102952ce16705c4ba235cea5c07595f6b.tar.lz
Essentials-fa2a041102952ce16705c4ba235cea5c07595f6b.tar.xz
Essentials-fa2a041102952ce16705c4ba235cea5c07595f6b.zip
Reduce permissions checks in antibuild.
Add a little debug logging for those with it enabled.
Diffstat (limited to 'EssentialsAntiBuild/src')
-rw-r--r--EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
index 8832ee630..9ce4f58f6 100644
--- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
+++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.antibuild;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
+import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.Event.Result;
@@ -33,26 +34,25 @@ public class EssentialsAntiBuildListener implements Listener
}
return metaPermCheck(user, action, block.getTypeId(), block.getData());
}
-
+
private boolean metaPermCheck(User user, String action, int blockId, byte data)
{
- String blockPerm = "essentials.build." + action + "." + blockId;
- String dataPerm = blockPerm + ":" + data;
+ final String blockPerm = "essentials.build." + action + "." + blockId;
+ final String dataPerm = blockPerm + ":" + data;
- if (user.isAuthorized(dataPerm))
+ if (user.isPermissionSet(dataPerm))
{
- return true;
+ return user.isAuthorized(dataPerm);
}
-
- if (user.isAuthorized(blockPerm))
+ else
{
- if (user.isPermissionSet(dataPerm) && !user.isAuthorized(dataPerm))
+ if (ess.getSettings().isDebug())
{
- return false;
+ ess.getLogger().log(Level.INFO, "abort checking if " + user.getName() + " has " + dataPerm + " - not directly set");
}
- return true;
}
- return false;
+
+ return user.isAuthorized(blockPerm);
}
@EventHandler(priority = EventPriority.HIGHEST)
@@ -68,6 +68,10 @@ public class EssentialsAntiBuildListener implements Listener
if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")
&& !metaPermCheck(user, "place", event.getBlock()))
{
+ if (ess.getSettings().warnOnBuildDisallow())
+ {
+ user.sendMessage(_("buildAlert"));
+ }
event.setCancelled(true);
return;
}
@@ -100,6 +104,10 @@ public class EssentialsAntiBuildListener implements Listener
if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")
&& !metaPermCheck(user, "break", event.getBlock()))
{
+ if (ess.getSettings().warnOnBuildDisallow())
+ {
+ user.sendMessage(_("buildAlert"));
+ }
event.setCancelled(true);
return;
}
@@ -190,7 +198,6 @@ public class EssentialsAntiBuildListener implements Listener
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.interact") && !user.isAuthorized("essentials.build"))
{
-
if (!metaPermCheck(user, "interact", event.getClickedBlock()))
{
event.setUseInteractedBlock(Result.DENY);
@@ -203,8 +210,6 @@ public class EssentialsAntiBuildListener implements Listener
{
event.setUseItemInHand(Result.DENY);
}
-
-
}
}
}