mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 18:14:38 +02: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:
@@ -1,6 +1,7 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -18,6 +19,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
|||||||
private boolean teleportRequestHere;
|
private boolean teleportRequestHere;
|
||||||
private Teleport teleport;
|
private Teleport teleport;
|
||||||
private long lastActivity;
|
private long lastActivity;
|
||||||
|
private static DecimalFormat df = new DecimalFormat("0.##");
|
||||||
|
|
||||||
User(Player base, Essentials ess)
|
User(Player base, Essentials ess)
|
||||||
{
|
{
|
||||||
@@ -84,7 +86,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMoney(getMoney() + value);
|
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
|
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);
|
setMoney(getMoney() - value);
|
||||||
reciever.setMoney(reciever.getMoney() + value);
|
reciever.setMoney(reciever.getMoney() + value);
|
||||||
sendMessage("§a$" + value + " has been sent to " + reciever.getDisplayName());
|
String d = df.format(Double.parseDouble(Double.toString(value)));
|
||||||
reciever.sendMessage("§a$" + value + " has been recieved from " + getDisplayName());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
setMoney(getMoney() - value);
|
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
|
public void charge(String cmd) throws Exception
|
||||||
|
@@ -2,11 +2,13 @@ package com.earth2me.essentials.commands;
|
|||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
public class Commandbalance extends EssentialsCommand
|
public class Commandbalance extends EssentialsCommand
|
||||||
{
|
{
|
||||||
|
private static DecimalFormat df = new DecimalFormat("0.##");
|
||||||
public Commandbalance()
|
public Commandbalance()
|
||||||
{
|
{
|
||||||
super("balance");
|
super("balance");
|
||||||
@@ -19,16 +21,18 @@ public class Commandbalance extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
String d = df.format(Double.parseDouble(Double.toString(getPlayer(server, args, 0).getMoney())));
|
||||||
sender.sendMessage("§7Balance: $" + getPlayer(server, args, 0).getMoney());
|
sender.sendMessage("§7Balance: $" + d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
charge(user);
|
charge(user);
|
||||||
user.sendMessage("§7Balance: $" + (args.length < 1 || !user.isAuthorized("essentials.balance.other")
|
double bal = (args.length < 1 || !user.isAuthorized("essentials.balance.other")
|
||||||
? user
|
? user
|
||||||
: getPlayer(server, args, 0)).getMoney());
|
: getPlayer(server, args, 0)).getMoney();
|
||||||
|
String d = df.format(Double.parseDouble(Double.toString(bal)));
|
||||||
|
user.sendMessage("§7Balance: $" + d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user