mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
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:
parent
b986a3d503
commit
037473d13b
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user