From db8a1ca44c7c71ae81dff99842b56224266d4a57 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 16 Apr 2011 05:57:16 +0000 Subject: [PATCH] [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 --- Essentials/src/com/earth2me/essentials/Worth.java | 3 +-- .../src/com/earth2me/essentials/commands/Commandsell.java | 2 +- .../src/com/earth2me/essentials/commands/Commandworth.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index c26d1cdee..cec56408b 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -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() diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 5e5344138..d81b23c6c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -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); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index ffe1139fc..744eb181f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -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)");