diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-01-29 01:12:38 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-01-29 01:12:38 +0000 |
commit | e1abdbdd370989c48ea49e54306155750e18b598 (patch) | |
tree | 621fa3f6915bf4724468e56196a89ca30b844d52 | |
parent | c6aa34076aeeab5e63ccee1102826fa9557753e9 (diff) | |
download | Essentials-e1abdbdd370989c48ea49e54306155750e18b598.tar Essentials-e1abdbdd370989c48ea49e54306155750e18b598.tar.gz Essentials-e1abdbdd370989c48ea49e54306155750e18b598.tar.lz Essentials-e1abdbdd370989c48ea49e54306155750e18b598.tar.xz Essentials-e1abdbdd370989c48ea49e54306155750e18b598.zip |
Added options to enable each sign type
6 files changed, 83 insertions, 32 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 30a073dde..560eb6f79 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -1,6 +1,7 @@ package com.earth2me.essentials; import com.earth2me.essentials.commands.IEssentialsCommand; +import com.earth2me.essentials.signs.EssentialsSign; import java.text.MessageFormat; import java.util.List; import java.util.Map; @@ -100,6 +101,8 @@ public interface ISettings extends IConf boolean isTradeInStacks(int id); List<Integer> itemSpawnBlacklist(); + + List<EssentialsSign> enabledSigns(); boolean permissionBasedItemSpawn(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index dc9c9471e..2152fc800 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -2,6 +2,8 @@ package com.earth2me.essentials; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.commands.IEssentialsCommand; +import com.earth2me.essentials.signs.EssentialsSign; +import com.earth2me.essentials.signs.Signs; import java.io.File; import java.text.MessageFormat; import java.util.*; @@ -278,7 +280,7 @@ public class Settings implements ISettings @Override public boolean areSignsDisabled() { - return config.getBoolean("signs-disabled", false); + return enabledSigns.isEmpty(); } @Override @@ -356,12 +358,21 @@ public class Settings implements ISettings { config.load(); noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList())); + enabledSigns = getEnabledSigns(); + itemSpawnBl = getItemSpawnBlacklist(); chatFormats.clear(); } + private List<Integer> itemSpawnBl = new ArrayList<Integer>(); + @Override public List<Integer> itemSpawnBlacklist() { + return itemSpawnBl; + } + + private List<Integer> getItemSpawnBlacklist() + { final List<Integer> epItemSpwn = new ArrayList<Integer>(); for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) { @@ -369,12 +380,11 @@ public class Settings implements ISettings if (itemName.isEmpty()) { continue; - } - ItemStack is; + } try { - is = ess.getItemDb().get(itemName); - epItemSpwn.add(is.getTypeId()); + final ItemStack iStack = ess.getItemDb().get(itemName); + epItemSpwn.add(iStack.getTypeId()); } catch (Exception ex) { @@ -383,6 +393,36 @@ public class Settings implements ISettings } return epItemSpwn; } + + private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>(); + + @Override + public List<EssentialsSign> enabledSigns() + { + return enabledSigns; + } + + private List<EssentialsSign> getEnabledSigns() + { + List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>(); + for (String signName : config.getString("enabledSigns", "").split(",")) + { + signName = signName.trim(); + if (signName.isEmpty()) + { + continue; + } + try + { + newSigns.add(Signs.valueOf(signName).getSign()); + } + catch (Exception ex) + { + logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns")); + } + } + return newSigns; + } @Override public boolean spawnIfNoHome() @@ -559,7 +599,8 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } - Set<String> noGodWorlds = new HashSet<String>(); + + private Set<String> noGodWorlds = new HashSet<String>(); @Override public Set<String> getNoGodWorlds() diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 913de6358..2ddb42c36 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -44,9 +44,9 @@ public class SignBlockListener implements Listener if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) { final Sign csign = (Sign)block.getState(); - for (Signs signs : Signs.values()) + + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName()) && !sign.onSignBreak(block, player, ess)) { @@ -62,9 +62,8 @@ public class SignBlockListener implements Listener LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign."); return true; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, player, ess)) { @@ -91,9 +90,8 @@ public class SignBlockListener implements Listener event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "ยง$1")); } } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (event.getLine(0).equalsIgnoreCase(sign.getSuccessName())) { event.setCancelled(true); @@ -130,9 +128,8 @@ public class SignBlockListener implements Listener { return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockPlace(block, event.getPlayer(), ess)) { @@ -159,9 +156,8 @@ public class SignBlockListener implements Listener event.setCancelled(true); return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockBurn(block, ess)) { @@ -188,9 +184,8 @@ public class SignBlockListener implements Listener event.setCancelled(true); return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockIgnite(block, ess)) { @@ -213,9 +208,8 @@ public class SignBlockListener implements Listener event.setCancelled(true); return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockPush(block, ess)) { @@ -240,9 +234,8 @@ public class SignBlockListener implements Listener event.setCancelled(true); return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockPush(block, ess)) { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index 281afdc98..d9e28becc 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -32,9 +32,8 @@ public class SignEntityListener implements Listener event.setCancelled(true); return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType())) { event.setCancelled(!sign.onBlockExplode(block, ess)); @@ -61,9 +60,8 @@ public class SignEntityListener implements Listener event.setCancelled(true); return; } - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, ess)) { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index f1ba79b0b..f891c0fdb 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -41,9 +41,8 @@ public class SignPlayerListener implements Listener return; } final Sign csign = (Sign)block.getState(); - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName())) { sign.onSignInteract(block, event.getPlayer(), ess); @@ -54,9 +53,8 @@ public class SignPlayerListener implements Listener } else { - for (Signs signs : Signs.values()) + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - final EssentialsSign sign = signs.getSign(); if (sign.getBlocks().contains(block.getType()) && !sign.onBlockInteract(block, event.getPlayer(), ess)) { diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 877ff0c42..a9e980725 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -166,8 +166,26 @@ kits: - 278 1 - 279 1 -# Disable all signs -signs-disabled: false +# Enable specifc signs on the server +# See http://ess.khhq.net/wiki/Sign_Tutorial for specific instructions. +# To enable remove # symbol. +enabledSigns: + - balance + #- buy + #- sell + #- trade + #- free + - disposal + #- warp + #- kit + #- mail + #- enchant + #- gamemode + #- heal + #- spawnmob + #- time + #- weather + #- protection # Backup runs a command while saving is disabled backup: |