mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-17 03:54:19 +02:00
[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:
@@ -7,7 +7,7 @@ import java.util.logging.Logger;
|
|||||||
public class Worth implements IConf
|
public class Worth implements IConf
|
||||||
{
|
{
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
public EssentialsConf config;
|
private EssentialsConf config;
|
||||||
|
|
||||||
public Worth(File dataFolder)
|
public Worth(File dataFolder)
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,6 @@ public class Worth implements IConf
|
|||||||
{
|
{
|
||||||
config.setProperty("worth-" + id, price);
|
config.setProperty("worth-" + id, price);
|
||||||
config.save();
|
config.save();
|
||||||
reloadConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadConfig()
|
public void reloadConfig()
|
||||||
|
@@ -24,7 +24,7 @@ public class Commandsell extends EssentialsCommand
|
|||||||
int id = is.getTypeId();
|
int id = is.getTypeId();
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if (args.length > 0) amount = Integer.parseInt(args[0].replaceAll("[^0-9]", ""));
|
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 stack = args.length > 0 && args[0].endsWith("s");
|
||||||
boolean requireStack = parent.getConfiguration().getBoolean("trade-in-stacks-" + id, false);
|
boolean requireStack = parent.getConfiguration().getBoolean("trade-in-stacks-" + id, false);
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ public class Commandworth extends EssentialsCommand
|
|||||||
amount = 64;
|
amount = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
int worth = Essentials.getWorth().config.getInt("worth-" + id, 0);
|
int worth = Essentials.getWorth().getPrice(String.valueOf(id));
|
||||||
|
|
||||||
user.charge(this);
|
user.charge(this);
|
||||||
user.sendMessage("§7Stack of " + id + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)");
|
user.sendMessage("§7Stack of " + id + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)");
|
||||||
|
Reference in New Issue
Block a user