summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-15 02:07:20 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-15 02:07:20 +0000
commitb691348223e45d12da99f740377eed053de3f05e (patch)
tree305dd39e6310f7afd92fab89c7a61951c5c93140
parent22def57fa6c17caf59abbee2716d539c96b689bb (diff)
downloadEssentials-b691348223e45d12da99f740377eed053de3f05e.tar
Essentials-b691348223e45d12da99f740377eed053de3f05e.tar.gz
Essentials-b691348223e45d12da99f740377eed053de3f05e.tar.lz
Essentials-b691348223e45d12da99f740377eed053de3f05e.tar.xz
Essentials-b691348223e45d12da99f740377eed053de3f05e.zip
Fix money and amount display of all signs
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1472 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java20
4 files changed, 28 insertions, 28 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
index 946f72487..495a3c619 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
@@ -86,11 +86,11 @@ public class EssentialsBlockListener extends BlockListener
if (!event.getLine(1).isEmpty())
{
String[] l1 = event.getLine(1).split("[ :-]+", 2);
- boolean m1 = l1[0].matches("\\$[0-9]+");
- int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
- if (q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
+ boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
+ double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
+ if (q1 < 1 || (!m1 && (int)q1 < 1)) throw new Exception(Util.i18n("moreThanZero"));
if (!m1) ItemDb.get(l1[1]);
- event.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]));
+ event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
}
event.setLine(0, "§1[Heal]");
}
@@ -127,11 +127,11 @@ public class EssentialsBlockListener extends BlockListener
if (!event.getLine(3).isEmpty())
{
String[] l1 = event.getLine(3).split("[ :-]+", 2);
- boolean m1 = l1[0].matches("\\$[0-9]+");
- int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
- if (q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
+ boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
+ double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
+ if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
if (!m1) ItemDb.get(l1[1]);
- event.setLine(3, (m1 ? "$" + q1 : q1 + " " + l1[1]));
+ event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
}
if (event.getLine(1).isEmpty()) {
event.setLine(1, "§dWarp name here!");
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java
index b27c67a1d..874e2a5f0 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java
@@ -165,7 +165,7 @@ public class EssentialsEcoBlockListener extends BlockListener
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
r2 = m2 ? r2 : r2 - r2 % q2;
- if ((!m1 & q1 < 1) || (!m2 &q2 < 1) || r2 < 1)
+ if ((!m1 & q1 < 1) || (!m2 & q2 < 1) || r2 < 1)
{
throw new Exception(Util.i18n("moreThanZero"));
}
@@ -195,16 +195,16 @@ public class EssentialsEcoBlockListener extends BlockListener
}
event.setLine(0, "§1[Trade]");
- event.setLine(1, (m1 ? ess.getSettings().getCurrencySymbol() + q1 : String.format("%.0f",q1) + " " + l1[1]) + ":0");
- event.setLine(2, (m2 ? ess.getSettings().getCurrencySymbol() + q2 : String.format("%.0f", q2)+ " " + l2[1]) + ":" + String.format("%.0f",r2));
+ event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":0");
+ event.setLine(2, (m2 ? Util.formatCurrency(q2) : (int)q2 + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : (int)r2));
event.setLine(3, "§8" + username);
}
catch (Throwable ex)
{
user.sendMessage("§cError: " + ex.getMessage());
event.setLine(0, "§4[Trade]");
- event.setLine(1, "# ItemOr"+ess.getSettings().getCurrencySymbol());
- event.setLine(2, "# ItemOr"+ess.getSettings().getCurrencySymbol()+":#");
+ event.setLine(1, "# ItemOr" + ess.getSettings().getCurrencySymbol());
+ event.setLine(2, "# ItemOr" + ess.getSettings().getCurrencySymbol() + ":#");
event.setLine(3, "§8" + username);
}
return;
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java
index 8065cb9a4..d420c29c5 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java
@@ -71,7 +71,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener
int amount = Integer.parseInt(sign.getLine(1));
ItemStack item = ItemDb.get(sign.getLine(2), amount);
double cost = Double.parseDouble(sign.getLine(3).substring(1));
-
+
if (!InventoryWorkaround.containsItem(user.getInventory(), true, item))
{
throw new Exception(Util.format("missingItems", amount, sign.getLine(2)));
@@ -126,7 +126,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener
user.updateInventory();
}
r1 = 0;
- sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + r1);
+ sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":0");
sign.update();
}
else
@@ -177,11 +177,11 @@ public class EssentialsEcoPlayerListener extends PlayerListener
r1 += q1;
r2 -= q2;
-
+
sign.setLine(0, "§1[Trade]");
- sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + String.format((m1 ? "%.2f" : "%.0f"), Util.roundDouble(r1)));
- sign.setLine(2, (m2 ? Util.formatCurrency(q2) : ((int)q2) + " " + l2[1]) + ":" + String.format((m2 ? "%.2f" : "%.0f"), Util.roundDouble(r2)));
+ sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + (m1 ? Util.roundDouble(r1) : (int)r1));
+ sign.setLine(2, (m2 ? Util.formatCurrency(q2) : ((int)q2) + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : (int)r2));
sign.update();
user.sendMessage(Util.i18n("tradeCompleted"));
}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 8022d9f46..59d577053 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -388,9 +388,9 @@ public class EssentialsPlayerListener extends PlayerListener
if (!sign.getLine(1).isEmpty())
{
String[] l1 = sign.getLine(1).split("[ :-]+");
- boolean m1 = l1[0].matches("\\$[0-9]+");
- int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
- if (q1 < 1)
+ boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
+ double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
+ if (!m1 && (int)q1 < 1)
{
throw new Exception(Util.i18n("moreThanZero"));
}
@@ -405,10 +405,10 @@ public class EssentialsPlayerListener extends PlayerListener
}
else
{
- ItemStack i = ItemDb.get(l1[1], q1);
+ ItemStack i = ItemDb.get(l1[1], (int)q1);
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i))
{
- throw new Exception(Util.format("missingItems", q1, l1[1]));
+ throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
}
InventoryWorkaround.removeItem(user.getInventory(), true, i);
user.updateInventory();
@@ -476,9 +476,9 @@ public class EssentialsPlayerListener extends PlayerListener
if (!sign.getLine(3).isEmpty())
{
String[] l1 = sign.getLine(3).split("[ :-]+");
- boolean m1 = l1[0].matches("\\$[0-9]+");
- int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
- if (q1 < 1)
+ boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
+ double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
+ if (!m1 && (int)q1 < 1)
{
throw new Exception(Util.i18n("moreThanZero"));
}
@@ -493,10 +493,10 @@ public class EssentialsPlayerListener extends PlayerListener
}
else
{
- ItemStack i = ItemDb.get(l1[1], q1);
+ ItemStack i = ItemDb.get(l1[1], (int)q1);
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i))
{
- throw new Exception(Util.format("missingItems", q1, l1[1]));
+ throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
}
InventoryWorkaround.removeItem(user.getInventory(), true, i);
user.updateInventory();