Fixed ugly decimals in messages and in balance.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1308 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
xeology 2011-05-02 01:23:57 +00:00
parent b986a3d503
commit 037473d13b
2 changed files with 17 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
@ -18,6 +19,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo
private boolean teleportRequestHere;
private Teleport teleport;
private long lastActivity;
private static DecimalFormat df = new DecimalFormat("0.##");
User(Player base, Essentials ess)
{
@ -84,7 +86,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo
return;
}
setMoney(getMoney() + value);
sendMessage("§a$" + value + " has been added to your account.");
String d = df.format(Double.parseDouble(Double.toString(value)));
sendMessage("§a$" + d + " has been added to your account.");
}
public void payUser(User reciever, double value) throws Exception
@ -101,8 +104,9 @@ public class User extends UserData implements Comparable<User>, IReplyTo
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage("§a$" + value + " has been sent to " + reciever.getDisplayName());
reciever.sendMessage("§a$" + value + " has been recieved from " + getDisplayName());
String d = df.format(Double.parseDouble(Double.toString(value)));
sendMessage("§a$" + d + " has been sent to " + reciever.getDisplayName());
reciever.sendMessage("§a$" + d + " has been recieved from " + getDisplayName());
}
}
@ -113,7 +117,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo
return;
}
setMoney(getMoney() - value);
sendMessage("§c$" + value + " has been taken from your account.");
String d = df.format(Double.parseDouble(Double.toString(value)));
sendMessage("§c$" + d + " has been taken from your account.");
}
public void charge(String cmd) throws Exception

View File

@ -2,11 +2,13 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import java.text.DecimalFormat;
import org.bukkit.command.CommandSender;
public class Commandbalance extends EssentialsCommand
{
private static DecimalFormat df = new DecimalFormat("0.##");
public Commandbalance()
{
super("balance");
@ -19,16 +21,18 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage("§7Balance: $" + getPlayer(server, args, 0).getMoney());
String d = df.format(Double.parseDouble(Double.toString(getPlayer(server, args, 0).getMoney())));
sender.sendMessage("§7Balance: $" + d);
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
user.sendMessage("§7Balance: $" + (args.length < 1 || !user.isAuthorized("essentials.balance.other")
double bal = (args.length < 1 || !user.isAuthorized("essentials.balance.other")
? user
: getPlayer(server, args, 0)).getMoney());
: getPlayer(server, args, 0)).getMoney();
String d = df.format(Double.parseDouble(Double.toString(bal)));
user.sendMessage("§7Balance: $" + d);
}
}