diff options
author | ementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-04 14:23:22 +0000 |
---|---|---|
committer | ementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-04 14:23:22 +0000 |
commit | 337e3e8277a5e6d4daae74eedceb429d72336256 (patch) | |
tree | 7238c5db4d9da4d4332a38557a2bb51e7fc5c3de | |
parent | 88ee42d0890dcad66a2b47a61b8c9209bcda0489 (diff) | |
download | Essentials-337e3e8277a5e6d4daae74eedceb429d72336256.tar Essentials-337e3e8277a5e6d4daae74eedceb429d72336256.tar.gz Essentials-337e3e8277a5e6d4daae74eedceb429d72336256.tar.lz Essentials-337e3e8277a5e6d4daae74eedceb429d72336256.tar.xz Essentials-337e3e8277a5e6d4daae74eedceb429d72336256.zip |
[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
4 files changed, 10 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java index 8c1eca6d8..c8266e910 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java @@ -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) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index ddcfe1522..639af97b0 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -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)); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java index 2957e2d5c..d2c847abb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java @@ -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)); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java index 6e43d0d2e..e3233dc9f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java @@ -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 |