diff options
author | KHobbits <rob@khobbits.co.uk> | 2014-02-02 16:07:32 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2014-02-02 16:07:32 +0000 |
commit | 109c26fa8f0f015191409834b93e247d00706ae5 (patch) | |
tree | 44e4f444bf62df5cc81d357234eaaf54bbb50b6c | |
parent | 889afc80899e44798496a6edc4a622e8ed304424 (diff) | |
download | Essentials-109c26fa8f0f015191409834b93e247d00706ae5.tar Essentials-109c26fa8f0f015191409834b93e247d00706ae5.tar.gz Essentials-109c26fa8f0f015191409834b93e247d00706ae5.tar.lz Essentials-109c26fa8f0f015191409834b93e247d00706ae5.tar.xz Essentials-109c26fa8f0f015191409834b93e247d00706ae5.zip |
[Breaking] Add exception when players have exceeded their account limit.
This might effect some plugins which hook Essentials for economy without using the API
38 files changed, 151 insertions, 83 deletions
diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index a1c6ce55e..c8946c011 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import net.ess3.api.ITeleport; +import net.ess3.api.MaxMoneyException; import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -21,19 +22,15 @@ public interface IUser void healCooldown() throws Exception; - void giveMoney(BigDecimal value); - - void giveMoney(final BigDecimal value, final CommandSource initiator); - @Deprecated - void giveMoney(final BigDecimal value, final CommandSender initiator); + void giveMoney(BigDecimal value) throws MaxMoneyException; + void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException; + void payUser(final User reciever, final BigDecimal value) throws Exception; void takeMoney(BigDecimal value); void takeMoney(final BigDecimal value, final CommandSource initiator); - @Deprecated - void takeMoney(final BigDecimal value, final CommandSender initiator); boolean canAfford(BigDecimal value); @@ -49,7 +46,7 @@ public interface IUser BigDecimal getMoney(); - void setMoney(final BigDecimal value); + void setMoney(final BigDecimal value) throws MaxMoneyException; void setAfk(final boolean set); diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index f1d60f9c4..4d258156a 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -107,7 +107,7 @@ public class Teleport implements net.ess3.api.ITeleport { if (teleportee.getBase().isInsideVehicle()) { - teleportee.getBase().leaveVehicle();; + teleportee.getBase().leaveVehicle(); } teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, loc)); } @@ -120,7 +120,7 @@ public class Teleport implements net.ess3.api.ITeleport { if (teleportee.getBase().isInsideVehicle()) { - teleportee.getBase().leaveVehicle();; + teleportee.getBase().leaveVehicle(); } teleportee.getBase().teleport(loc); } diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index 5c59b0e82..dbdc430e4 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -15,6 +15,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import net.ess3.api.MaxMoneyException; import org.bukkit.Location; import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; @@ -122,12 +123,12 @@ public class Trade } } - public boolean pay(final IUser user) + public boolean pay(final IUser user) throws MaxMoneyException { return pay(user, OverflowType.ABORT) == null; } - public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type) + public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type) throws MaxMoneyException { if (getMoney() != null && getMoney().signum() > 0) { diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 29d435070..0ca5201c0 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -13,6 +13,7 @@ import java.util.GregorianCalendar; import java.util.logging.Level; import java.util.logging.Logger; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.api.events.UserBalanceUpdateEvent; import org.bukkit.ChatColor; @@ -135,13 +136,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es } @Override - public void giveMoney(final BigDecimal value) + public void giveMoney(final BigDecimal value) throws MaxMoneyException { giveMoney(value, (CommandSource)null); } @Override - public void giveMoney(final BigDecimal value, final CommandSource initiator) + public void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException { if (value.signum() == 0) { @@ -156,14 +157,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es } @Override - @Deprecated - public void giveMoney(final BigDecimal value, final CommandSender initiator) - { - giveMoney(value, new CommandSource(initiator)); - } - - @Override - public void payUser(final User reciever, final BigDecimal value) throws ChargeException + public void payUser(final User reciever, final BigDecimal value) throws ChargeException, MaxMoneyException { if (value.signum() == 0) { @@ -195,7 +189,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es { return; } - setMoney(getMoney().subtract(value)); + try + { + setMoney(getMoney().subtract(value)); + } + catch (MaxMoneyException ex) + { + //We shouldn't be able to throw an exception on subtract money + } sendMessage(_("takenFromAccount", NumberUtil.displayCurrency(value, ess))); if (initiator != null) { @@ -204,13 +205,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es } @Override - @Deprecated - public void takeMoney(final BigDecimal value, final CommandSender initiator) - { - takeMoney(value, new CommandSource(initiator)); - } - - @Override public boolean canAfford(final BigDecimal cost) { return canAfford(cost, true); @@ -441,7 +435,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es } @Override - public void setMoney(final BigDecimal value) + public void setMoney(final BigDecimal value) throws MaxMoneyException { if (ess.getSettings().isEcoDisabled()) { @@ -467,7 +461,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es { } } - super.setMoney(value); + super.setMoney(value, true); ess.getServer().getPluginManager().callEvent(new UserBalanceUpdateEvent(this.getBase(), value)); Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess); } @@ -480,7 +474,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es } if (Methods.hasMethod() && super.getMoney() != value) { - super.setMoney(value); + try + { + super.setMoney(value, false); + } + catch (MaxMoneyException ex) + { + // We don't want to throw any errors here, just updating a cache + } } } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 46025de8b..a2787972f 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -8,6 +8,7 @@ import java.math.BigDecimal; import java.util.*; import net.ess3.api.IEssentials; import net.ess3.api.InvalidWorldException; +import net.ess3.api.MaxMoneyException; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -99,7 +100,7 @@ public abstract class UserData extends PlayerExtension implements IConf return money; } - public void setMoney(BigDecimal value) + public void setMoney(BigDecimal value, boolean throwError) throws MaxMoneyException { money = value; BigDecimal maxMoney = ess.getSettings().getMaxMoney(); @@ -107,6 +108,10 @@ public abstract class UserData extends PlayerExtension implements IConf if (money.compareTo(maxMoney) > 0) { money = maxMoney; + if (throwError) + { + throw new MaxMoneyException(); + } } if (money.compareTo(minMoney) < 0) { @@ -729,13 +734,12 @@ public abstract class UserData extends PlayerExtension implements IConf return afk; } - public void _setAfk(boolean set) + public void _setAfk(boolean set) { afk = set; config.setProperty("afk", set); config.save(); } - private boolean newplayer; private String geolocation; diff --git a/Essentials/src/com/earth2me/essentials/api/Economy.java b/Essentials/src/com/earth2me/essentials/api/Economy.java index 606661b4d..1ae89e868 100644 --- a/Essentials/src/com/earth2me/essentials/api/Economy.java +++ b/Essentials/src/com/earth2me/essentials/api/Economy.java @@ -21,6 +21,7 @@ import java.math.MathContext; import java.util.logging.Level; import java.util.logging.Logger; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; /** @@ -146,7 +147,14 @@ public class Economy { throw new NoLoanPermittedException(); } - user.setMoney(balance); + try + { + user.setMoney(balance); + } + catch (MaxMoneyException ex) + { + //TODO: Update API to show max balance errors + } } /** diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java index 6f6aab6e7..dac835655 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java @@ -7,6 +7,9 @@ import com.earth2me.essentials.User; import com.earth2me.essentials.utils.NumberUtil; import java.math.BigDecimal; import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.ess3.api.MaxMoneyException; import org.bukkit.Server; @@ -56,7 +59,7 @@ public class Commandeco extends EssentialsLoopCommand } @Override - protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws NotEnoughArgumentsException, ChargeException + protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws NotEnoughArgumentsException, ChargeException, MaxMoneyException { switch (cmd) { @@ -85,7 +88,14 @@ public class Commandeco extends EssentialsLoopCommand } else if (sender == null) { - player.setMoney(minBalance); + try + { + player.setMoney(minBalance); + } + catch (MaxMoneyException ex) + { + // Take shouldn't be able to throw a max money exception + } player.sendMessage(_("takenFromAccount", NumberUtil.displayCurrency(player.getMoney(), ess))); } else @@ -94,7 +104,7 @@ public class Commandeco extends EssentialsLoopCommand } } - private void set(BigDecimal amount, final User player, final CommandSource sender) + private void set(BigDecimal amount, final User player, final CommandSource sender) throws MaxMoneyException { BigDecimal minBalance = ess.getSettings().getMinMoney(); boolean underMinimum = (amount.compareTo(minBalance) < 0); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java index 2dc95db0d..51c2d1983 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java @@ -2,9 +2,11 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.CommandSource; +import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import java.math.BigDecimal; +import net.ess3.api.MaxMoneyException; import org.bukkit.Server; @@ -33,7 +35,14 @@ public class Commandpay extends EssentialsLoopCommand protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws ChargeException { User user = ess.getUser(sender.getPlayer()); - user.payUser(player, amount); - Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess); + try + { + user.payUser(player, amount); + Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess); + } + catch (MaxMoneyException ex) + { + sender.sendMessage(_("maxMoney")); + } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java index 271636358..be30cde70 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsLoopCommand.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.User; import java.util.List; +import net.ess3.api.MaxMoneyException; import org.bukkit.Server; import org.bukkit.entity.Player; @@ -16,7 +17,7 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand } protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, boolean matchWildcards, final String searchTerm, final String[] commandArgs) - throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException + throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { if (searchTerm.isEmpty()) { @@ -70,7 +71,7 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand } protected void loopOnlinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, boolean matchWildcards, final String searchTerm, final String[] commandArgs) - throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException + throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { if (searchTerm.isEmpty()) { @@ -122,5 +123,5 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand } protected abstract void updatePlayer(Server server, CommandSource sender, User user, String[] args) - throws NotEnoughArgumentsException, PlayerExemptException, ChargeException; + throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException; } diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index 0e6d2d47c..b6af79698 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; import net.ess3.api.events.SignBreakEvent; import net.ess3.api.events.SignCreateEvent; import net.ess3.api.events.SignInteractEvent; @@ -129,7 +130,7 @@ public class EssentialsSign } } - protected final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) + protected final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) throws MaxMoneyException { final ISign sign = new BlockSign(block); final User user = ess.getUser(player); @@ -162,12 +163,12 @@ public class EssentialsSign return true; } - protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException { return true; } - protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException + protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException { return true; } @@ -208,7 +209,7 @@ public class EssentialsSign return false; } - protected final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess) + protected final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess) throws MaxMoneyException { User user = ess.getUser(player); try @@ -298,7 +299,7 @@ public class EssentialsSign return true; } - protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException + protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException { return true; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 5f51b27f1..78879b52d 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -5,6 +5,7 @@ import com.earth2me.essentials.utils.FormatUtil; import java.util.logging.Level; import java.util.logging.Logger; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -35,14 +36,20 @@ public class SignBlockListener implements Listener event.getHandlers().unregister(this); return; } - - if (protectSignsAndBlocks(event.getBlock(), event.getPlayer())) + try + { + if (protectSignsAndBlocks(event.getBlock(), event.getPlayer())) + { + event.setCancelled(true); + } + } + catch (MaxMoneyException ex) { event.setCancelled(true); } } - public boolean protectSignsAndBlocks(final Block block, final Player player) + public boolean protectSignsAndBlocks(final Block block, final Player player) throws MaxMoneyException { // prevent any signs be broken by destroying the block they are attached to if (EssentialsSign.checkIfBlockBreaksSigns(block)) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBuy.java b/Essentials/src/com/earth2me/essentials/signs/SignBuy.java index 13ed4faaf..13c7799c7 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBuy.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBuy.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; public class SignBuy extends EssentialsSign @@ -22,7 +23,7 @@ public class SignBuy extends EssentialsSign } @Override - protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException { final Trade items = getTrade(sign, 1, 2, player, ess); final Trade charge = getTrade(sign, 3, ess); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 49ad92f59..6e9166fda 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -6,6 +6,7 @@ import com.earth2me.essentials.Trade.OverflowType; import com.earth2me.essentials.utils.FormatUtil; import java.util.*; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -72,7 +73,7 @@ public class SignProtection extends EssentialsSign return false; } - private void checkIfSignsAreBroken(final Block block, final User player, final String username, final IEssentials ess) + private void checkIfSignsAreBroken(final Block block, final User player, final String username, final IEssentials ess) throws MaxMoneyException { final Map<Location, SignProtectionState> signs = getConnectedSigns(block, player, username, false); for (Map.Entry<Location, SignProtectionState> entry : signs.entrySet()) @@ -285,7 +286,7 @@ public class SignProtection extends EssentialsSign } @Override - protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException + protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException { final SignProtectionState state = isBlockProtected(block, player, username, false); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignSell.java b/Essentials/src/com/earth2me/essentials/signs/SignSell.java index 344fff61b..45fee196e 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignSell.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignSell.java @@ -5,6 +5,7 @@ import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade.OverflowType; import com.earth2me.essentials.User; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; public class SignSell extends EssentialsSign @@ -23,7 +24,7 @@ public class SignSell extends EssentialsSign } @Override - protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException { final Trade charge = getTrade(sign, 1, 2, player, ess); final Trade money = getTrade(sign, 3, ess); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index d71bf95f1..b0c644c83 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -8,6 +8,7 @@ import com.earth2me.essentials.utils.NumberUtil; import java.math.BigDecimal; import java.util.Map; import net.ess3.api.IEssentials; +import net.ess3.api.MaxMoneyException; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -39,7 +40,7 @@ public class SignTrade extends EssentialsSign } @Override - protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException { if (sign.getLine(3).substring(2).equalsIgnoreCase(username)) { @@ -115,7 +116,7 @@ public class SignTrade extends EssentialsSign } @Override - protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException + protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, MaxMoneyException { if ((sign.getLine(3).length() > 3 && sign.getLine(3).substring(2).equalsIgnoreCase(username)) || player.isAuthorized("essentials.signs.trade.override")) diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 0044899b1..68a931e66 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -534,3 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 19d55ee2c..923d77a50 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a7Nemuzes umlcet hrace, kteri nejsou pripojeni. ignoreExempt=\u00a74Nemuzes ignorovat tohoto hrace. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 1bf8ff7bf..1a857d963 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Du kan ikke g\u00f8re offline spillere tavse. ignoreExempt=\u00a74Du kan ikke ignorere den spiller. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 94c51bbbb..d9f71892c 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Du darfst abgemeldete Spieler nicht stummschalten. ignoreExempt=\u00a74Du kannst diesen Spieler nicht ignorieren. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 23bfa36f7..1482683a2 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You may not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 9e4259303..973014884 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74No puedes silenciar a jugadores que no est\u00e1n conec ignoreExempt=\u00a74No puedes ignorar a este jugador. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index f17db580d..47a07c912 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 75501508a..ea3a6b3ec 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Vous ne pouvez pas rendre muets les joueurs d\u00e9conn ignoreExempt=\u00a74Vous ne pouvez pas ignorer ce joueur. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_hu.properties b/Essentials/src/messages_hu.properties index 1a5d7e2bc..616885896 100644 --- a/Essentials/src/messages_hu.properties +++ b/Essentials/src/messages_hu.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Nem n\u00e9m\u00edthatsz le Offline j\u00e1t\u00e9kost. ignoreExempt=\u00a74Nem hagyhatod figyelmen k\u00edv\u0171l ezt a j\u00e1t\u00e9kost. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 5f34646ef..6ff83ce68 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Non puoi silenziare un giocatore che e'' offline. ignoreExempt=\u00a74Non puoi ignorare quel giocatore. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_lt.properties b/Essentials/src/messages_lt.properties index 8e679976f..e92b7151d 100644 --- a/Essentials/src/messages_lt.properties +++ b/Essentials/src/messages_lt.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Tu negali uztildyti neprisijungusiu zaideju. ignoreExempt=\u00a74Tu negali ignoruoti sio zaidejo. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index a7073e6f8..6eb7ca033 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Je mag geen offline players dempen ignoreExempt=\u00a74Je kan die speler niet negeren. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index a99a87712..d6e95a56c 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Nie mozesz wyciszyc graczy offline. ignoreExempt=\u00a74Nie mozesz ignorowac tego gracza. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 5bd875f1c..8401220c9 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74Voce nao pode silenciar jogadores desconectados. ignoreExempt=\u00a74Voce nao pode ignorar aquele jogador. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_ro.properties b/Essentials/src/messages_ro.properties index b43c4e7cd..e08f4305f 100644 --- a/Essentials/src/messages_ro.properties +++ b/Essentials/src/messages_ro.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_ru.properties b/Essentials/src/messages_ru.properties index 3e1392dba..0ee1de734 100644 --- a/Essentials/src/messages_ru.properties +++ b/Essentials/src/messages_ru.properties @@ -534,3 +534,4 @@ muteExemptOffline=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u044 ignoreExempt=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_sv.properties b/Essentials/src/messages_sv.properties index 2baec831d..96a081577 100644 --- a/Essentials/src/messages_sv.properties +++ b/Essentials/src/messages_sv.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74DU kan inte st\u00e4nga av urkopplad-spelare. ignoreExempt=\u00a74DU kan inte ignorera den spelaren. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_tr.properties b/Essentials/src/messages_tr.properties index 4ba7fde8e..3983bb7d7 100644 --- a/Essentials/src/messages_tr.properties +++ b/Essentials/src/messages_tr.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_zh.properties b/Essentials/src/messages_zh.properties index a15fa0ed7..4d92276e9 100644 --- a/Essentials/src/messages_zh.properties +++ b/Essentials/src/messages_zh.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74\u4f60\u53ef\u80fd\u65e0\u6cd5\u7981\u8a00\u5df2\u79bb\ ignoreExempt=\u00a74\u4f60\u65e0\u6cd5\u5ffd\u7565\u90a3\u4e2a\u73a9\u5bb6. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_zh_HK.properties b/Essentials/src/messages_zh_HK.properties index 22df45fd2..bd2751652 100644 --- a/Essentials/src/messages_zh_HK.properties +++ b/Essentials/src/messages_zh_HK.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/messages_zh_TW.properties b/Essentials/src/messages_zh_TW.properties index b86e2ae15..d5801b0a7 100644 --- a/Essentials/src/messages_zh_TW.properties +++ b/Essentials/src/messages_zh_TW.properties @@ -534,4 +534,4 @@ muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled. noMetaJson=JSON Metadata is not supported in this version of Bukkit. - +maxMoney=\u00a74This transaction would exceed the balance limit for this account. diff --git a/Essentials/src/net/ess3/api/MaxMoneyException.java b/Essentials/src/net/ess3/api/MaxMoneyException.java new file mode 100644 index 000000000..4ac45be5b --- /dev/null +++ b/Essentials/src/net/ess3/api/MaxMoneyException.java @@ -0,0 +1,12 @@ +package net.ess3.api; + +import static com.earth2me.essentials.I18n._; + + +public class MaxMoneyException extends Exception +{ + public MaxMoneyException() + { + super(_("maxMoney")); + } +} diff --git a/Essentials/test/com/earth2me/essentials/UserTest.java b/Essentials/test/com/earth2me/essentials/UserTest.java index 24d39cc0f..c6e59b509 100644 --- a/Essentials/test/com/earth2me/essentials/UserTest.java +++ b/Essentials/test/com/earth2me/essentials/UserTest.java @@ -2,7 +2,10 @@ package com.earth2me.essentials; import java.io.IOException; import java.math.BigDecimal; +import java.util.logging.Level; +import java.util.logging.Logger; import junit.framework.TestCase; +import net.ess3.api.MaxMoneyException; import org.bukkit.Location; import org.bukkit.World.Environment; import org.bukkit.plugin.InvalidDescriptionException; @@ -71,11 +74,19 @@ public class UserTest extends TestCase should("properly set, take, give, and get money"); User user = ess.getUser(base1); BigDecimal i = new BigDecimal("100.5"); - user.setMoney(i); - user.takeMoney(new BigDecimal(50)); - i = i.subtract(BigDecimal.valueOf(50)); - user.giveMoney(new BigDecimal(25)); - i = i.add(BigDecimal.valueOf(25)); + try + { + user.setMoney(i); + user.takeMoney(new BigDecimal(50)); + i = i.subtract(BigDecimal.valueOf(50)); + user.giveMoney(new BigDecimal(25)); + i = i.add(BigDecimal.valueOf(25)); + } + catch (MaxMoneyException ex) + { + fail(); + } + assertEquals(user.getMoney(), i); } |