summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-10-09 16:53:01 +0200
committersnowleo <schneeleo@gmail.com>2011-10-09 16:53:01 +0200
commitd075b14e4f1f63fda7df54fe7076312506e81587 (patch)
tree9e5dde0341b01305ac34a42afb1ea455b461cd9e
parentcc77b7d0aad61fd0a18cca97d4720ff478781e70 (diff)
downloadEssentials-d075b14e4f1f63fda7df54fe7076312506e81587.tar
Essentials-d075b14e4f1f63fda7df54fe7076312506e81587.tar.gz
Essentials-d075b14e4f1f63fda7df54fe7076312506e81587.tar.lz
Essentials-d075b14e4f1f63fda7df54fe7076312506e81587.tar.xz
Essentials-d075b14e4f1f63fda7df54fe7076312506e81587.zip
Throw RuntimeException instead of NPE, if the api is called before Essentials is loaded.
-rw-r--r--Essentials/src/com/earth2me/essentials/api/Economy.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/api/Economy.java b/Essentials/src/com/earth2me/essentials/api/Economy.java
index 940207a6f..b0a267345 100644
--- a/Essentials/src/com/earth2me/essentials/api/Economy.java
+++ b/Essentials/src/com/earth2me/essentials/api/Economy.java
@@ -21,6 +21,7 @@ public final class Economy
}
private static final Logger logger = Logger.getLogger("Minecraft");
private static IEssentials ess;
+ private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
/**
* @param aEss the ess to set
@@ -66,6 +67,10 @@ public final class Economy
private static User getUserByName(String name)
{
+ if (ess == null)
+ {
+ throw new RuntimeException(noCallBeforeLoad);
+ }
User user;
Player player = ess.getServer().getPlayer(name);
if (player != null)
@@ -176,6 +181,10 @@ public final class Economy
*/
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
{
+ if (ess == null)
+ {
+ throw new RuntimeException(noCallBeforeLoad);
+ }
setMoney(name, ess.getSettings().getStartingBalance());
}
@@ -231,6 +240,10 @@ public final class Economy
*/
public static String format(double amount)
{
+ if (ess == null)
+ {
+ throw new RuntimeException(noCallBeforeLoad);
+ }
return Util.formatCurrency(amount, ess);
}