[trunk] /worth: don't access config directly, don't reload config after save and use getPrice() method.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1208 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
snowleo 2011-04-16 05:57:16 +00:00
parent fc9a9c2b9f
commit 31dc8694b6
3 changed files with 3 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import java.util.logging.Logger;
public class Worth implements IConf
{
private static final Logger logger = Logger.getLogger("Minecraft");
public EssentialsConf config;
private EssentialsConf config;
public Worth(File dataFolder)
{
@ -25,7 +25,6 @@ public class Worth implements IConf
{
config.setProperty("worth-" + id, price);
config.save();
reloadConfig();
}
public void reloadConfig()

View File

@ -24,7 +24,7 @@ public class Commandsell extends EssentialsCommand
int id = is.getTypeId();
int amount = 0;
if (args.length > 0) amount = Integer.parseInt(args[0].replaceAll("[^0-9]", ""));
int worth = Essentials.getWorth().config.getInt("worth-" + id, 0);
int worth = Essentials.getWorth().getPrice(String.valueOf(id));
boolean stack = args.length > 0 && args[0].endsWith("s");
boolean requireStack = parent.getConfiguration().getBoolean("trade-in-stacks-" + id, false);

View File

@ -40,7 +40,7 @@ public class Commandworth extends EssentialsCommand
amount = 64;
}
int worth = Essentials.getWorth().config.getInt("worth-" + id, 0);
int worth = Essentials.getWorth().getPrice(String.valueOf(id));
user.charge(this);
user.sendMessage("§7Stack of " + id + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)");