diff options
Diffstat (limited to 'EssentialsAntiBuild/src/net/ess3')
5 files changed, 72 insertions, 84 deletions
diff --git a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuild.java b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuild.java index 0869d706e..11320c6a0 100644 --- a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuild.java +++ b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuild.java @@ -31,8 +31,8 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild public EssentialsConnect getEssentialsConnect() { return ess; - } - + } + @Override public AntiBuildHolder getSettings() { diff --git a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java index 2e0aba9a4..4334d6697 100644 --- a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java +++ b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java @@ -1,8 +1,6 @@ package net.ess3.antibuild; import static net.ess3.I18n._; -import net.ess3.api.IEssentials; -import net.ess3.api.IUser; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -11,13 +9,18 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.*; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.painting.PaintingBreakByEntityEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; +import net.ess3.api.IEssentials; +import net.ess3.api.IUser; public class EssentialsAntiBuildListener implements Listener @@ -33,39 +36,36 @@ public class EssentialsAntiBuildListener implements Listener @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPlace(final BlockPlaceEvent event) - { + { final Player user = event.getPlayer(); final Block block = event.getBlockPlaced(); final int typeId = block.getTypeId(); final Material type = block.getType(); - if (antib.getSettings().getData().isDisableBuild() - && !Permissions.BUILD.isAuthorized(user) - && !Permissions.PLACEMENT.isAuthorized(user, block)) + if (antib.getSettings().getData().isDisableBuild() && !Permissions.BUILD.isAuthorized(user) && !Permissions.PLACEMENT.isAuthorized(user, block)) + { + if (antib.getSettings().getData().isWarnOnBuildDisallow()) { - if (antib.getSettings().getData().isWarnOnBuildDisallow()) - { - user.sendMessage(_("antiBuildPlace", type.toString())); - } - event.setCancelled(true); - return; + user.sendMessage(_("antiBuildPlace", type.toString())); } + event.setCancelled(true); + return; + } - if (antib.getSettings().getData().getBlacklist().getPlacement(type) && !Permissions.BLACKLIST_ALLOWPLACEMENT.isAuthorized(user)) + if (antib.getSettings().getData().getBlacklist().getPlacement(type) && !Permissions.BLACKLIST_ALLOWPLACEMENT.isAuthorized(user)) + { + if (antib.getSettings().getData().isWarnOnBuildDisallow()) { - if (antib.getSettings().getData().isWarnOnBuildDisallow()) - { - user.sendMessage(_("antiBuildPlace", type.toString())); - } - event.setCancelled(true); - return; + user.sendMessage(_("antiBuildPlace", type.toString())); } + event.setCancelled(true); + return; + } - if (antib.getSettings().getData().getAlert().getAlertOnPlacementContains(type) - && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) - { - antib.getEssentialsConnect().alert(user, type.toString(), _("alertPlaced")); - } + if (antib.getSettings().getData().getAlert().getAlertOnPlacementContains(type) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) + { + antib.getEssentialsConnect().alert(user, type.toString(), _("alertPlaced")); + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -75,36 +75,33 @@ public class EssentialsAntiBuildListener implements Listener final Block block = event.getBlock(); final int typeId = block.getTypeId(); final Material type = block.getType(); - - if (antib.getSettings().getData().isDisableBuild() - && !Permissions.BUILD.isAuthorized(user) - && !Permissions.BREAK.isAuthorized(user, block)) - { - if (antib.getSettings().getData().isWarnOnBuildDisallow()) - { - user.sendMessage(_("antiBuildBreak", type.toString())); - } - event.setCancelled(true); - return; - } - if (antib.getSettings().getData().getBlacklist().getBreaking(type) && !Permissions.BLACKLIST_ALLOWBREAK.isAuthorized(user)) + if (antib.getSettings().getData().isDisableBuild() && !Permissions.BUILD.isAuthorized(user) && !Permissions.BREAK.isAuthorized(user, block)) + { + if (antib.getSettings().getData().isWarnOnBuildDisallow()) { - if (antib.getSettings().getData().isWarnOnBuildDisallow()) - { - user.sendMessage(_("antiBuildBreak", type.toString())); - } - event.setCancelled(true); - return; + user.sendMessage(_("antiBuildBreak", type.toString())); } + event.setCancelled(true); + return; + } - if (antib.getSettings().getData().getAlert().getAlertOnBreakContains(type) - && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) + if (antib.getSettings().getData().getBlacklist().getBreaking(type) && !Permissions.BLACKLIST_ALLOWBREAK.isAuthorized(user)) + { + if (antib.getSettings().getData().isWarnOnBuildDisallow()) { - antib.getEssentialsConnect().alert(user, type.toString(), _("alertBroke")); + user.sendMessage(_("antiBuildBreak", type.toString())); } + event.setCancelled(true); + return; + } + + if (antib.getSettings().getData().getAlert().getAlertOnBreakContains(type) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) + { + antib.getEssentialsConnect().alert(user, type.toString(), _("alertBroke")); + } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPaintingBreak(final PaintingBreakByEntityEvent event) { @@ -112,9 +109,8 @@ public class EssentialsAntiBuildListener implements Listener if (entity instanceof Player) { final IUser user = ess.getUserMap().getUser((Player)entity); - if (antib.getSettings().getData().isDisableBuild() - && !Permissions.BUILD.isAuthorized(user) - && !Permissions.BREAK.isAuthorized(user, Material.PAINTING, null)) + if (antib.getSettings().getData().isDisableBuild() && !Permissions.BUILD.isAuthorized(user) && !Permissions.BREAK.isAuthorized( + user, Material.PAINTING, null)) { if (antib.getSettings().getData().isWarnOnBuildDisallow()) { @@ -159,9 +155,7 @@ public class EssentialsAntiBuildListener implements Listener final Player user = event.getPlayer(); final ItemStack item = event.getItem(); - if (item != null - && antib.getSettings().getData().getBlacklist().getUsage(item.getType()) - && !Permissions.BLACKLIST_ALLOWUSAGE.isAuthorized(user)) + if (item != null && antib.getSettings().getData().getBlacklist().getUsage(item.getType()) && !Permissions.BLACKLIST_ALLOWUSAGE.isAuthorized(user)) { if (antib.getSettings().getData().isWarnOnBuildDisallow()) { @@ -171,15 +165,12 @@ public class EssentialsAntiBuildListener implements Listener return; } - if (item != null - && antib.getSettings().getData().getAlert().getAlertOnUseContains(item.getType()) - && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) + if (item != null && antib.getSettings().getData().getAlert().getAlertOnUseContains(item.getType()) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) { antib.getEssentialsConnect().alert(user, item.getType().toString(), _("alertUsed")); } - if (antib.getSettings().getData().isDisableUse() - && !Permissions.BUILD.isAuthorized(user)) + if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user)) { if (event.hasItem() && !Permissions.INTERACT.isAuthorized(user, item.getType(), item.getData())) { @@ -211,8 +202,7 @@ public class EssentialsAntiBuildListener implements Listener final Player user = (Player)entity; final ItemStack item = event.getRecipe().getResult(); - if (antib.getSettings().getData().isDisableUse() - && !Permissions.BUILD.isAuthorized(user)) + if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user)) { if (!Permissions.CRAFT.isAuthorized(user, item.getType(), item.getData())) { @@ -233,8 +223,7 @@ public class EssentialsAntiBuildListener implements Listener final Player user = event.getPlayer(); final ItemStack item = event.getItem().getItemStack(); - if (antib.getSettings().getData().isDisableUse() - && !Permissions.BUILD.isAuthorized(user)) + if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user)) { if (!Permissions.PICKUP.isAuthorized(user, item.getType(), item.getData())) { @@ -251,8 +240,10 @@ public class EssentialsAntiBuildListener implements Listener final Player user = event.getPlayer(); final ItemStack item = event.getItemDrop().getItemStack(); - if (antib.getSettings().getData().isDisableUse() - && !Permissions.BUILD.isAuthorized(user)); + if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user)) + { + ; + } { if (!Permissions.DROP.isAuthorized(user, item.getType(), item.getData())) { @@ -264,5 +255,5 @@ public class EssentialsAntiBuildListener implements Listener } } } - } + } } diff --git a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsConnect.java b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsConnect.java index efa549172..249da46eb 100644 --- a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsConnect.java +++ b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsConnect.java @@ -1,13 +1,13 @@ package net.ess3.antibuild; +import static net.ess3.I18n._; import java.util.logging.Level; import java.util.logging.Logger; -import static net.ess3.I18n._; -import net.ess3.api.IEssentials; -import net.ess3.bukkit.BukkitPlugin; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import net.ess3.api.IEssentials; +import net.ess3.bukkit.BukkitPlugin; public class EssentialsConnect @@ -24,7 +24,7 @@ public class EssentialsConnect } ess = ((BukkitPlugin)essPlugin).getEssentials(); antib = (IAntiBuild)essProtect; - antib.setSettings(new AntiBuildHolder(ess)); + antib.setSettings(new AntiBuildHolder(ess)); } public void onDisable() @@ -39,9 +39,8 @@ public class EssentialsConnect public void alert(final Player user, final String item, final String type) { final Location loc = user.getLocation(); - final String warnMessage = _("alertFormat", user.getName(), type, item, - loc.getWorld().getName() + "," + loc.getBlockX() + "," - + loc.getBlockY() + "," + loc.getBlockZ()); + final String warnMessage = _( + "alertFormat", user.getName(), type, item, loc.getWorld().getName() + "," + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ()); LOGGER.log(Level.WARNING, warnMessage); for (Player p : ess.getServer().getOnlinePlayers()) { diff --git a/EssentialsAntiBuild/src/net/ess3/antibuild/IAntiBuild.java b/EssentialsAntiBuild/src/net/ess3/antibuild/IAntiBuild.java index 599b63a01..51e49c463 100644 --- a/EssentialsAntiBuild/src/net/ess3/antibuild/IAntiBuild.java +++ b/EssentialsAntiBuild/src/net/ess3/antibuild/IAntiBuild.java @@ -3,10 +3,11 @@ package net.ess3.antibuild; import org.bukkit.plugin.Plugin; + public interface IAntiBuild extends Plugin { EssentialsConnect getEssentialsConnect(); - + AntiBuildHolder getSettings(); void setSettings(AntiBuildHolder settings); diff --git a/EssentialsAntiBuild/src/net/ess3/antibuild/Permissions.java b/EssentialsAntiBuild/src/net/ess3/antibuild/Permissions.java index 588eebf24..a217163c4 100644 --- a/EssentialsAntiBuild/src/net/ess3/antibuild/Permissions.java +++ b/EssentialsAntiBuild/src/net/ess3/antibuild/Permissions.java @@ -1,14 +1,11 @@ package net.ess3.antibuild; -import java.util.EnumMap; import java.util.Locale; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.PermissionDefault; import net.ess3.api.IPermission; import net.ess3.bukkit.PermissionFactory; -import net.ess3.permissions.BasePermission; import net.ess3.permissions.MaterialDotStarPermission; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.permissions.PermissionDefault; public enum Permissions implements IPermission @@ -33,7 +30,7 @@ public enum Permissions implements IPermission { this(defaultBase, defaultPerm); } - + private Permissions(final String base, final PermissionDefault defaultPerm) { permission = base + toString().toLowerCase(Locale.ENGLISH).replace('_', '.'); @@ -70,12 +67,12 @@ public enum Permissions implements IPermission { return PermissionFactory.checkPermission(sender, this); } - + public static MaterialDotStarPermission PLACEMENT = new MaterialDotStarPermission("essentials.build.place"); public static MaterialDotStarPermission BREAK = new MaterialDotStarPermission("essentials.build.break"); public static MaterialDotStarPermission INTERACT = new MaterialDotStarPermission("essentials.build.interact"); public static MaterialDotStarPermission CRAFT = new MaterialDotStarPermission("essentials.build.craft"); public static MaterialDotStarPermission PICKUP = new MaterialDotStarPermission("essentials.build.pickup"); public static MaterialDotStarPermission DROP = new MaterialDotStarPermission("essentials.build.drop"); - + } |