diff options
Diffstat (limited to 'Essentials/src')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 4 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/OfflinePlayer.java | 9 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 7 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/api/Economy.java | 13 | ||||
-rw-r--r-- | Essentials/src/config.yml | 1 |
5 files changed, 27 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index b5c819559..c99f381a6 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -58,14 +58,14 @@ public class Essentials extends JavaPlugin return settings; } - public void setupForTesting() throws IOException, InvalidDescriptionException + public void setupForTesting(Server server) throws IOException, InvalidDescriptionException { File dataFolder = File.createTempFile("essentialstest", ""); dataFolder.delete(); dataFolder.mkdir(); logger.log(Level.INFO, Util.i18n("usingTempFolderForTesting")); logger.log(Level.INFO, dataFolder.toString()); - this.initialize(null, null, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null); + this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null); settings = new Settings(dataFolder); setStatic(); } diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index 5d7104914..ab513d87b 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -25,6 +25,7 @@ public class OfflinePlayer implements Player { private final String name; private Location location = new Location(null, 0, 0, 0, 0, 0); + private World world = null; public OfflinePlayer(String name) { @@ -132,7 +133,13 @@ public class OfflinePlayer implements Player public World getWorld() { - return null; + return world; + } + + public void setLocation(Location loc) + { + location = loc; + world = loc.getWorld(); } public void teleportTo(Location lctn) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index e53162b8d..bcbed1064 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.text.MessageFormat; import java.util.Calendar; import java.util.Enumeration; @@ -270,13 +271,13 @@ public class Util } return isBlockAboveAir(world, x, y, z); } - private static DecimalFormat df = new DecimalFormat("#0.##"); + private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US)); public static String formatCurrency(double value) { String str = Essentials.getStatic().getSettings().getCurrencySymbol()+df.format(value); - if (str.endsWith(".")) { - return str.substring(0, str.length()-1); + if (str.endsWith(".00")) { + str = str.substring(0, str.length()-3); } return str; } diff --git a/Essentials/src/com/earth2me/essentials/api/Economy.java b/Essentials/src/com/earth2me/essentials/api/Economy.java index 82b3cda5c..95962d7a2 100644 --- a/Essentials/src/com/earth2me/essentials/api/Economy.java +++ b/Essentials/src/com/earth2me/essentials/api/Economy.java @@ -18,6 +18,10 @@ public class Economy private static void createNPCFile(String name) { File folder = new File(Essentials.getStatic().getDataFolder(), "userdata"); + if (!folder.exists()) + { + folder.mkdirs(); + } EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml")); npcConfig.load(); npcConfig.setProperty("npc", true); @@ -28,6 +32,10 @@ public class Economy private static void deleteNPC(String name) { File folder = new File(Essentials.getStatic().getDataFolder(), "userdata"); + if (!folder.exists()) + { + folder.mkdirs(); + } File config = new File(folder, Util.sanitizeFileName(name) + ".yml"); EssentialsConf npcConfig = new EssentialsConf(config); npcConfig.load(); @@ -235,13 +243,16 @@ public class Economy /** * Creates dummy files for a npc, if there is no player yet with that name. * @param name Name of the player + * @return true, if a new npc was created */ - public static void createNPC(String name) + public static boolean createNPC(String name) { User user = getUserByName(name); if (user == null) { createNPCFile(name); + return true; } + return false; } /** diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index ddafda644..8fffa244b 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -155,6 +155,7 @@ restricted-commands: - unbanip - togglejail - setjail + - eco.loan # Note: All items MUST be followed by a quantity! # Times are measured in seconds. |