diff options
14 files changed, 90 insertions, 97 deletions
diff --git a/Essentials/src/net/ess3/Essentials.java b/Essentials/src/net/ess3/Essentials.java index 9d0f215a3..ef503f18a 100644 --- a/Essentials/src/net/ess3/Essentials.java +++ b/Essentials/src/net/ess3/Essentials.java @@ -335,7 +335,7 @@ public class Essentials implements IEssentials { return spawns; } - + @Override public void reload() { diff --git a/Essentials/src/net/ess3/I18n.java b/Essentials/src/net/ess3/I18n.java index 9387c3eda..678d111c5 100644 --- a/Essentials/src/net/ess3/I18n.java +++ b/Essentials/src/net/ess3/I18n.java @@ -72,7 +72,8 @@ public class I18n implements II18n public static String _(final String string, final Object... objects) { - if (instance == null) { + if (instance == null) + { return ""; } if (objects.length == 0) diff --git a/Essentials/src/net/ess3/Warps.java b/Essentials/src/net/ess3/Warps.java index 72ffc857f..38653bea8 100644 --- a/Essentials/src/net/ess3/Warps.java +++ b/Essentials/src/net/ess3/Warps.java @@ -59,7 +59,7 @@ public class Warps extends StorageObjectMap<IWarp> implements IWarps { setWarp(name, new net.ess3.storage.StoredLocation(loc)); } - + public void setWarp(final String name, final net.ess3.storage.StoredLocation loc) throws Exception { IWarp warp = getObject(name); diff --git a/EssentialsGeoIP/src/net/ess3/geoip/ConfigHolder.java b/EssentialsGeoIP/src/net/ess3/geoip/ConfigHolder.java index e37523ed7..4f6faba69 100644 --- a/EssentialsGeoIP/src/net/ess3/geoip/ConfigHolder.java +++ b/EssentialsGeoIP/src/net/ess3/geoip/ConfigHolder.java @@ -11,25 +11,25 @@ import org.bukkit.plugin.Plugin; public class ConfigHolder extends AsyncStorageObjectHolder<GeoIP> { private final transient Plugin geoip; - + public ConfigHolder(final IEssentials ess, final Plugin geoip) { super(ess, GeoIP.class); this.geoip = geoip; onReload(true); } - + @Override public File getStorageFile() throws IOException { return new File(geoip.getDataFolder(), "config.yml"); } - + @Override public void finishRead() { } - + @Override public void finishWrite() { diff --git a/EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java b/EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java index 24e38a8f3..b91f6740e 100644 --- a/EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java +++ b/EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java @@ -29,5 +29,4 @@ public class EssentialsConnect { return ess; } - }
\ No newline at end of file diff --git a/EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java index fbccc3ec6..89f808354 100644 --- a/EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java @@ -13,7 +13,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient EssentialsConnect ess = null; private transient ProtectHolder settings = null; - + @Override public void onEnable() { @@ -24,7 +24,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect enableEmergencyMode(pm); return; } - ess = new EssentialsConnect(essPlugin, this); + ess = new EssentialsConnect(essPlugin, this); final EssentialsProtectBlockListener blockListener = new EssentialsProtectBlockListener(this); pm.registerEvents(blockListener, this); @@ -48,12 +48,11 @@ 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 EssentialsConnect getEssentialsConnect() { return ess; - } + } @Override public ProtectHolder getSettings() diff --git a/EssentialsProtect/src/net/ess3/protect/Permissions.java b/EssentialsProtect/src/net/ess3/protect/Permissions.java index ae900e6c5..5edde818e 100644 --- a/EssentialsProtect/src/net/ess3/protect/Permissions.java +++ b/EssentialsProtect/src/net/ess3/protect/Permissions.java @@ -8,7 +8,7 @@ import org.bukkit.permissions.PermissionDefault; public enum Permissions implements IPermission -{ +{ ENTITYTARGET(PermissionDefault.TRUE), PVP(PermissionDefault.TRUE), PREVENTDAMAGE_FALL(PermissionDefault.FALSE), @@ -22,7 +22,7 @@ public enum Permissions implements IPermission PREVENTDAMAGE_FIRE(PermissionDefault.FALSE), PREVENTDAMAGE_DROWNING(PermissionDefault.FALSE), PREVENTDAMAGE_LIGHTNING(PermissionDefault.FALSE), - PREVENTDAMAGE_NONE(PermissionDefault.FALSE), + PREVENTDAMAGE_NONE(PermissionDefault.FALSE), USEFLINTSTEEL(PermissionDefault.TRUE); private static final String base = "essentials.protect."; private final String permission; diff --git a/EssentialsSigns/src/net/ess3/signs/EssentialsSign.java b/EssentialsSigns/src/net/ess3/signs/EssentialsSign.java index 60a76b9bd..4aa10c25a 100644 --- a/EssentialsSigns/src/net/ess3/signs/EssentialsSign.java +++ b/EssentialsSigns/src/net/ess3/signs/EssentialsSign.java @@ -1,6 +1,5 @@ package net.ess3.signs; - import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -23,12 +22,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); @@ -60,22 +59,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); @@ -96,7 +95,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); @@ -112,22 +111,22 @@ 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) { final IUser user = ess.getUserMap().getUser(player); @@ -145,7 +144,7 @@ public class EssentialsSign } return false; } - + public final boolean onBlockInteract(final Block block, final Player player, final IEssentials ess) { final IUser user = ess.getUserMap().getUser(player); @@ -163,7 +162,7 @@ public class EssentialsSign } return false; } - + public final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess) { final IUser user = ess.getUserMap().getUser(player); @@ -177,32 +176,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); @@ -231,32 +230,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(); @@ -271,7 +270,7 @@ public class EssentialsSign sign.setLine(index, FormatUtil.shortCurrency(money, ess)); } } - + protected final void validateTrade(final ISign sign, final int amountIndex, final int itemIndex, final IUser player, final IEssentials ess) throws SignException { @@ -287,7 +286,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 { @@ -305,7 +304,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(); @@ -316,7 +315,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); @@ -326,13 +325,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) @@ -340,7 +339,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 @@ -354,13 +353,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); @@ -370,7 +369,7 @@ public class EssentialsSign } return quantity; } - + protected final Double getDouble(final String line) throws SignException { try @@ -382,12 +381,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(); @@ -395,7 +394,7 @@ public class EssentialsSign { return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess); } - + final Double money = getMoney(line); if (money == null) { @@ -405,7 +404,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")) { @@ -429,89 +428,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/net/ess3/signs/SignBlockListener.java b/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java index d5cf4ff14..e7fc11d44 100644 --- a/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java +++ b/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java @@ -69,14 +69,14 @@ public class SignBlockListener implements Listener return true; } for (EssentialsSign sign : plugin.getSettings().getEnabledSigns()) + { + if (sign.getBlocks().contains(block.getType()) + && !sign.onBlockBreak(block, player, ess)) { - if (sign.getBlocks().contains(block.getType()) - && !sign.onBlockBreak(block, player, ess)) - { - LOGGER.log(Level.INFO, "A block was protected by a sign."); - return true; - } - } + LOGGER.log(Level.INFO, "A block was protected by a sign."); + return true; + } + } return false; } @@ -208,7 +208,7 @@ public class SignBlockListener implements Listener { return; } - + for (Block block : event.getBlocks()) { if (((block.getTypeId() == WALL_SIGN @@ -238,7 +238,7 @@ public class SignBlockListener implements Listener { return; } - + if (event.isSticky()) { final Block block = event.getBlock(); diff --git a/EssentialsSigns/src/net/ess3/signs/SignGameMode.java b/EssentialsSigns/src/net/ess3/signs/SignGameMode.java index e8a8e5b79..1109956ab 100644 --- a/EssentialsSigns/src/net/ess3/signs/SignGameMode.java +++ b/EssentialsSigns/src/net/ess3/signs/SignGameMode.java @@ -35,13 +35,13 @@ public class SignGameMode extends EssentialsSign { final Trade charge = getTrade(sign, 2, ess); final String mode = sign.getLine(1).trim(); - + if (mode.isEmpty()) { throw new SignException(_("invalidSignLine", 2)); } charge.isAffordableFor(player); - + //this needs to be fixed player.getPlayer().setGameMode(player.getPlayer().getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); player.sendMessage(_("gameMode", _(player.getPlayer().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getPlayer().getDisplayName())); diff --git a/EssentialsSigns/src/net/ess3/signs/SignInfo.java b/EssentialsSigns/src/net/ess3/signs/SignInfo.java index c738667b8..dd37d6462 100644 --- a/EssentialsSigns/src/net/ess3/signs/SignInfo.java +++ b/EssentialsSigns/src/net/ess3/signs/SignInfo.java @@ -1,6 +1,5 @@ package net.ess3.signs; - import java.io.IOException; import net.ess3.api.ChargeException; import net.ess3.api.IEssentials; @@ -53,6 +52,3 @@ public class SignInfo extends EssentialsSign return true; } } - - - diff --git a/EssentialsSigns/src/net/ess3/signs/SignRepair.java b/EssentialsSigns/src/net/ess3/signs/SignRepair.java index 9da4b4d3f..1610f16f8 100644 --- a/EssentialsSigns/src/net/ess3/signs/SignRepair.java +++ b/EssentialsSigns/src/net/ess3/signs/SignRepair.java @@ -23,10 +23,10 @@ public class SignRepair extends EssentialsSign { sign.setLine(1, "Hand"); } - else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand") ) + else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand")) { throw new SignException(_("invalidSignLine", 2)); - } + } validateTrade(sign, 2, ess); return true; } @@ -36,7 +36,7 @@ public class SignRepair extends EssentialsSign { final Trade charge = getTrade(sign, 2, ess); charge.isAffordableFor(player); - + Commandrepair command = new Commandrepair(); command.init(ess, "repair"); String[] args = new String[] @@ -51,7 +51,7 @@ public class SignRepair extends EssentialsSign { throw new SignException(ex.getMessage(), ex); } - charge.charge(player); + charge.charge(player); return true; } } diff --git a/EssentialsSigns/src/net/ess3/signs/SignTrade.java b/EssentialsSigns/src/net/ess3/signs/SignTrade.java index 3038cc27c..dc5129cbb 100644 --- a/EssentialsSigns/src/net/ess3/signs/SignTrade.java +++ b/EssentialsSigns/src/net/ess3/signs/SignTrade.java @@ -10,8 +10,7 @@ import org.bukkit.inventory.ItemStack; //TODO: Sell Enchantment on Trade signs? public class SignTrade extends EssentialsSign -{ - +{ public SignTrade() { super("Trade"); diff --git a/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPPPlayerListener.java b/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPPPlayerListener.java index 1e63e4e2a..647ff6ac3 100644 --- a/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPPPlayerListener.java +++ b/EssentialsXMPP/src/net/ess3/xmpp/EssentialsXMPPPlayerListener.java @@ -19,19 +19,19 @@ class EssentialsXMPPPlayerListener implements Listener this.ess = ess; } - @EventHandler(priority= EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(final PlayerJoinEvent event) { sendMessageToSpyUsers("Player " + event.getPlayer().getDisplayName() + " joined the game"); } - @EventHandler(priority= EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerChat(final PlayerChatEvent event) { sendMessageToSpyUsers(String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage())); } - @EventHandler(priority= EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerQuit(final PlayerQuitEvent event) { sendMessageToSpyUsers("Player " + event.getPlayer().getDisplayName() + " left the game"); |