diff options
author | ementalo <ementalodev@gmx.co.uk> | 2012-07-17 12:26:55 +0100 |
---|---|---|
committer | ementalo <ementalodev@gmx.co.uk> | 2012-07-17 14:21:03 +0100 |
commit | a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3 (patch) | |
tree | 2aa10b6300f6c8d3cb2b298c124180fade74857a /EssentialsSigns | |
parent | 3c385e69271dfe8530fadc3f67e13ee495e4b0e1 (diff) | |
parent | 9f05e43ecf8e6e1a8fcaef757678e762f0d82573 (diff) | |
download | Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.gz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.lz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.xz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.zip |
Merge of server-layer branch
Diffstat (limited to 'EssentialsSigns')
-rw-r--r-- | EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java | 7 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/EssentialsSign.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java) | 128 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/EssentialsSignsPlugin.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSignsPlugin.java) | 9 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/ISignsPlugin.java | 9 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignBalance.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignBalance.java) | 5 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignBlockListener.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignBlockListener.java) | 90 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignBuy.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java) | 4 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignDisposal.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignDisposal.java) | 2 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignEnchant.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java) | 12 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignEntityListener.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java) | 19 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignException.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignException.java) | 2 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignFree.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java) | 4 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignGameMode.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java) | 6 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignHeal.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java) | 6 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignKit.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java) | 11 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignMail.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignMail.java) | 2 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignPlayerListener.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignPlayerListener.java) | 13 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignProtection.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java) | 10 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignSell.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java) | 4 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignSpawnmob.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java) | 7 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignTime.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignTime.java) | 6 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignTrade.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignTrade.java) | 4 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignWarp.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java) | 4 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignWeather.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java) | 6 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/Signs.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java) | 2 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignsConfig.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java) | 8 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfigHolder.java) | 34 | ||||
-rw-r--r-- | EssentialsSigns/src/net/ess3/signs/SignsPermissions.java (renamed from EssentialsSigns/src/com/earth2me/essentials/signs/SignsPermissions.java) | 2 | ||||
-rw-r--r-- | EssentialsSigns/src/plugin.yml | 4 |
29 files changed, 230 insertions, 190 deletions
diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java b/EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java deleted file mode 100644 index a7d8c24cb..000000000 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.earth2me.essentials.signs; - -import net.ess3.api.IEssentialsModule; - -public interface ISignsPlugin extends IEssentialsModule { - SignsConfigHolder getSettings(); -} diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java b/EssentialsSigns/src/net/ess3/signs/EssentialsSign.java index 4992eb795..59c733981 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/EssentialsSigns/src/net/ess3/signs/EssentialsSign.java @@ -1,4 +1,8 @@ +<<<<<<< HEAD:EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java package com.earth2me.essentials.signs; +======= +package net.ess3.signs; +>>>>>>> master:EssentialsSigns/src/net/ess3/signs/EssentialsSign.java import net.ess3.api.ChargeException; import static net.ess3.I18n._; @@ -22,12 +26,12 @@ public class EssentialsSign { private static final Set<Material> EMPTY_SET = new HashSet<Material>(); protected transient final String signName; - + public EssentialsSign(final String signName) { this.signName = signName; } - + public final boolean onSignCreate(final SignChangeEvent event, final IEssentials ess) { final ISign sign = new EventSign(event); @@ -59,22 +63,22 @@ public class EssentialsSign // Return true, so the player sees the wrong sign. return true; } - + public String getSuccessName() { return _("signFormatSuccess", this.signName); } - + public String getTemplateName() { return _("signFormatTemplate", this.signName); } - + private String getUsername(final IUser user) { return user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length()); } - + public final boolean onSignInteract(final Block block, final Player player, final IEssentials ess) { final ISign sign = new BlockSign(block); @@ -86,7 +90,7 @@ public class EssentialsSign } catch (ChargeException ex) { - ess.getCommandHandler().showCommandError(user,signName, ex); + ess.getCommandHandler().showCommandError(user, signName, ex); return false; } catch (SignException ex) @@ -95,7 +99,7 @@ public class EssentialsSign return false; } } - + public final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) { final ISign sign = new BlockSign(block); @@ -111,25 +115,25 @@ public class EssentialsSign return false; } } - + protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException { return true; } - + protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException { return true; } - + protected boolean onSignBreak(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException { return true; } - + public final boolean onBlockPlace(final Block block, final Player player, final IEssentials ess) { - IUser user = ess.getUser(player); + final IUser user = ess.getUser(player); try { return onBlockPlace(block, user, getUsername(user), ess); @@ -144,10 +148,10 @@ public class EssentialsSign } return false; } - + public final boolean onBlockInteract(final Block block, final Player player, final IEssentials ess) { - IUser user = ess.getUser(player); + final IUser user = ess.getUser(player); try { return onBlockInteract(block, user, getUsername(user), ess); @@ -162,10 +166,10 @@ public class EssentialsSign } return false; } - + public final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess) { - IUser user = ess.getUser(player); + final IUser user = ess.getUser(player); try { return onBlockBreak(block, user, getUsername(user), ess); @@ -176,32 +180,32 @@ public class EssentialsSign } return false; } - + public boolean onBlockBreak(final Block block, final IEssentials ess) { return true; } - + public boolean onBlockExplode(final Block block, final IEssentials ess) { return true; } - + public boolean onBlockBurn(final Block block, final IEssentials ess) { return true; } - + public boolean onBlockIgnite(final Block block, final IEssentials ess) { return true; } - + public boolean onBlockPush(final Block block, final IEssentials ess) { return true; } - + public static boolean checkIfBlockBreaksSigns(final Block block) { final Block sign = block.getRelative(BlockFace.UP); @@ -230,32 +234,32 @@ public class EssentialsSign } return false; } - + public static boolean isValidSign(final ISign sign) { return sign.getLine(0).matches("§1\\[.*\\]"); } - + protected boolean onBlockPlace(final Block block, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException { return true; } - + protected boolean onBlockInteract(final Block block, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException { return true; } - + protected boolean onBlockBreak(final Block block, final IUser player, final String username, final IEssentials ess) throws SignException { return true; } - + public Set<Material> getBlocks() { return EMPTY_SET; } - + protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException { final String line = sign.getLine(index).trim(); @@ -270,7 +274,7 @@ public class EssentialsSign sign.setLine(index, Util.shortCurrency(money, ess)); } } - + protected final void validateTrade(final ISign sign, final int amountIndex, final int itemIndex, final IUser player, final IEssentials ess) throws SignException { @@ -286,7 +290,7 @@ public class EssentialsSign sign.setLine(amountIndex, Integer.toString(item.getAmount())); sign.setLine(itemIndex, sign.getLine(itemIndex).trim()); } - + protected final Trade getTrade(final ISign sign, final int amountIndex, final int itemIndex, final IUser player, final IEssentials ess) throws SignException { @@ -304,7 +308,7 @@ public class EssentialsSign item.setAmount(amount); return new Trade(item, ess); } - + protected final void validateInteger(final ISign sign, final int index) throws SignException { final String line = sign.getLine(index).trim(); @@ -315,7 +319,7 @@ public class EssentialsSign final int quantity = getIntegerPositive(line); sign.setLine(index, Integer.toString(quantity)); } - + protected final int getIntegerPositive(final String line) throws SignException { final int quantity = getInteger(line); @@ -325,13 +329,13 @@ public class EssentialsSign } return quantity; } - + protected final int getInteger(final String line) throws SignException { try { final int quantity = Integer.parseInt(line); - + return quantity; } catch (NumberFormatException ex) @@ -339,7 +343,7 @@ public class EssentialsSign throw new SignException("Invalid sign", ex); } } - + protected final ItemStack getItemStack(final String itemName, final int quantity, final IEssentials ess) throws SignException { try @@ -353,13 +357,13 @@ public class EssentialsSign throw new SignException(ex.getMessage(), ex); } } - + protected final Double getMoney(final String line) throws SignException { final boolean isMoney = line.matches("^[^0-9-\\.][\\.0-9]+$"); return isMoney ? getDoublePositive(line.substring(1)) : null; } - + protected final Double getDoublePositive(final String line) throws SignException { final double quantity = getDouble(line); @@ -369,7 +373,7 @@ public class EssentialsSign } return quantity; } - + protected final Double getDouble(final String line) throws SignException { try @@ -381,12 +385,12 @@ public class EssentialsSign throw new SignException(ex.getMessage(), ex); } } - + protected final Trade getTrade(final ISign sign, final int index, final IEssentials ess) throws SignException { return getTrade(sign, index, 1, ess); } - + protected final Trade getTrade(final ISign sign, final int index, final int decrement, final IEssentials ess) throws SignException { final String line = sign.getLine(index).trim(); @@ -394,7 +398,7 @@ public class EssentialsSign { return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess); } - + final Double money = getMoney(line); if (money == null) { @@ -404,7 +408,7 @@ public class EssentialsSign throw new SignException(_("invalidCharge")); } final int quantity = getIntegerPositive(split[0]); - + final String item = split[1].toLowerCase(Locale.ENGLISH); if (item.equalsIgnoreCase("times")) { @@ -428,89 +432,89 @@ public class EssentialsSign return new Trade(money, ess); } } - - + + static class EventSign implements ISign { private final transient SignChangeEvent event; private final transient Block block; - + public EventSign(final SignChangeEvent event) { this.event = event; this.block = event.getBlock(); } - + @Override public final String getLine(final int index) { return event.getLine(index); } - + @Override public final void setLine(final int index, final String text) { event.setLine(index, text); } - + @Override public Block getBlock() { return block; } - + @Override public void updateSign() { } } - - + + static class BlockSign implements ISign { private final transient Sign sign; private final transient Block block; - + public BlockSign(final Block block) { this.block = block; this.sign = (Sign)block.getState(); } - + @Override public final String getLine(final int index) { return sign.getLine(index); } - + @Override public final void setLine(final int index, final String text) { sign.setLine(index, text); } - + @Override public final Block getBlock() { return block; } - + @Override public final void updateSign() { sign.update(); } } - - + + public interface ISign { String getLine(final int index); - + void setLine(final int index, final String text); - + public Block getBlock(); - + void updateSign(); } } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSignsPlugin.java b/EssentialsSigns/src/net/ess3/signs/EssentialsSignsPlugin.java index f0e33f9cd..d2f615d52 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSignsPlugin.java +++ b/EssentialsSigns/src/net/ess3/signs/EssentialsSignsPlugin.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import static net.ess3.I18n._; import net.ess3.api.IEssentials; @@ -12,14 +12,13 @@ import org.bukkit.plugin.java.JavaPlugin; public class EssentialsSignsPlugin extends JavaPlugin implements ISignsPlugin { private static final transient Logger LOGGER = Bukkit.getLogger(); - private transient IEssentials ess; private transient SignsConfigHolder config; @Override public void onEnable() { final PluginManager pluginManager = getServer().getPluginManager(); - ess = (IEssentials)pluginManager.getPlugin("Essentials3"); + final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials-3"); if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) { LOGGER.log(Level.WARNING, _("versionMismatchAll")); @@ -38,8 +37,8 @@ public class EssentialsSignsPlugin extends JavaPlugin implements ISignsPlugin final SignEntityListener signEntityListener = new SignEntityListener(ess, this); pluginManager.registerEvents(signEntityListener, this); - - config = new SignsConfigHolder(ess, this); + + config = new SignsConfigHolder(ess, this); } @Override diff --git a/EssentialsSigns/src/net/ess3/signs/ISignsPlugin.java b/EssentialsSigns/src/net/ess3/signs/ISignsPlugin.java new file mode 100644 index 000000000..9a6d14a61 --- /dev/null +++ b/EssentialsSigns/src/net/ess3/signs/ISignsPlugin.java @@ -0,0 +1,9 @@ +package net.ess3.signs; + +import net.ess3.api.IEssentialsModule; + + +public interface ISignsPlugin extends IEssentialsModule +{ + SignsConfigHolder getSettings(); +} diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBalance.java b/EssentialsSigns/src/net/ess3/signs/SignBalance.java index 52fdbb336..35a1648ae 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBalance.java +++ b/EssentialsSigns/src/net/ess3/signs/SignBalance.java @@ -1,8 +1,9 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import static net.ess3.I18n._; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.utils.Util; public class SignBalance extends EssentialsSign @@ -15,7 +16,7 @@ public class SignBalance extends EssentialsSign @Override protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException { - player.sendMessage(_("balance", player.getMoney())); + player.sendMessage(_("balance", Util.displayCurrency(player.getMoney(), ess))); return true; } } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBlockListener.java b/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java index 3d9315249..31cdfc970 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java @@ -1,7 +1,9 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.IEssentials; +import net.ess3.api.ISettings; import net.ess3.api.IUser; +import net.ess3.utils.Util; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Material; @@ -19,6 +21,8 @@ public class SignBlockListener implements Listener private final transient IEssentials ess; private final transient ISignsPlugin plugin; private final static Logger LOGGER = Logger.getLogger("Minecraft"); + private final static int WALL_SIGN = Material.WALL_SIGN.getId(); + private final static int SIGN_POST = Material.SIGN_POST.getId(); public SignBlockListener(final IEssentials ess, final ISignsPlugin plugin) { @@ -26,10 +30,12 @@ public class SignBlockListener implements Listener this.plugin = plugin; } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockBreak(final BlockBreakEvent event) { - if (event.isCancelled()) + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + if (plugin.getSettings().areSignsDisabled()) { return; } @@ -43,7 +49,7 @@ public class SignBlockListener implements Listener public boolean protectSignsAndBlocks(final Block block, final Player player) { final int mat = block.getTypeId(); - if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) + if (mat == SIGN_POST || mat == WALL_SIGN) { final Sign csign = (Sign)block.getState(); @@ -56,15 +62,13 @@ public class SignBlockListener implements Listener } } } - else + // prevent any signs be broken by destroying the block they are attached to + if (EssentialsSign.checkIfBlockBreaksSigns(block)) { - // prevent any signs be broken by destroying the block they are attached to - if (EssentialsSign.checkIfBlockBreaksSigns(block)) - { - LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign."); - return true; - } - for (EssentialsSign sign : plugin.getSettings().getEnabledSigns()) + LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign."); + return true; + } + for (EssentialsSign sign : plugin.getSettings().getEnabledSigns()) { if (sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, player, ess)) @@ -72,26 +76,24 @@ public class SignBlockListener implements Listener LOGGER.log(Level.INFO, "A block was protected by a sign."); return true; } - } - } + } return false; } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSignChange(final SignChangeEvent event) { - if (event.isCancelled()) + if (plugin.getSettings().areSignsDisabled()) { return; } IUser user = ess.getUser(event.getPlayer()); - if (SignsPermissions.COLOR.isAuthorized(user)) + + for (int i = 0; i < 4; i++) { - for (int i = 0; i < 4; i++) - { - event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "§$1")); - } + event.setLine(i, Util.formatString(user, "essentials.signs", event.getLine(i))); } + for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); @@ -109,25 +111,25 @@ public class SignBlockListener implements Listener } } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockPlace(final BlockPlaceEvent event) { - if (event.isCancelled()) + if (plugin.getSettings().areSignsDisabled()) { return; } final Block against = event.getBlockAgainst(); - if ((against.getType() == Material.WALL_SIGN - || against.getType() == Material.SIGN_POST) + if ((against.getTypeId() == WALL_SIGN + || against.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against))) { event.setCancelled(true); return; } final Block block = event.getBlock(); - if (block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) { return; } @@ -143,17 +145,17 @@ public class SignBlockListener implements Listener } } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockBurn(final BlockBurnEvent event) { - if (event.isCancelled()) + if (plugin.getSettings().areSignsDisabled()) { return; } final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -171,17 +173,17 @@ public class SignBlockListener implements Listener } } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockIgnite(final BlockIgniteEvent event) { - if (event.isCancelled()) + if (plugin.getSettings().areSignsDisabled()) { return; } final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -202,10 +204,15 @@ public class SignBlockListener implements Listener @EventHandler(priority = EventPriority.LOW) public void onBlockPistonExtend(final BlockPistonExtendEvent event) { + if (plugin.getSettings().areSignsDisabled()) + { + return; + } + for (Block block : event.getBlocks()) { - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -227,11 +234,16 @@ public class SignBlockListener implements Listener @EventHandler(priority = EventPriority.LOW) public void onBlockPistonRetract(final BlockPistonRetractEvent event) { + if (plugin.getSettings().areSignsDisabled()) + { + return; + } + if (event.isSticky()) { final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java b/EssentialsSigns/src/net/ess3/signs/SignBuy.java index 252ac76cf..ff08cdbc1 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java +++ b/EssentialsSigns/src/net/ess3/signs/SignBuy.java @@ -1,9 +1,9 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.ChargeException; -import net.ess3.economy.Trade; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; public class SignBuy extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignDisposal.java b/EssentialsSigns/src/net/ess3/signs/SignDisposal.java index f56a2ede6..01775e18c 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignDisposal.java +++ b/EssentialsSigns/src/net/ess3/signs/SignDisposal.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.IEssentials; import net.ess3.api.IUser; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java b/EssentialsSigns/src/net/ess3/signs/SignEnchant.java index 6463ab5de..6004d9f38 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java +++ b/EssentialsSigns/src/net/ess3/signs/SignEnchant.java @@ -1,11 +1,11 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; -import net.ess3.api.ChargeException; -import net.ess3.bukkit.Enchantments; import static net.ess3.I18n._; -import net.ess3.economy.Trade; +import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.bukkit.Enchantments; +import net.ess3.economy.Trade; import java.util.Locale; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -39,7 +39,7 @@ public class SignEnchant extends EssentialsSign } catch (NumberFormatException ex) { - throw new SignException(ex.getMessage()); + throw new SignException(ex.getMessage(), ex); } if (level < 1 || level > enchantment.getMaxLevel()) { @@ -55,7 +55,7 @@ public class SignEnchant extends EssentialsSign } catch (Throwable ex) { - throw new SignException(ex.getMessage()); + throw new SignException(ex.getMessage(), ex); } getTrade(sign, 3, ess); return true; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java b/EssentialsSigns/src/net/ess3/signs/SignEntityListener.java index 077c54813..1c316478d 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/EssentialsSigns/src/net/ess3/signs/SignEntityListener.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.IEssentials; import org.bukkit.Material; @@ -24,10 +24,15 @@ public class SignEntityListener implements Listener @EventHandler(priority = EventPriority.LOW) public void onEntityExplode(final EntityExplodeEvent event) { + if (plugin.getSettings().areSignsDisabled()) + { + return; + } + for (Block block : event.blockList()) { - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == Material.WALL_SIGN.getId() + || block.getTypeId() == Material.SIGN_POST.getId()) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -45,17 +50,17 @@ public class SignEntityListener implements Listener } } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityChangeBlock(final EntityChangeBlockEvent event) { - if (event.isCancelled()) + if (plugin.getSettings().areSignsDisabled()) { return; } final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == Material.WALL_SIGN.getId() + || block.getTypeId() == Material.SIGN_POST.getId()) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignException.java b/EssentialsSigns/src/net/ess3/signs/SignException.java index 9c9ab44a2..7ca73e4e5 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignException.java +++ b/EssentialsSigns/src/net/ess3/signs/SignException.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; public class SignException extends Exception diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java b/EssentialsSigns/src/net/ess3/signs/SignFree.java index a96045a2f..2cf049346 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java +++ b/EssentialsSigns/src/net/ess3/signs/SignFree.java @@ -1,10 +1,10 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import static net.ess3.I18n._; -import net.ess3.economy.Trade; import net.ess3.api.IEssentials; import net.ess3.api.IUser; import net.ess3.craftbukkit.InventoryWorkaround; +import net.ess3.economy.Trade; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java b/EssentialsSigns/src/net/ess3/signs/SignGameMode.java index 217d8da77..a8ef5a881 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java +++ b/EssentialsSigns/src/net/ess3/signs/SignGameMode.java @@ -1,10 +1,10 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; -import net.ess3.api.ChargeException; import static net.ess3.I18n._; -import net.ess3.economy.Trade; +import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; import java.util.Locale; import org.bukkit.GameMode; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java b/EssentialsSigns/src/net/ess3/signs/SignHeal.java index 09f1f9cc7..787e7b166 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java +++ b/EssentialsSigns/src/net/ess3/signs/SignHeal.java @@ -1,10 +1,10 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; -import net.ess3.api.ChargeException; import static net.ess3.I18n._; -import net.ess3.economy.Trade; +import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; public class SignHeal extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java b/EssentialsSigns/src/net/ess3/signs/SignKit.java index 6270baf8f..9c478ccad 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java +++ b/EssentialsSigns/src/net/ess3/signs/SignKit.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.ChargeException; import net.ess3.economy.Trade; @@ -32,7 +32,7 @@ public class SignKit extends EssentialsSign { try { - ess.getKits().getKit(kitName); + ess.getKits().getKit(kitName); } catch (Exception ex) { @@ -58,11 +58,10 @@ public class SignKit extends EssentialsSign final Trade charge = getTrade(sign, 3, ess); charge.isAffordableFor(player); try - { - final Kit kit = ess.getKits().getKit(kitName); + {; + final Kit kit = ess.getKits().getKit(kitName); + ess.getKits().checkTime(player, kit); ess.getKits().sendKit(player, kit); - - //TODO: Implement Kits from 2.9 charge.charge(player); } catch (Exception ex) diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignMail.java b/EssentialsSigns/src/net/ess3/signs/SignMail.java index 483964bf2..6acf14bb1 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignMail.java +++ b/EssentialsSigns/src/net/ess3/signs/SignMail.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import static net.ess3.I18n._; import net.ess3.api.IEssentials; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignPlayerListener.java b/EssentialsSigns/src/net/ess3/signs/SignPlayerListener.java index 4dd8db93f..eabf5423b 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/EssentialsSigns/src/net/ess3/signs/SignPlayerListener.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.IEssentials; import org.bukkit.Material; @@ -22,26 +22,22 @@ public class SignPlayerListener implements Listener this.plugin = plugin; } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteract(final PlayerInteractEvent event) { - if (event.isCancelled()) + if (plugin.getSettings().areSignsDisabled() || event.getAction() != Action.RIGHT_CLICK_BLOCK) { return; } - final Block block = event.getClickedBlock(); if (block == null) { return; } + final int mat = block.getTypeId(); if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) { - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) - { - return; - } final Sign csign = (Sign)block.getState(); for (EssentialsSign sign : plugin.getSettings().getEnabledSigns()) { @@ -62,7 +58,6 @@ public class SignPlayerListener implements Listener { event.setCancelled(true); return; - } } } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java b/EssentialsSigns/src/net/ess3/signs/SignProtection.java index 7986e5ca2..e87002fd4 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java +++ b/EssentialsSigns/src/net/ess3/signs/SignProtection.java @@ -1,11 +1,11 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; -import net.ess3.api.ChargeException; import static net.ess3.I18n._; -import net.ess3.economy.Trade; -import net.ess3.utils.Util; +import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; +import net.ess3.utils.Util; import java.util.*; import org.bukkit.Location; import org.bukkit.Material; @@ -147,7 +147,7 @@ public class SignProtection extends EssentialsSign { return SignProtectionState.OWNER; } - if (Util.stripColor(sign.getLine(3)).equalsIgnoreCase(username)) + if (Util.stripFormat(sign.getLine(3)).equalsIgnoreCase(username)) { return SignProtectionState.OWNER; } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java b/EssentialsSigns/src/net/ess3/signs/SignSell.java index 8b1eac2c8..9a48e4948 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java +++ b/EssentialsSigns/src/net/ess3/signs/SignSell.java @@ -1,9 +1,9 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.ChargeException; -import net.ess3.economy.Trade; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; public class SignSell extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java b/EssentialsSigns/src/net/ess3/signs/SignSpawnmob.java index 057614372..47961a96e 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java +++ b/EssentialsSigns/src/net/ess3/signs/SignSpawnmob.java @@ -1,10 +1,10 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.ChargeException; -import net.ess3.economy.Trade; import net.ess3.api.IEssentials; import net.ess3.api.IUser; import net.ess3.commands.Commandspawnmob; +import net.ess3.economy.Trade; public class SignSpawnmob extends EssentialsSign @@ -22,14 +22,13 @@ public class SignSpawnmob extends EssentialsSign return true; } - //TODO: This should call a method not a command @Override protected boolean onSignInteract(ISign sign, IUser player, String username, IEssentials ess) throws SignException, ChargeException { final Trade charge = getTrade(sign, 3, ess); charge.isAffordableFor(player); - Commandspawnmob command = new Commandspawnmob(); + Commandspawnmob command = new Commandspawnmob(); command.init(ess, "spawnmob"); String[] args = new String[] { diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignTime.java b/EssentialsSigns/src/net/ess3/signs/SignTime.java index 6f56ba51e..8ef98a4d5 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignTime.java +++ b/EssentialsSigns/src/net/ess3/signs/SignTime.java @@ -1,10 +1,10 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; -import net.ess3.api.ChargeException; import static net.ess3.I18n._; -import net.ess3.economy.Trade; +import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; public class SignTime extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignTrade.java b/EssentialsSigns/src/net/ess3/signs/SignTrade.java index 15296ecc9..c3e78e226 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignTrade.java +++ b/EssentialsSigns/src/net/ess3/signs/SignTrade.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.ChargeException; import static net.ess3.I18n._; @@ -228,7 +228,7 @@ public class SignTrade extends EssentialsSign } catch (SignException e) { - throw new SignException(_("tradeSignEmpty")); + throw new SignException(_("tradeSignEmpty"), e); } } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java b/EssentialsSigns/src/net/ess3/signs/SignWarp.java index a69c2ce8e..b6dc95d0f 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java +++ b/EssentialsSigns/src/net/ess3/signs/SignWarp.java @@ -1,9 +1,9 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.ChargeException; -import net.ess3.economy.Trade; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; import net.ess3.permissions.WarpPermissions; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java b/EssentialsSigns/src/net/ess3/signs/SignWeather.java index 17d28c195..94217aeec 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java +++ b/EssentialsSigns/src/net/ess3/signs/SignWeather.java @@ -1,10 +1,10 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; -import net.ess3.api.ChargeException; import static net.ess3.I18n._; -import net.ess3.economy.Trade; +import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.economy.Trade; public class SignWeather extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java b/EssentialsSigns/src/net/ess3/signs/Signs.java index e29d45ad4..af4111dac 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java +++ b/EssentialsSigns/src/net/ess3/signs/Signs.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; public enum Signs diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java b/EssentialsSigns/src/net/ess3/signs/SignsConfig.java index d8113e36d..70b606962 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java +++ b/EssentialsSigns/src/net/ess3/signs/SignsConfig.java @@ -1,10 +1,12 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.storage.StorageObject; import java.util.HashMap; import java.util.Map; -public class SignsConfig implements StorageObject { + +public class SignsConfig implements StorageObject +{ private Map<String, Boolean> signs = new HashMap<String, Boolean>(); public Map<String, Boolean> getSigns() @@ -12,7 +14,7 @@ public class SignsConfig implements StorageObject { return signs; } - public void setSigns(Map<String, Boolean> signs) + public void setSigns(final Map<String, Boolean> signs) { this.signs = signs; } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfigHolder.java b/EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java index 274c2a1be..fce56906d 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfigHolder.java +++ b/EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.IEssentials; import net.ess3.storage.AsyncStorageObjectHolder; @@ -10,8 +10,9 @@ import org.bukkit.plugin.Plugin; public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig> { - private final Plugin plugin; + private final transient Plugin plugin; private Set<EssentialsSign> enabledSigns = new HashSet<EssentialsSign>(); + private boolean signsEnabled = false; public SignsConfigHolder(final IEssentials ess, final Plugin plugin) { @@ -21,14 +22,20 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig> acquireReadLock(); try { - Map<String, Boolean> signs = getData().getSigns(); + final Map<String, Boolean> signs = getData().getSigns(); for (Map.Entry<String, Boolean> entry : signs.entrySet()) { - Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH)); + if (entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR")) + { + signsEnabled = true; + continue; + } + final Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH)); if (sign != null && entry.getValue()) { enabledSigns.add(sign.getSign()); - } + signsEnabled = true; + } } } finally @@ -38,7 +45,7 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig> acquireWriteLock(); try { - Map<String, Boolean> signs = new HashMap<String, Boolean>(); + final Map<String, Boolean> signs = new HashMap<String, Boolean>(); for (Signs sign : Signs.values()) { signs.put(sign.toString(), enabledSigns.contains(sign.getSign())); @@ -61,4 +68,19 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig> { return enabledSigns; } + + public boolean areSignsDisabled() + { + return !signsEnabled; + } + + @Override + public void finishRead() + { + } + + @Override + public void finishWrite() + { + } } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsPermissions.java b/EssentialsSigns/src/net/ess3/signs/SignsPermissions.java index b27eb3c45..21c736b7d 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsPermissions.java +++ b/EssentialsSigns/src/net/ess3/signs/SignsPermissions.java @@ -1,4 +1,4 @@ -package com.earth2me.essentials.signs; +package net.ess3.signs; import net.ess3.api.IPermission; import net.ess3.permissions.BasePermission; diff --git a/EssentialsSigns/src/plugin.yml b/EssentialsSigns/src/plugin.yml index 7f0bda1a2..a58338c86 100644 --- a/EssentialsSigns/src/plugin.yml +++ b/EssentialsSigns/src/plugin.yml @@ -1,9 +1,9 @@ # This determines the command prefix when there are conflicts (/name:home, /name:help, etc.) name: EssentialsSigns -main: com.earth2me.essentials.signs.EssentialsSignsPlugin +main: net.ess3.signs.EssentialsSignsPlugin # Note to developers: This next line cannot change, or the automatic versioning system will break. version: ${build.number} website: http://tiny.cc/EssentialsWiki description: Provides signs, utilizing Essentials. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] -depend: [Essentials3]
\ No newline at end of file +depend: [Essentials-3]
\ No newline at end of file |