[trunk] formatting monies and signs. signs still need some work to incorporate doubles

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1340 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
ementalo 2011-05-04 14:23:22 +00:00
parent c4bf23211f
commit 8647f4f955
4 changed files with 10 additions and 11 deletions

View File

@ -53,8 +53,8 @@ public class EssentialsEcoBlockListener extends BlockListener
String[] l2 = sign.getLines()[2].split("[ :-]+");
boolean m1 = l1[0].matches("\\$[0-9]+(\\.[0-9]+)?");
boolean m2 = l2[0].matches("\\$[0-9]+(\\.[0-9]+)?");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]);
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
if (q1 < 1 || q2 < 1)
@ -137,7 +137,7 @@ public class EssentialsEcoBlockListener extends BlockListener
ItemStack is = ItemDb.get(event.getLine(2));
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
{
throw new Exception("Don't buy air.");
throw new Exception("Can't buy air.");
}
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
event.setLine(3, Util.formatCurrency(price));
@ -161,8 +161,8 @@ public class EssentialsEcoBlockListener extends BlockListener
String[] l2 = event.getLines()[2].split("[ :-]+");
boolean m1 = l1[0].matches("\\$[0-9]+(\\.[0-9]+)?");
boolean m2 = l2[0].matches("\\$[0-9]+(\\.[0-9]+)?");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]);
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
r2 = r2 - r2 % q2;
if (q1 < 1 || q2 < 1 || r2 < 1)

View File

@ -260,6 +260,6 @@ public class Util
private static DecimalFormat df = new DecimalFormat("0.##");
public static String formatCurrency(double value) {
return "$"+df.format(value);
return "$"+Double.valueOf(df.format(value));
}
}

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.text.DecimalFormat;
import org.bukkit.command.CommandSender;
@ -21,8 +22,7 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
String d = df.format(Double.parseDouble(Double.toString(getPlayer(server, args, 0).getMoney())));
sender.sendMessage("§7Balance: $" + d);
sender.sendMessage("§7Balance: " + Util.formatCurrency(getPlayer(server, args, 0).getMoney()));
}
@Override
@ -32,7 +32,6 @@ public class Commandbalance extends EssentialsCommand
double bal = (args.length < 1 || !user.isAuthorized("essentials.balance.other")
? user
: getPlayer(server, args, 0)).getMoney();
String d = df.format(Double.parseDouble(Double.toString(bal)));
user.sendMessage("§7Balance: $" + d);
user.sendMessage("§7Balance: " + Util.formatCurrency(bal));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commandsocialspy extends EssentialsCommand