mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-11 02:47:52 +01:00
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
This commit is contained in:
parent
5eeb020f01
commit
e50cb7d86a
@ -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!");
|
||||
|
@ -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;
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user