diff options
author | md_5 <md_5@bigpond.com> | 2012-06-27 20:03:26 +1000 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-06-27 20:03:26 +1000 |
commit | 7bef2d3817634a4c396e61930460126dde3606ba (patch) | |
tree | addbcf9b25a818a10afb9e9363ddd4ee9145b490 | |
parent | 3d96c9caaf19cc1e6849295067d2a3ac01f05351 (diff) | |
download | Essentials-7bef2d3817634a4c396e61930460126dde3606ba.tar Essentials-7bef2d3817634a4c396e61930460126dde3606ba.tar.gz Essentials-7bef2d3817634a4c396e61930460126dde3606ba.tar.lz Essentials-7bef2d3817634a4c396e61930460126dde3606ba.tar.xz Essentials-7bef2d3817634a4c396e61930460126dde3606ba.zip |
Cleanup signs, update and xmpp, more to come.
35 files changed, 137 insertions, 184 deletions
diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java b/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java index 54266b3b9..8f8a4814a 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -22,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); @@ -59,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); @@ -86,7 +86,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 +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); @@ -111,25 +111,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 +144,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 +162,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 +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); @@ -230,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(); @@ -270,7 +270,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 +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 { @@ -304,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(); @@ -315,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); @@ -325,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) @@ -339,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 @@ -353,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); @@ -369,7 +369,7 @@ public class EssentialsSign } return quantity; } - + protected final Double getDouble(final String line) throws SignException { try @@ -381,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(); @@ -394,7 +394,7 @@ public class EssentialsSign { return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess); } - + final Double money = getMoney(line); if (money == null) { @@ -404,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")) { @@ -428,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/com/earth2me/essentials/signs/EssentialsSignsPlugin.java b/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSignsPlugin.java index 04421161e..97146439e 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSignsPlugin.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/EssentialsSignsPlugin.java @@ -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("Essentials3"); 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/com/earth2me/essentials/signs/ISignsPlugin.java b/EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java index 98030a6e6..2847ef87e 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/ISignsPlugin.java @@ -2,6 +2,8 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.api.IEssentialsModule; -public interface ISignsPlugin extends IEssentialsModule { + +public interface ISignsPlugin extends IEssentialsModule +{ SignsConfigHolder getSettings(); } diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java index 1f5951a16..dcb0ec857 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignBuy.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.api.ChargeException; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; public class SignBuy extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java index f974b2e25..222a04909 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignEnchant.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.api.ChargeException; -import com.earth2me.essentials.bukkit.Enchantments; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.bukkit.Enchantments; +import com.earth2me.essentials.economy.Trade; import java.util.Locale; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java index ac990cf32..789f9ba1f 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -28,7 +28,7 @@ public class SignEntityListener implements Listener { return; } - + for (Block block : event.blockList()) { if (((block.getTypeId() == Material.WALL_SIGN.getId() diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java index 1452d4570..b5fc54e40 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignFree.java @@ -1,13 +1,11 @@ package com.earth2me.essentials.signs; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.craftbukkit.InventoryWorkaround; +import com.earth2me.essentials.economy.Trade; import org.bukkit.Material; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java index 74fc33509..d9fdd2872 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignGameMode.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.api.ChargeException; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; import java.util.Locale; import org.bukkit.GameMode; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java index 920ff04e0..2da09e521 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignHeal.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.api.ChargeException; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; public class SignHeal extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java index b33e05a35..9ddce494f 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignKit.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.Kits; import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IEssentials; @@ -33,7 +32,7 @@ public class SignKit extends EssentialsSign { try { - ess.getKits().getKit(kitName); + ess.getKits().getKit(kitName); } catch (Exception ex) { @@ -60,9 +59,9 @@ public class SignKit extends EssentialsSign charge.isAffordableFor(player); try {; - final Kit kit = ess.getKits().getKit(kitName); - ess.getKits().checkTime(player, kit); - ess.getKits().sendKit(player,kit); + final Kit kit = ess.getKits().getKit(kitName); + ess.getKits().checkTime(player, kit); + ess.getKits().sendKit(player, kit); charge.charge(player); } catch (Exception ex) diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java index bfdacee41..3921ffc5e 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignProtection.java @@ -1,11 +1,11 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.api.ChargeException; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; -import com.earth2me.essentials.utils.Util; +import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.utils.Util; import java.util.*; import org.bukkit.Location; import org.bukkit.Material; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java index 1ec8da077..ced0e01fa 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignSell.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.api.ChargeException; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; public class SignSell extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java index 577cc7a6b..e581c8516 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignSpawnmob.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.api.ChargeException; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.commands.Commandspawnmob; +import com.earth2me.essentials.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/com/earth2me/essentials/signs/SignTime.java index 3479b70b0..d09b88d70 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignTime.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignTime.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.api.ChargeException; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; public class SignTime extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java index ba724b733..12deb86de 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignWarp.java @@ -1,9 +1,9 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.api.ChargeException; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.permissions.WarpPermissions; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java index 17f7014fb..70b5d0079 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignWeather.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.signs; -import com.earth2me.essentials.api.ChargeException; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.api.ChargeException; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; public class SignWeather extends EssentialsSign diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java b/EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java index 2cf05ee77..e29d45ad4 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/Signs.java @@ -19,7 +19,6 @@ public enum Signs TRADE(new SignTrade()), WARP(new SignWarp()), WEATHER(new SignWeather()); - private final EssentialsSign sign; private Signs(final EssentialsSign sign) diff --git a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java b/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java index c40e8f184..c9b4ccc83 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfig.java @@ -4,7 +4,9 @@ import com.earth2me.essentials.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/com/earth2me/essentials/signs/SignsConfigHolder.java index d5ece9f69..4ebbb1260 100644 --- a/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfigHolder.java +++ b/EssentialsSigns/src/com/earth2me/essentials/signs/SignsConfigHolder.java @@ -10,7 +10,7 @@ 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; @@ -22,15 +22,15 @@ 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()) { - if(entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR")) + if (entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR")) { signsEnabled = true; continue; } - Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH)); + final Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH)); if (sign != null && entry.getValue()) { enabledSigns.add(sign.getSign()); @@ -44,7 +44,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())); @@ -67,7 +67,7 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig> { return enabledSigns; } - + public boolean areSignsDisabled() { return !signsEnabled; @@ -76,12 +76,10 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig> @Override public void finishRead() { - } @Override public void finishWrite() { - } } diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java b/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java index 6cad44e4d..489c2163d 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java @@ -37,4 +37,4 @@ public class PastieUpload throw new IOException("Failed to upload to pastie.org"); } } -}
\ No newline at end of file +} diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java index 98426ce58..3d0034166 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java @@ -188,7 +188,7 @@ public class UpdateCheck private int getBukkitVersion() { final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(plugin.getServer().getVersion()); - if (versionMatch.matches()) + if (versionMatch.matches()) { return Integer.parseInt(versionMatch.group(1)); } diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java index 3d465e2e8..0659f7dbb 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.update; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.math.BigInteger; import java.security.KeyFactory; @@ -15,6 +16,7 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; +import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; @@ -25,7 +27,6 @@ public class UpdateFile private final static String UPDATE_URL = "http://goo.gl/67jev"; private final static BigInteger PUBLIC_KEY = new BigInteger("5ha6a2d4qdy17ttkg8evh74sl5a87djojwenu12k1lvy8ui6003e6l06rntczpoh99mhc3txj8mqlxw111oyy9yl7s7qpyluyzix3j1odxrxx4u52gxvyu6qiteapczkzvi7rxgeqsozz7b19rdx73a7quo9ybwpz1cr82r7x5k0pg2a73pjjsv2j1awr13azo7klrcxp9y5xxwf5qv1s3tw4zqftli18u0ek5qkbzfbgk1v5n2f11pkwwk6p0mibrn26wnjbv11vyiqgu95o7busmt6vf5q7grpcenl637w83mbin56s3asj1131b2mscj9xep3cbj7la9tgsxl5bj87vzy8sk2d34kzwqdqgh9nry43nqqus12l1stmiv184r8r3jcy8w43e8h1u1mzklldb5eytkuhayqik8l3ns04hwt8sgacvw534be8sx26qrn5s1", 36); private final transient File file; - private transient YamlConfiguration updateConfig; private final transient Plugin plugin; private final transient TreeMap<Version, VersionInfo> versions = new TreeMap<Version, VersionInfo>(); @@ -185,16 +186,14 @@ public class UpdateFile return false; } - private void readVersions() throws Exception + private void readVersions() throws FileNotFoundException, InvalidConfigurationException, IOException { - updateConfig = new YamlConfiguration(); + final YamlConfiguration updateConfig = new YamlConfiguration(); updateConfig.load(file); versions.clear(); for (String versionString : updateConfig.getKeys(false)) { - final Version version = new Version(versionString); - final VersionInfo info = new VersionInfo(updateConfig, versionString); - versions.put(version, info); + versions.put(new Version(versionString), new VersionInfo(updateConfig, versionString)); } } diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java index 9fa587f8f..3da76cc25 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java @@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.Plugin; - +// TODO: This whole thing should make use of the conversations api public class UpdateProcess implements Listener { private transient Player currentPlayer; diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java index de2c6a830..5eb3c8082 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java @@ -61,6 +61,5 @@ public class ConfigCommand extends AbstractFileCommand implements Command player.sendMessage(ex.getMessage()); } } - } } diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java index 31e9384ee..c2cc209e6 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java @@ -35,7 +35,6 @@ public class IrcBot extends PircBot try { connect(SERVER, PORT); - return; } catch (IOException ex) { diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java index 2c85c39fd..9d3279439 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java @@ -39,7 +39,7 @@ public abstract class AbstractState /** * Check if we already know the answer, so the user does not have to answer the question. - * + * * @return true, if the answer could be guessed. */ public boolean guessAnswer() @@ -49,12 +49,14 @@ public abstract class AbstractState /** * Ask the user the question. - * @param sender + * + * @param sender */ public abstract void askQuestion(Player sender); /** * React on the answer and set internal variables + * * @param answer * @return true, if the answer could be recognized as a valid answer */ diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java index 6aaed634a..7253f0d80 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java @@ -11,7 +11,7 @@ public class EssentialsChat extends AbstractYesNoState { public EssentialsChat(final StateMap states) { - super(states, EssentialsChatSettings.class, EssentialsSpawn.class); + super(states, EssentialsChatSettings.class); } @Override diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java index 6666ff371..bb53bc86b 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java @@ -7,7 +7,7 @@ public class EssentialsChatSettings extends AbstractYesNoState { public EssentialsChatSettings(final StateMap states) { - super(states, EssentialsSpawn.class); + super(states, null); } @Override diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java index a91a44787..6924a5445 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java @@ -44,4 +44,4 @@ public class EssentialsGeoIP extends AbstractYesNoState } listener.onWorkDone(); } -}
\ No newline at end of file +} diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java index ca0337d30..925d28315 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java @@ -44,4 +44,4 @@ public class EssentialsProtect extends AbstractYesNoState } listener.onWorkDone(); } -}
\ No newline at end of file +} diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java deleted file mode 100644 index 2a87638ba..000000000 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.earth2me.essentials.update.states; - -import com.earth2me.essentials.update.AbstractWorkListener; -import com.earth2me.essentials.update.tasks.InstallModule; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - - -public class EssentialsSpawn extends AbstractYesNoState -{ - public EssentialsSpawn(final StateMap states) - { - super(states, null); - } - - @Override - public boolean guessAnswer() - { - final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsSpawn"); - if (plugin != null) - { - setAnswer(true); - return true; - } - return false; - } - - @Override - public void askQuestion(final Player sender) - { - sender.sendMessage("Do you want to install EssentialsSpawn? (yes/no)"); - sender.sendMessage("EssentialsSpawn lets you control player spawning"); - sender.sendMessage("It allows you to set different places where players spawn on death, new players join and allows players to return to spawn."); - } - - @Override - public void doWork(final AbstractWorkListener listener) - { - if (getAnswer()) - { - new InstallModule(listener, "EssentialsSpawn").start(); - return; - } - listener.onWorkDone(); - } -}
\ No newline at end of file diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java index 194d7e98e..4c3fd8f0a 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java @@ -6,11 +6,16 @@ import org.bukkit.event.HandlerList; public class InstallationFinishedEvent extends Event { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java index 5da4d8f93..0a82d31dd 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java @@ -37,4 +37,4 @@ public class Commandxmppspy extends EssentialsCommand } } } -}
\ No newline at end of file +} diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java index fea8dd2e2..8514d5046 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java @@ -1,10 +1,10 @@ package com.earth2me.essentials.xmpp; -import com.earth2me.essentials.commands.EssentialsCommandHandler; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ICommandHandler; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.commands.EssentialsCommandHandler; import java.util.List; import java.util.Locale; import java.util.logging.Level; @@ -55,7 +55,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP ess.addReloadListener(users); ess.addReloadListener(xmpp); - + commandHandler = new EssentialsCommandHandler(EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials.", ess); } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index 5ea94eab9..c1b1b347f 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -11,14 +11,14 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import org.jivesoftware.smack.Roster.SubscriptionMode; import org.jivesoftware.smack.*; +import org.jivesoftware.smack.Roster.SubscriptionMode; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.util.StringUtils; -public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload +public final class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload { private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient YamlConfiguration config = null; @@ -132,7 +132,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager } } - public final void disconnect() + public void disconnect() { if (loggerThread != null) { @@ -165,7 +165,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager } @Override - public final void onReload() + public void onReload() { LOGGER.removeHandler(this); config = YamlConfiguration.loadConfiguration(new File(parent.getDataFolder(), "config.yml")); |