From ff5a82a14cbffbbd65e9baefb09d2c95305124c1 Mon Sep 17 00:00:00 2001 From: ementalo Date: Wed, 6 Jun 2012 01:53:34 +0100 Subject: 2.9 -> 3.0 merge --- Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Essentials2Compat') diff --git a/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java index 97338579d..865af41e3 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -696,7 +696,8 @@ public class EssentialsUpgrade { return; } - ess.getSettings().setMetricsEnabled(false); + //todo - metrics + // ess.getSettings().setMetricsEnabled(false); doneFile.setProperty("warnMetrics", true); doneFile.save(); } -- cgit v1.2.3 From 06f54fdbac1874c549b5181d92b4a9474da55dcc Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 27 Jun 2012 20:27:27 +1000 Subject: That just leaves the big ol' core. Largely ignore Compat as it is very temporary. --- .../src/com/earth2me/essentials/Essentials.java | 8 +- .../com/earth2me/essentials/EssentialsUpgrade.java | 105 ++++++++++----------- .../src/com/earth2me/essentials/api/Economy.java | 27 ++++-- 3 files changed, 72 insertions(+), 68 deletions(-) (limited to 'Essentials2Compat') diff --git a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java index dc612e8d6..840ef7d37 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java +++ b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java @@ -9,14 +9,8 @@ public class Essentials extends JavaPlugin @Override public void onEnable() { - Bukkit.getLogger().info("You can remove this compatibility plugin, when all plugins are updated to Essentials 3"); + Bukkit.getLogger().info("You can remove this compatibility plugin, when all plugins are updated to Essentials-3"); //TODO: Update files to new 3.0 format //TODO: Move Eco Api here } - - @Override - public void onDisable() - { - throw new UnsupportedOperationException("Not supported yet."); - } } diff --git a/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java index 865af41e3..d912caf7e 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -386,7 +386,6 @@ public class EssentialsUpgrade * ((Number)vals.get(4)).floatValue())); } } } } usersFile.renameTo(new File(usersFile.getAbsolutePath() + ".old")); * } */ - private void convertWarps() { final File warpsFolder = new File(ess.getDataFolder(), "warps"); @@ -461,56 +460,56 @@ public class EssentialsUpgrade } /*final File warpFile = new File(ess.getDataFolder(), "warps.txt"); - if (warpFile.exists()) - { - try - { - final BufferedReader rx = new BufferedReader(new FileReader(warpFile)); - try - { - for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":")) - { - if (parts.length < 6) - { - continue; - } - final String name = parts[0]; - final double x = Double.parseDouble(parts[1].trim()); - final double y = Double.parseDouble(parts[2].trim()); - final double z = Double.parseDouble(parts[3].trim()); - final float yaw = Float.parseFloat(parts[4].trim()); - final float pitch = Float.parseFloat(parts[5].trim()); - if (name.isEmpty()) - { - continue; - } - World w = null; - for (World world : ess.getServer().getWorlds()) - { - if (world.getEnvironment() != World.Environment.NETHER) - { - w = world; - break; - } - } - final Location loc = new Location(name, x, y, z, yaw, pitch); - ess.getWarps().setWarp(name, loc); - if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old"))) - { - throw new Exception(_("fileRenameError", "warps.txt")); - } - } - } - finally - { - rx.close(); - } - } - catch (Exception ex) - { - LOGGER.log(Level.SEVERE, null, ex); - } - }*/ + if (warpFile.exists()) + { + try + { + final BufferedReader rx = new BufferedReader(new FileReader(warpFile)); + try + { + for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":")) + { + if (parts.length < 6) + { + continue; + } + final String name = parts[0]; + final double x = Double.parseDouble(parts[1].trim()); + final double y = Double.parseDouble(parts[2].trim()); + final double z = Double.parseDouble(parts[3].trim()); + final float yaw = Float.parseFloat(parts[4].trim()); + final float pitch = Float.parseFloat(parts[5].trim()); + if (name.isEmpty()) + { + continue; + } + World w = null; + for (World world : ess.getServer().getWorlds()) + { + if (world.getEnvironment() != World.Environment.NETHER) + { + w = world; + break; + } + } + final Location loc = new Location(name, x, y, z, yaw, pitch); + ess.getWarps().setWarp(name, loc); + if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old"))) + { + throw new Exception(_("fileRenameError", "warps.txt")); + } + } + } + finally + { + rx.close(); + } + } + catch (Exception ex) + { + LOGGER.log(Level.SEVERE, null, ex); + } + }*/ } /* @@ -532,7 +531,7 @@ public class EssentialsUpgrade * ess.getDataFolder().getParentFile().getParentFile(); final File worldDirectory = new File(bukkitDirectory, name); * if (worldDirectory.exists() && worldDirectory.isDirectory()) { return new FakeWorld(worldDirectory.getName(), * World.Environment.NORMAL); } return null; - } + } */ public Location getFakeLocation(EssentialsConf config, String path) { @@ -697,7 +696,7 @@ public class EssentialsUpgrade return; } //todo - metrics - // ess.getSettings().setMetricsEnabled(false); + // ess.getSettings().setMetricsEnabled(false); doneFile.setProperty("warnMetrics", true); doneFile.save(); } diff --git a/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java b/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java index cf8cb640c..663c451c6 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java +++ b/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java @@ -4,8 +4,7 @@ import com.earth2me.essentials.utils.Util; /** - * Instead of using this api directly, we recommend to use the register plugin: - * http://bit.ly/RegisterMethod + * Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod */ public final class Economy { @@ -17,9 +16,10 @@ public final class Economy /** * Returns the balance of a user + * * @param name Name of the user * @return balance - * @throws UserDoesNotExistException + * @throws UserDoesNotExistException */ public static double getMoney(String name) throws UserDoesNotExistException { @@ -32,6 +32,7 @@ public final class Economy /** * Sets the balance of a user + * * @param name Name of the user * @param balance The balance you want to set * @throws UserDoesNotExistException If a user by that name does not exists @@ -48,6 +49,7 @@ public final class Economy /** * Adds money to the balance of a user + * * @param name Name of the user * @param amount The money you want to add * @throws UserDoesNotExistException If a user by that name does not exists @@ -61,6 +63,7 @@ public final class Economy /** * Substracts money from the balance of a user + * * @param name Name of the user * @param amount The money you want to substract * @throws UserDoesNotExistException If a user by that name does not exists @@ -74,6 +77,7 @@ public final class Economy /** * Divides the balance of a user by a value + * * @param name Name of the user * @param value The balance is divided by this value * @throws UserDoesNotExistException If a user by that name does not exists @@ -87,6 +91,7 @@ public final class Economy /** * Multiplies the balance of a user by a value + * * @param name Name of the user * @param value The balance is multiplied by this value * @throws UserDoesNotExistException If a user by that name does not exists @@ -100,6 +105,7 @@ public final class Economy /** * Resets the balance of a user to the starting balance + * * @param name Name of the user * @throws UserDoesNotExistException If a user by that name does not exists * @throws NoLoanPermittedException If the user is not allowed to have a negative balance @@ -148,6 +154,7 @@ public final class Economy /** * Test if the user has a negative balance + * * @param name Name of the user * @return true, if the user has a negative balance * @throws UserDoesNotExistException If a user by that name does not exists @@ -158,8 +165,8 @@ public final class Economy } /** - * Formats the amount of money like all other Essentials functions. - * Example: $100000 or $12345.67 + * Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67 + * * @param amount The amount of money * @return Formatted money */ @@ -174,6 +181,7 @@ public final class Economy /** * Test if a player exists to avoid the UserDoesNotExistException + * * @param name Name of the user * @return true, if the user exists */ @@ -188,9 +196,10 @@ public final class Economy /** * Test if a player is a npc + * * @param name Name of the player * @return true, if it's a npc - * @throws UserDoesNotExistException + * @throws UserDoesNotExistException */ public static boolean isNPC(String name) throws UserDoesNotExistException { @@ -203,6 +212,7 @@ public final 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 */ @@ -216,9 +226,10 @@ public final class Economy } /** - * Deletes a user, if it is marked as npc. + * Deletes a user, if it is marked as npc. + * * @param name Name of the player - * @throws UserDoesNotExistException + * @throws UserDoesNotExistException */ public static void removeNPC(String name) throws UserDoesNotExistException { -- cgit v1.2.3 From 6123f17ef45136089837ba891c34be2ace5fd012 Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 27 Jun 2012 13:54:13 +0200 Subject: Renamed plugin from Essentials3 to Essentials-3 --- Essentials2Compat/src/plugin.yml | 1 + 1 file changed, 1 insertion(+) (limited to 'Essentials2Compat') diff --git a/Essentials2Compat/src/plugin.yml b/Essentials2Compat/src/plugin.yml index e3d9afe83..5610b82a4 100644 --- a/Essentials2Compat/src/plugin.yml +++ b/Essentials2Compat/src/plugin.yml @@ -4,3 +4,4 @@ version: 2.9 website: http://tiny.cc/EssentialsWiki description: Compatibility plugin for older plugins authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] +depend: [Essentials-3] -- cgit v1.2.3 From 16d0b5c228dd8d981a0d79944c70248ea813d63b Mon Sep 17 00:00:00 2001 From: ementalo Date: Wed, 27 Jun 2012 13:35:39 +0100 Subject: package name change to net.ess3 --- .../src/com/earth2me/essentials/Economy.java | 245 +++++++++++++++++++++ .../com/earth2me/essentials/EssentialsConf.java | 2 +- .../com/earth2me/essentials/EssentialsUpgrade.java | 17 +- .../src/com/earth2me/essentials/api/Economy.java | 242 -------------------- Essentials2Compat/src/plugin.yml | 2 +- 5 files changed, 256 insertions(+), 252 deletions(-) create mode 100644 Essentials2Compat/src/com/earth2me/essentials/Economy.java delete mode 100644 Essentials2Compat/src/com/earth2me/essentials/api/Economy.java (limited to 'Essentials2Compat') diff --git a/Essentials2Compat/src/com/earth2me/essentials/Economy.java b/Essentials2Compat/src/com/earth2me/essentials/Economy.java new file mode 100644 index 000000000..bf1c9a61d --- /dev/null +++ b/Essentials2Compat/src/com/earth2me/essentials/Economy.java @@ -0,0 +1,245 @@ +package com.earth2me.essentials; + +import net.ess3.api.IEssentials; +import net.ess3.api.NoLoanPermittedException; +import net.ess3.api.UserDoesNotExistException; +import net.ess3.utils.Util; + + +/** + * Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod + */ +public final class Economy +{ + private Economy() + { + } + private static IEssentials ess; + private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded."; + + /** + * Returns the balance of a user + * + * @param name Name of the user + * @return balance + * @throws net.ess3.api.UserDoesNotExistException + */ + public static double getMoney(String name) throws UserDoesNotExistException + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return ess.getEconomy().getMoney(name); + } + + /** + * Sets the balance of a user + * + * @param name Name of the user + * @param balance The balance you want to set + * @throws UserDoesNotExistException If a user by that name does not exists + * @throws net.ess3.api.NoLoanPermittedException If the user is not allowed to have a negative balance + */ + public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + ess.getEconomy().setMoney(name, balance); + } + + /** + * Adds money to the balance of a user + * + * @param name Name of the user + * @param amount The money you want to add + * @throws UserDoesNotExistException If a user by that name does not exists + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + */ + public static void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException + { + double result = getMoney(name) + amount; + setMoney(name, result); + } + + /** + * Substracts money from the balance of a user + * + * @param name Name of the user + * @param amount The money you want to substract + * @throws UserDoesNotExistException If a user by that name does not exists + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + */ + public static void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException + { + double result = getMoney(name) - amount; + setMoney(name, result); + } + + /** + * Divides the balance of a user by a value + * + * @param name Name of the user + * @param value The balance is divided by this value + * @throws UserDoesNotExistException If a user by that name does not exists + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + */ + public static void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException + { + double result = getMoney(name) / value; + setMoney(name, result); + } + + /** + * Multiplies the balance of a user by a value + * + * @param name Name of the user + * @param value The balance is multiplied by this value + * @throws UserDoesNotExistException If a user by that name does not exists + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + */ + public static void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException + { + double result = getMoney(name) * value; + setMoney(name, result); + } + + /** + * Resets the balance of a user to the starting balance + * + * @param name Name of the user + * @throws UserDoesNotExistException If a user by that name does not exists + * @throws NoLoanPermittedException If the user is not allowed to have a negative balance + */ + public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + ess.getEconomy().resetBalance(name); + } + + /** + * @param name Name of the user + * @param amount The amount of money the user should have + * @return true, if the user has more or an equal amount of money + * @throws UserDoesNotExistException If a user by that name does not exists + */ + public static boolean hasEnough(String name, double amount) throws UserDoesNotExistException + { + return amount <= getMoney(name); + } + + /** + * @param name Name of the user + * @param amount The amount of money the user should have + * @return true, if the user has more money + * @throws UserDoesNotExistException If a user by that name does not exists + */ + public static boolean hasMore(String name, double amount) throws UserDoesNotExistException + { + return amount < getMoney(name); + } + + /** + * @param name Name of the user + * @param amount The amount of money the user should not have + * @return true, if the user has less money + * @throws UserDoesNotExistException If a user by that name does not exists + */ + public static boolean hasLess(String name, double amount) throws UserDoesNotExistException + { + return amount > getMoney(name); + } + + /** + * Test if the user has a negative balance + * + * @param name Name of the user + * @return true, if the user has a negative balance + * @throws UserDoesNotExistException If a user by that name does not exists + */ + public static boolean isNegative(String name) throws UserDoesNotExistException + { + return getMoney(name) < 0.0; + } + + /** + * Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67 + * + * @param amount The amount of money + * @return Formatted money + */ + public static String format(double amount) + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return Util.displayCurrency(amount, ess); + } + + /** + * Test if a player exists to avoid the UserDoesNotExistException + * + * @param name Name of the user + * @return true, if the user exists + */ + public static boolean playerExists(String name) + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return ess.getEconomy().playerExists(name); + } + + /** + * Test if a player is a npc + * + * @param name Name of the player + * @return true, if it's a npc + * @throws UserDoesNotExistException + */ + public static boolean isNPC(String name) throws UserDoesNotExistException + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return ess.getEconomy().isNPC(name); + } + + /** + * 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 boolean createNPC(String name) + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + return ess.getEconomy().createNPC(name); + } + + /** + * Deletes a user, if it is marked as npc. + * + * @param name Name of the player + * @throws UserDoesNotExistException + */ + public static void removeNPC(String name) throws UserDoesNotExistException + { + if (ess == null) + { + throw new RuntimeException(noCallBeforeLoad); + } + ess.getEconomy().removeNPC(name); + } +} diff --git a/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java index 0dc36e262..cbc51eddd 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java @@ -1,6 +1,6 @@ package com.earth2me.essentials; -import static com.earth2me.essentials.I18n._; +import static net.ess3.I18n._; import com.google.common.io.Files; import java.io.*; import java.nio.ByteBuffer; diff --git a/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java index d912caf7e..cbc6f5982 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -1,12 +1,13 @@ package com.earth2me.essentials; -import com.earth2me.essentials.economy.WorthHolder; -import com.earth2me.essentials.storage.ManagedFile; -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IEssentials; -import com.earth2me.essentials.settings.Spawns; -import com.earth2me.essentials.storage.Location; -import com.earth2me.essentials.storage.YamlStorageWriter; +import net.ess3.economy.WorthHolder; +import net.ess3.Warps; +import net.ess3.storage.ManagedFile; +import static net.ess3.I18n._; +import net.ess3.api.IEssentials; +import net.ess3.settings.Spawns; +import net.ess3.storage.Location; +import net.ess3.storage.YamlStorageWriter; import java.io.*; import java.math.BigInteger; import java.security.DigestInputStream; @@ -658,7 +659,7 @@ public class EssentialsUpgrade config.load(); if (!config.hasProperty("jails")) { - final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails(); + final net.ess3.settings.Jails jails = new net.ess3.settings.Jails(); Set keys = config.getKeys(false); for (String jailName : keys) { diff --git a/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java b/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java deleted file mode 100644 index 663c451c6..000000000 --- a/Essentials2Compat/src/com/earth2me/essentials/api/Economy.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.earth2me.essentials.api; - -import com.earth2me.essentials.utils.Util; - - -/** - * Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod - */ -public final class Economy -{ - private Economy() - { - } - private static IEssentials ess; - private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded."; - - /** - * Returns the balance of a user - * - * @param name Name of the user - * @return balance - * @throws UserDoesNotExistException - */ - public static double getMoney(String name) throws UserDoesNotExistException - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return ess.getEconomy().getMoney(name); - } - - /** - * Sets the balance of a user - * - * @param name Name of the user - * @param balance The balance you want to set - * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance - */ - public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - ess.getEconomy().setMoney(name, balance); - } - - /** - * Adds money to the balance of a user - * - * @param name Name of the user - * @param amount The money you want to add - * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance - */ - public static void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException - { - double result = getMoney(name) + amount; - setMoney(name, result); - } - - /** - * Substracts money from the balance of a user - * - * @param name Name of the user - * @param amount The money you want to substract - * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance - */ - public static void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException - { - double result = getMoney(name) - amount; - setMoney(name, result); - } - - /** - * Divides the balance of a user by a value - * - * @param name Name of the user - * @param value The balance is divided by this value - * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance - */ - public static void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException - { - double result = getMoney(name) / value; - setMoney(name, result); - } - - /** - * Multiplies the balance of a user by a value - * - * @param name Name of the user - * @param value The balance is multiplied by this value - * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance - */ - public static void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException - { - double result = getMoney(name) * value; - setMoney(name, result); - } - - /** - * Resets the balance of a user to the starting balance - * - * @param name Name of the user - * @throws UserDoesNotExistException If a user by that name does not exists - * @throws NoLoanPermittedException If the user is not allowed to have a negative balance - */ - public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - ess.getEconomy().resetBalance(name); - } - - /** - * @param name Name of the user - * @param amount The amount of money the user should have - * @return true, if the user has more or an equal amount of money - * @throws UserDoesNotExistException If a user by that name does not exists - */ - public static boolean hasEnough(String name, double amount) throws UserDoesNotExistException - { - return amount <= getMoney(name); - } - - /** - * @param name Name of the user - * @param amount The amount of money the user should have - * @return true, if the user has more money - * @throws UserDoesNotExistException If a user by that name does not exists - */ - public static boolean hasMore(String name, double amount) throws UserDoesNotExistException - { - return amount < getMoney(name); - } - - /** - * @param name Name of the user - * @param amount The amount of money the user should not have - * @return true, if the user has less money - * @throws UserDoesNotExistException If a user by that name does not exists - */ - public static boolean hasLess(String name, double amount) throws UserDoesNotExistException - { - return amount > getMoney(name); - } - - /** - * Test if the user has a negative balance - * - * @param name Name of the user - * @return true, if the user has a negative balance - * @throws UserDoesNotExistException If a user by that name does not exists - */ - public static boolean isNegative(String name) throws UserDoesNotExistException - { - return getMoney(name) < 0.0; - } - - /** - * Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67 - * - * @param amount The amount of money - * @return Formatted money - */ - public static String format(double amount) - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return Util.displayCurrency(amount, ess); - } - - /** - * Test if a player exists to avoid the UserDoesNotExistException - * - * @param name Name of the user - * @return true, if the user exists - */ - public static boolean playerExists(String name) - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return ess.getEconomy().playerExists(name); - } - - /** - * Test if a player is a npc - * - * @param name Name of the player - * @return true, if it's a npc - * @throws UserDoesNotExistException - */ - public static boolean isNPC(String name) throws UserDoesNotExistException - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return ess.getEconomy().isNPC(name); - } - - /** - * 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 boolean createNPC(String name) - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - return ess.getEconomy().createNPC(name); - } - - /** - * Deletes a user, if it is marked as npc. - * - * @param name Name of the player - * @throws UserDoesNotExistException - */ - public static void removeNPC(String name) throws UserDoesNotExistException - { - if (ess == null) - { - throw new RuntimeException(noCallBeforeLoad); - } - ess.getEconomy().removeNPC(name); - } -} diff --git a/Essentials2Compat/src/plugin.yml b/Essentials2Compat/src/plugin.yml index 5610b82a4..bc721f650 100644 --- a/Essentials2Compat/src/plugin.yml +++ b/Essentials2Compat/src/plugin.yml @@ -1,5 +1,5 @@ name: Essentials -main: com.earth2me.essentials.Essentials +main: net.ess3.Essentials version: 2.9 website: http://tiny.cc/EssentialsWiki description: Compatibility plugin for older plugins -- cgit v1.2.3