From 5432f046e17cb54775e236d44e80527974529520 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 18 Aug 2012 21:19:00 +0100 Subject: Split Ess protect into EssProtect and EssAntiBuild New permissions: essentials.build - same as build: true essentials.build.interact. - whitelist single interact block essentials.build.place. - whitelist single place block essentials.build.break. - whitelist single break block essentials.build.use. - whitelist single use item --- .../essentials/protect/EssentialsConnect.java | 20 ---------- .../essentials/protect/EssentialsProtect.java | 7 ---- .../protect/EssentialsProtectBlockListener.java | 44 ---------------------- .../protect/EssentialsProtectPlayerListener.java | 40 -------------------- .../com/earth2me/essentials/protect/IProtect.java | 2 - .../earth2me/essentials/protect/ProtectConfig.java | 11 +----- 6 files changed, 1 insertion(+), 123 deletions(-) (limited to 'EssentialsProtect/src/com') diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java index 7503c334c..e17264ca9 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java @@ -2,7 +2,6 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.IConf; import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; import com.earth2me.essentials.protect.data.ProtectedBlockMemory; import com.earth2me.essentials.protect.data.ProtectedBlockMySQL; import com.earth2me.essentials.protect.data.ProtectedBlockSQLite; @@ -10,8 +9,6 @@ import java.beans.PropertyVetoException; import static com.earth2me.essentials.I18n._; import java.util.logging.Level; import java.util.logging.Logger; -import org.bukkit.Location; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -43,23 +40,6 @@ public class EssentialsConnect return ess; } - public void alert(final User 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()); - LOGGER.log(Level.WARNING, warnMessage); - for (Player p : ess.getServer().getOnlinePlayers()) - { - final User alertUser = ess.getUser(p); - if (alertUser.isAuthorized("essentials.protect.alerts")) - { - alertUser.sendMessage(warnMessage); - } - } - } - private class ProtectReloader implements IConf { diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 9c257662d..06dc03656 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -73,13 +73,6 @@ public class EssentialsProtect extends JavaPlugin implements IProtect LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now."); } - @Override - public boolean checkProtectionItems(final ProtectConfig list, final int id) - { - final List itemList = settingsList.get(list); - return itemList != null && !itemList.isEmpty() && itemList.contains(id); - } - @Override public IProtectedBlock getStorage() { diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index 8e5e9cca8..bd760b0ec 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.protect; -import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.protect.data.IProtectedBlock; @@ -36,26 +35,9 @@ public class EssentialsProtectBlockListener implements Listener final User user = ess.getUser(event.getPlayer()); - if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild()) - { - event.setCancelled(true); - return; - } - final Block blockPlaced = event.getBlockPlaced(); final int id = blockPlaced.getTypeId(); - if (prot.checkProtectionItems(ProtectConfig.blacklist_placement, id) && !user.isAuthorized("essentials.protect.exemptplacement")) - { - event.setCancelled(true); - return; - } - - if (!user.hasPermission("essentials.protect.alerts.notrigger") - && prot.checkProtectionItems(ProtectConfig.alert_on_placement, id)) - { - prot.getEssentialsConnect().alert(user, blockPlaced.getType().toString(), _("alertPlaced")); - } final Block below = blockPlaced.getRelative(BlockFace.DOWN); if ((below.getType() == Material.RAILS || below.getType() == Material.POWERED_RAIL || below.getType() == Material.DETECTOR_RAIL) @@ -234,27 +216,11 @@ public class EssentialsProtectBlockListener implements Listener } final User user = ess.getUser(event.getPlayer()); - if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild()) - { - event.setCancelled(true); - return; - } final Block block = event.getBlock(); final int typeId = block.getTypeId(); - if (prot.checkProtectionItems(ProtectConfig.blacklist_break, typeId) - && !user.isAuthorized("essentials.protect.exemptbreak")) - { - event.setCancelled(true); - return; - } final Material type = block.getType(); - if (!user.hasPermission("essentials.protect.alerts.notrigger") - && prot.checkProtectionItems(ProtectConfig.alert_on_break, typeId)) - { - prot.getEssentialsConnect().alert(user, type.toString(), _("alertBroke")); - } final IProtectedBlock storage = prot.getStorage(); if (user.isAuthorized("essentials.protect.admin")) @@ -333,11 +299,6 @@ public class EssentialsProtectBlockListener implements Listener } for (Block block : event.getBlocks()) { - if (prot.checkProtectionItems(ProtectConfig.blacklist_piston, block.getTypeId())) - { - event.setCancelled(true); - return; - } if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS || block.getType() == Material.RAILS || block.getRelative(BlockFace.UP).getType() == Material.POWERED_RAIL @@ -385,11 +346,6 @@ public class EssentialsProtectBlockListener implements Listener return; } final Block block = event.getRetractLocation().getBlock(); - if (prot.checkProtectionItems(ProtectConfig.blacklist_piston, block.getTypeId())) - { - event.setCancelled(true); - return; - } if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS || block.getType() == Material.RAILS || block.getRelative(BlockFace.UP).getType() == Material.POWERED_RAIL diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java index 6e515e56d..393376b6f 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java @@ -3,14 +3,12 @@ package com.earth2me.essentials.protect; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; public class EssentialsProtectPlayerListener implements Listener @@ -30,38 +28,6 @@ public class EssentialsProtectPlayerListener implements Listener // Do not return if cancelled, because the interact event has 2 cancelled states. final User user = ess.getUser(event.getPlayer()); - if (event.hasItem() - && (event.getItem().getType() == Material.WATER_BUCKET - || event.getItem().getType() == Material.LAVA_BUCKET) - && prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild()) - { - if (ess.getSettings().warnOnBuildDisallow()) - { - user.sendMessage(_("buildAlert")); - } - event.setCancelled(true); - return; - } - - if (prot.getSettingBool(ProtectConfig.disable_use) && !user.canBuild()) - { - if (ess.getSettings().warnOnBuildDisallow()) - { - user.sendMessage(_("buildAlert")); - } - event.setCancelled(true); - return; - } - - final ItemStack item = event.getItem(); - if (item != null - && prot.checkProtectionItems(ProtectConfig.blacklist_usage, item.getTypeId()) - && !user.isAuthorized("essentials.protect.exemptusage")) - { - event.setCancelled(true); - return; - } - if (user.isAuthorized("essentials.protect.ownerinfo") && event.getAction() == Action.RIGHT_CLICK_BLOCK) { final StringBuilder stringBuilder = new StringBuilder(); @@ -82,11 +48,5 @@ public class EssentialsProtectPlayerListener implements Listener user.sendMessage(_("protectionOwner", ownerNames)); } } - if (item != null - && !user.hasPermission("essentials.protect.alerts.notrigger") - && prot.checkProtectionItems(ProtectConfig.alert_on_use, item.getTypeId())) - { - prot.getEssentialsConnect().alert(user, item.getType().toString(), _("alertUsed")); - } } } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java index afcb6e8ce..b82481267 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java @@ -8,8 +8,6 @@ import org.bukkit.plugin.Plugin; public interface IProtect extends Plugin { - boolean checkProtectionItems(final ProtectConfig list, final int id); - boolean getSettingBool(final ProtectConfig protectConfig); String getSettingString(final ProtectConfig protectConfig); diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java index bee8d0f4d..31141d7e7 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java @@ -10,8 +10,6 @@ public enum ProtectConfig memstore("protect.memstore", false), disable_contactdmg("protect.disable.contactdmg", false), disable_lavadmg("protect.disable.lavadmg", false), - disable_build("protect.disable.build", true), - disable_use("protect.disable.use", true), disable_pvp("protect.disable.pvp", false), disable_projectiles("protect.disable.projectiles", false), disable_fall("protect.disable.fall", false), @@ -47,14 +45,7 @@ public enum ProtectConfig protect_below_rails("protect.protect.block-below", true), protect_signs("protect.protect.signs", true), protect_against_signs("protect.protect.block-below", true), - enderdragon_fakeexplosions("protect.enderdragon-fakeexplosions", false), - alert_on_placement("protect.alert.on-placement"), - alert_on_use("protect.alert.on-use"), - alert_on_break("protect.alert.on-break"), - blacklist_placement("protect.blacklist.placement"), - blacklist_usage("protect.blacklist.usage"), - blacklist_break("protect.blacklist.break"), - blacklist_piston("protect.blacklist.piston"); + enderdragon_fakeexplosions("protect.enderdragon-fakeexplosions", false); private final String configName; private final String defValueString; private final boolean defValueBoolean; -- cgit v1.2.3