[Breaking] Add exception when players have exceeded their account limit.

This might effect some plugins which hook Essentials for economy without using the API
This commit is contained in:
KHobbits 2014-02-02 16:07:32 +00:00
parent 161862bc53
commit 882ebae257
38 changed files with 151 additions and 83 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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)
{
@ -203,13 +204,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)
{
@ -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
}
}
}

View File

@ -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;

View File

@ -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
}
}
/**

View File

@ -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);

View File

@ -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"));
}
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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))

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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"))

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -0,0 +1,12 @@
package net.ess3.api;
import static com.earth2me.essentials.I18n._;
public class MaxMoneyException extends Exception
{
public MaxMoneyException()
{
super(_("maxMoney"));
}
}

View File

@ -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);
}