mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-04 19:46:27 +00:00
Allow more currency customization.
Added currency key to messages.
This commit is contained in:
parent
b16a1f7237
commit
cbfb524195
17 changed files with 269 additions and 252 deletions
|
@ -105,10 +105,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName(), Util.formatCurrency(getMoney(), ess)));
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -144,10 +144,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName(), Util.formatCurrency(getMoney(), ess)));
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -422,11 +422,11 @@ public class Util
|
|||
}
|
||||
return is;
|
||||
}
|
||||
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatCurrency(final double value, final IEssentials ess)
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
|
@ -434,6 +434,16 @@ public class Util
|
|||
return str;
|
||||
}
|
||||
|
||||
public static String displayCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
|
||||
}
|
||||
|
||||
public static String shortCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
|
|
|
@ -249,7 +249,7 @@ public final class Economy
|
|||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.formatCurrency(amount, ess);
|
||||
return Util.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ public class Commandbalance extends EssentialsCommand
|
|||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,6 +32,6 @@ public class Commandbalance extends EssentialsCommand
|
|||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,11 +130,11 @@ public class Commandbalancetop extends EssentialsCommand
|
|||
}
|
||||
});
|
||||
|
||||
cache.getLines().add(_("serverTotal", Util.formatCurrency(totalMoney, ess)));
|
||||
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
|
||||
int pos = 1;
|
||||
for (Map.Entry<String, Double> entry : sortedEntries)
|
||||
{
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.formatCurrency(entry.getValue(), ess));
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
|
|
|
@ -160,8 +160,8 @@ public class Commandsell extends EssentialsCommand
|
|||
user.updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(_("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
|
||||
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class Commandwhois extends EssentialsCommand
|
|||
sender.sendMessage(_("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||
if (!ess.getSettings().isEcoDisabled())
|
||||
{
|
||||
sender.sendMessage(_("whoisMoney", Util.formatCurrency(user.getMoney(), ess)));
|
||||
sender.sendMessage(_("whoisMoney", Util.displayCurrency(user.getMoney(), ess)));
|
||||
}
|
||||
sender.sendMessage(user.isAfk()
|
||||
? _("whoisStatusAway")
|
||||
|
|
|
@ -51,14 +51,14 @@ public class Commandworth extends EssentialsCommand
|
|||
? _("worthMeta",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
iStack.getDurability(),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess))
|
||||
Util.displayCurrency(worth, ess))
|
||||
: _("worth",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess)));
|
||||
Util.displayCurrency(worth, ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,14 +95,14 @@ public class Commandworth extends EssentialsCommand
|
|||
? _("worthMeta",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
iStack.getDurability(),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess))
|
||||
Util.displayCurrency(worth, ess))
|
||||
: _("worth",
|
||||
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
Util.displayCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess)));
|
||||
Util.displayCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ public class EssentialsSign
|
|||
final Double money = trade.getMoney();
|
||||
if (money != null)
|
||||
{
|
||||
sign.setLine(index, Util.formatCurrency(money, ess));
|
||||
sign.setLine(index, Util.shortCurrency(money, ess));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,11 +135,11 @@ public class SignTrade extends EssentialsSign
|
|||
final Double money = getMoney(split[0]);
|
||||
if (money != null)
|
||||
{
|
||||
if (Util.formatCurrency(money, ess).length() * 2 > 15)
|
||||
if (Util.shortCurrency(money, ess).length() * 2 > 15)
|
||||
{
|
||||
throw new SignException("Line can be too long!");
|
||||
}
|
||||
sign.setLine(index, Util.formatCurrency(money, ess) + ":0");
|
||||
sign.setLine(index, Util.shortCurrency(money, ess) + ":0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public class SignTrade extends EssentialsSign
|
|||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
}
|
||||
sign.setLine(index, Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount, ess).substring(1));
|
||||
sign.setLine(index, Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(amount, ess).substring(1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ public class SignTrade extends EssentialsSign
|
|||
final Double amount = getDouble(split[1]);
|
||||
if (money != null && amount != null)
|
||||
{
|
||||
final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1);
|
||||
final String newline = Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(amount + value, ess).substring(1);
|
||||
if (newline.length() > 15)
|
||||
{
|
||||
throw new SignException("This sign is full: Line too long!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue