From dc15ec2d6c7c9fd33529497a1533ac9ef71956ea Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 19 Apr 2013 18:58:34 +0200 Subject: [PATCH] Now that I think of it the default case is the null case. --- src/com/massivecraft/mcore/money/Money.java | 12 ++- .../mcore/money/MoneyMixinDefault.java | 92 ------------------- .../mcore/money/MoneyMixinVault.java | 2 +- 3 files changed, 12 insertions(+), 94 deletions(-) delete mode 100644 src/com/massivecraft/mcore/money/MoneyMixinDefault.java diff --git a/src/com/massivecraft/mcore/money/Money.java b/src/com/massivecraft/mcore/money/Money.java index 02824bcb..c575ea6f 100644 --- a/src/com/massivecraft/mcore/money/Money.java +++ b/src/com/massivecraft/mcore/money/Money.java @@ -8,7 +8,7 @@ public class Money // MIXIN // -------------------------------------------- // - private static MoneyMixin mixin = MoneyMixinDefault.get(); + private static MoneyMixin mixin = null; public static MoneyMixin mixin() { return mixin; }; public static void mixin(MoneyMixin newMixin) { mixin = newMixin; } @@ -36,6 +36,7 @@ public class Money public static boolean enabled(Object universe) { + if (mixin == null) return false; return mixin.enabled(universe(universe)); } @@ -50,16 +51,19 @@ public class Money public static String format(Object universe, double amount) { + if (disabled(universe)) return String.valueOf(amount); return mixin.format(universe(universe), amount); } public static String singular(Object universe) { + if (disabled(universe)) return "singular"; return mixin.singular(universe(universe)); } public static String plural(Object universe) { + if (disabled(universe)) return "plural"; return mixin.plural(universe(universe)); } @@ -69,11 +73,13 @@ public class Money public static boolean exists(Object universe, Object accountId) { + if (disabled(universe)) return false; return mixin.exists(universe(universe), accountId(accountId)); } public static boolean create(Object universe, Object accountId) { + if (disabled(universe)) return false; return mixin.create(universe(universe), accountId(accountId)); } @@ -83,11 +89,13 @@ public class Money public static double get(Object universe, Object accountId) { + if (disabled(universe)) return 0D; return mixin.get(universe(universe), accountId(accountId)); } public static boolean set(Object universe, Object accountId, double amount) { + if (disabled(universe)) return false; return mixin.set(universe(universe), accountId(accountId), amount); } @@ -97,11 +105,13 @@ public class Money public static boolean add(Object universe, Object accountId, double amount) { + if (disabled(universe)) return false; return mixin.add(universe(universe), accountId(accountId), amount); } public static boolean subtract(Object universe, Object accountId, double amount) { + if (disabled(universe)) return false; return mixin.subtract(universe(universe), accountId(accountId), amount); } diff --git a/src/com/massivecraft/mcore/money/MoneyMixinDefault.java b/src/com/massivecraft/mcore/money/MoneyMixinDefault.java deleted file mode 100644 index e950db5d..00000000 --- a/src/com/massivecraft/mcore/money/MoneyMixinDefault.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.massivecraft.mcore.money; - -public class MoneyMixinDefault extends MoneyMixinAbstract -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final MoneyMixinDefault i = new MoneyMixinDefault(); - public static MoneyMixinDefault get() { return i; } - - // -------------------------------------------- // - // ENABLED AND DISABLED - // -------------------------------------------- // - - @Override - public boolean enabled(String universe) - { - return false; - } - - // -------------------------------------------- // - // FORMAT AND NAME - // -------------------------------------------- // - - @Override - public String format(String universe, double amount) - { - return String.valueOf(amount); - } - - @Override - public String singular(String universe) - { - return "singular"; - } - - @Override - public String plural(String universe) - { - return "plural"; - } - - // -------------------------------------------- // - // EXISTS AND CREATE - // -------------------------------------------- // - - @Override - public boolean exists(String universe, String accountId) - { - return false; - } - - @Override - public boolean create(String universe, String accountId) - { - return false; - } - - // -------------------------------------------- // - // GET AND SET - // -------------------------------------------- // - - @Override - public double get(String universe, String accountId) - { - return 0D; - } - - @Override - public boolean set(String universe, String accountId, double amount) - { - return false; - } - - // -------------------------------------------- // - // MODIFY - // -------------------------------------------- // - - @Override - public boolean add(String universe, String accountId, double amount) - { - return false; - } - - @Override - public boolean subtract(String universe, String accountId, double amount) - { - return false; - } - -} \ No newline at end of file diff --git a/src/com/massivecraft/mcore/money/MoneyMixinVault.java b/src/com/massivecraft/mcore/money/MoneyMixinVault.java index ffcdc0df..1c819727 100644 --- a/src/com/massivecraft/mcore/money/MoneyMixinVault.java +++ b/src/com/massivecraft/mcore/money/MoneyMixinVault.java @@ -29,7 +29,7 @@ public class MoneyMixinVault extends MoneyMixinAbstract public void deactivate() { - Money.mixin(MoneyMixinDefault.get()); + Money.mixin(null); } // -------------------------------------------- //