mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 20:43:11 +00:00
[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:
parent
c4bf23211f
commit
8647f4f955
4 changed files with 10 additions and 11 deletions
|
@ -53,8 +53,8 @@ public class EssentialsEcoBlockListener extends BlockListener
|
||||||
String[] l2 = sign.getLines()[2].split("[ :-]+");
|
String[] l2 = sign.getLines()[2].split("[ :-]+");
|
||||||
boolean m1 = l1[0].matches("\\$[0-9]+(\\.[0-9]+)?");
|
boolean m1 = l1[0].matches("\\$[0-9]+(\\.[0-9]+)?");
|
||||||
boolean m2 = l2[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]);
|
int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
|
||||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]);
|
||||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||||
if (q1 < 1 || q2 < 1)
|
if (q1 < 1 || q2 < 1)
|
||||||
|
@ -137,7 +137,7 @@ public class EssentialsEcoBlockListener extends BlockListener
|
||||||
ItemStack is = ItemDb.get(event.getLine(2));
|
ItemStack is = ItemDb.get(event.getLine(2));
|
||||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
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\\.]", ""));
|
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||||
event.setLine(3, Util.formatCurrency(price));
|
event.setLine(3, Util.formatCurrency(price));
|
||||||
|
@ -161,8 +161,8 @@ public class EssentialsEcoBlockListener extends BlockListener
|
||||||
String[] l2 = event.getLines()[2].split("[ :-]+");
|
String[] l2 = event.getLines()[2].split("[ :-]+");
|
||||||
boolean m1 = l1[0].matches("\\$[0-9]+(\\.[0-9]+)?");
|
boolean m1 = l1[0].matches("\\$[0-9]+(\\.[0-9]+)?");
|
||||||
boolean m2 = l2[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]);
|
int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
|
||||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]);
|
||||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||||
r2 = r2 - r2 % q2;
|
r2 = r2 - r2 % q2;
|
||||||
if (q1 < 1 || q2 < 1 || r2 < 1)
|
if (q1 < 1 || q2 < 1 || r2 < 1)
|
||||||
|
|
|
@ -260,6 +260,6 @@ public class Util
|
||||||
|
|
||||||
private static DecimalFormat df = new DecimalFormat("0.##");
|
private static DecimalFormat df = new DecimalFormat("0.##");
|
||||||
public static String formatCurrency(double value) {
|
public static String formatCurrency(double value) {
|
||||||
return "$"+df.format(value);
|
return "$"+Double.valueOf(df.format(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@ -21,8 +22,7 @@ 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: " + Util.formatCurrency(getPlayer(server, args, 0).getMoney()));
|
||||||
sender.sendMessage("§7Balance: $" + d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +32,6 @@ public class Commandbalance extends EssentialsCommand
|
||||||
double bal = (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: " + Util.formatCurrency(bal));
|
||||||
user.sendMessage("§7Balance: $" + d);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
|
|
||||||
public class Commandsocialspy extends EssentialsCommand
|
public class Commandsocialspy extends EssentialsCommand
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue