From e8e8de834bb375aa5e35cecbcb2f9351ca732f11 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 19 Apr 2013 18:25:47 +0200 Subject: [PATCH] Fore the sake of inception add in experimental money support in mcore through Vault. --- src/com/massivecraft/mcore/MCore.java | 21 ++- .../integration/vault/VaultFeatures.java | 32 +++++ src/com/massivecraft/mcore/money/Money.java | 108 +++++++++++++++ .../massivecraft/mcore/money/MoneyMixin.java | 40 ++++++ .../mcore/money/MoneyMixinAbstract.java | 6 + .../mcore/money/MoneyMixinDefault.java | 92 +++++++++++++ .../mcore/money/MoneyMixinVault.java | 130 ++++++++++++++++++ .../massivecraft/mcore/usys/Multiverse.java | 4 +- src/com/massivecraft/mcore/util/MUtil.java | 4 + .../mcore/util/extractor/ExtractorLogic.java | 35 ++++- .../extractor/ExtractorMoneyUniverse.java | 22 +++ .../mcore/util/extractor/ExtractorPlayer.java | 18 ++- .../util/extractor/ExtractorPlayerName.java | 18 ++- .../mcore/util/extractor/ExtractorSender.java | 18 ++- .../util/extractor/ExtractorSenderId.java | 18 ++- .../mcore/util/extractor/ExtractorWorld.java | 18 ++- .../util/extractor/ExtractorWorldName.java | 18 ++- 17 files changed, 556 insertions(+), 46 deletions(-) create mode 100644 src/com/massivecraft/mcore/integration/vault/VaultFeatures.java create mode 100644 src/com/massivecraft/mcore/money/Money.java create mode 100644 src/com/massivecraft/mcore/money/MoneyMixin.java create mode 100644 src/com/massivecraft/mcore/money/MoneyMixinAbstract.java create mode 100644 src/com/massivecraft/mcore/money/MoneyMixinDefault.java create mode 100644 src/com/massivecraft/mcore/money/MoneyMixinVault.java create mode 100644 src/com/massivecraft/mcore/util/extractor/ExtractorMoneyUniverse.java diff --git a/src/com/massivecraft/mcore/MCore.java b/src/com/massivecraft/mcore/MCore.java index ba48add4..6085cc5d 100644 --- a/src/com/massivecraft/mcore/MCore.java +++ b/src/com/massivecraft/mcore/MCore.java @@ -20,6 +20,7 @@ import com.massivecraft.mcore.adapter.PlayerInventoryAdapter; import com.massivecraft.mcore.adapter.UUIDAdapter; import com.massivecraft.mcore.cmd.CmdMcore; import com.massivecraft.mcore.integration.protocollib.ProtocolLibFeatures; +import com.massivecraft.mcore.integration.vault.VaultFeatures; import com.massivecraft.mcore.mixin.ScheduledTeleportEngine; import com.massivecraft.mcore.mixin.SenderIdMixinDefault; import com.massivecraft.mcore.mixin.TeleportMixinCauseEngine; @@ -28,7 +29,9 @@ import com.massivecraft.mcore.ps.PSAdapter; import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Db; import com.massivecraft.mcore.store.MStore; +import com.massivecraft.mcore.usys.Aspect; import com.massivecraft.mcore.usys.AspectColl; +import com.massivecraft.mcore.usys.Multiverse; import com.massivecraft.mcore.usys.MultiverseColl; import com.massivecraft.mcore.usys.cmd.CmdUsys; import com.massivecraft.mcore.util.PlayerUtil; @@ -90,6 +93,12 @@ public class MCore extends MPlugin public CmdUsys cmdUsys; public CmdMcore cmdMcore; + // Aspects + private Aspect moneyAspect; + public Aspect getMoneyAspect() { return this.moneyAspect; } + public Multiverse getMoneyMultiverse() { return this.getMoneyAspect().getMultiverse(); } + + // Runnables private Runnable collTickTask = new Runnable() { public void run() @@ -138,6 +147,13 @@ public class MCore extends MPlugin AspectColl.get().init(); MCoreConfColl.get().init(); + // Init aspects + this.moneyAspect = AspectColl.get().get("mcore_money", true); + this.moneyAspect.register(); + this.moneyAspect.setDesc( + "The aspect used for how much money a player has" + ); + // Register commands this.cmdUsys = new CmdUsys(); this.cmdUsys.register(this, true); @@ -146,7 +162,10 @@ public class MCore extends MPlugin this.cmdMcore.register(this, true); // Integration - this.integrate(ProtocolLibFeatures.get()); + this.integrate( + ProtocolLibFeatures.get(), + VaultFeatures.get() + ); /* test(""); diff --git a/src/com/massivecraft/mcore/integration/vault/VaultFeatures.java b/src/com/massivecraft/mcore/integration/vault/VaultFeatures.java new file mode 100644 index 00000000..ab773654 --- /dev/null +++ b/src/com/massivecraft/mcore/integration/vault/VaultFeatures.java @@ -0,0 +1,32 @@ +package com.massivecraft.mcore.integration.vault; + +import com.massivecraft.mcore.integration.IntegrationFeaturesAbstract; +import com.massivecraft.mcore.money.MoneyMixinVault; + +public class VaultFeatures extends IntegrationFeaturesAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static VaultFeatures i = new VaultFeatures(); + public static VaultFeatures get() { return i; } + private VaultFeatures() { super("Vault"); } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void activate() + { + MoneyMixinVault.get().activate(); + } + + @Override + public void deactivate() + { + MoneyMixinVault.get().deactivate(); + } + +} diff --git a/src/com/massivecraft/mcore/money/Money.java b/src/com/massivecraft/mcore/money/Money.java new file mode 100644 index 00000000..02824bcb --- /dev/null +++ b/src/com/massivecraft/mcore/money/Money.java @@ -0,0 +1,108 @@ +package com.massivecraft.mcore.money; + +import com.massivecraft.mcore.util.MUtil; + +public class Money +{ + // -------------------------------------------- // + // MIXIN + // -------------------------------------------- // + + private static MoneyMixin mixin = MoneyMixinDefault.get(); + public static MoneyMixin mixin() { return mixin; }; + public static void mixin(MoneyMixin newMixin) { mixin = newMixin; } + + // -------------------------------------------- // + // EXTRACT + // -------------------------------------------- // + + public static String universe(Object universe) + { + String ret = MUtil.extract(String.class, "moneyUniverse", universe); + if (ret == null) throw new IllegalArgumentException("extraction of universe from object failed"); + return ret; + } + + public static String accountId(Object accountId) + { + String ret = MUtil.extract(String.class, "accountId", accountId); + if (ret == null) throw new IllegalArgumentException("extraction of accountId from object failed"); + return ret; + } + + // -------------------------------------------- // + // ENABLED + // -------------------------------------------- // + + public static boolean enabled(Object universe) + { + return mixin.enabled(universe(universe)); + } + + public static boolean disabled(Object universe) + { + return !enabled(universe); + } + + // -------------------------------------------- // + // FORMAT AND NAME + // -------------------------------------------- // + + public static String format(Object universe, double amount) + { + return mixin.format(universe(universe), amount); + } + + public static String singular(Object universe) + { + return mixin.singular(universe(universe)); + } + + public static String plural(Object universe) + { + return mixin.plural(universe(universe)); + } + + // -------------------------------------------- // + // EXISTS AND CREATE + // -------------------------------------------- // + + public static boolean exists(Object universe, Object accountId) + { + return mixin.exists(universe(universe), accountId(accountId)); + } + + public static boolean create(Object universe, Object accountId) + { + return mixin.create(universe(universe), accountId(accountId)); + } + + // -------------------------------------------- // + // GET AND SET + // -------------------------------------------- // + + public static double get(Object universe, Object accountId) + { + return mixin.get(universe(universe), accountId(accountId)); + } + + public static boolean set(Object universe, Object accountId, double amount) + { + return mixin.set(universe(universe), accountId(accountId), amount); + } + + // -------------------------------------------- // + // MODIFY + // -------------------------------------------- // + + public static boolean add(Object universe, Object accountId, double amount) + { + return mixin.add(universe(universe), accountId(accountId), amount); + } + + public static boolean subtract(Object universe, Object accountId, double amount) + { + return mixin.subtract(universe(universe), accountId(accountId), amount); + } + +} diff --git a/src/com/massivecraft/mcore/money/MoneyMixin.java b/src/com/massivecraft/mcore/money/MoneyMixin.java new file mode 100644 index 00000000..5c87b2a0 --- /dev/null +++ b/src/com/massivecraft/mcore/money/MoneyMixin.java @@ -0,0 +1,40 @@ +package com.massivecraft.mcore.money; + +public interface MoneyMixin +{ + // -------------------------------------------- // + // ENABLED + // -------------------------------------------- // + + public boolean enabled(String universe); + + // -------------------------------------------- // + // FORMAT AND NAME + // -------------------------------------------- // + + public String format(String universe, double amount); + public String singular(String universe); + public String plural(String universe); + + // -------------------------------------------- // + // EXISTS AND CREATE + // -------------------------------------------- // + + public boolean exists(String universe, String accountId); + public boolean create(String universe, String accountId); + + // -------------------------------------------- // + // GET AND SET + // -------------------------------------------- // + + public double get(String universe, String accountId); + public boolean set(String universe, String accountId, double amount); + + // -------------------------------------------- // + // MODIFY + // -------------------------------------------- // + + public boolean add(String universe, String accountId, double amount); + public boolean subtract(String universe, String accountId, double amount); + +} diff --git a/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java b/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java new file mode 100644 index 00000000..8c691b48 --- /dev/null +++ b/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java @@ -0,0 +1,6 @@ +package com.massivecraft.mcore.money; + +public abstract class MoneyMixinAbstract implements MoneyMixin +{ + +} \ No newline at end of file diff --git a/src/com/massivecraft/mcore/money/MoneyMixinDefault.java b/src/com/massivecraft/mcore/money/MoneyMixinDefault.java new file mode 100644 index 00000000..e950db5d --- /dev/null +++ b/src/com/massivecraft/mcore/money/MoneyMixinDefault.java @@ -0,0 +1,92 @@ +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 new file mode 100644 index 00000000..ffcdc0df --- /dev/null +++ b/src/com/massivecraft/mcore/money/MoneyMixinVault.java @@ -0,0 +1,130 @@ +package com.massivecraft.mcore.money; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.RegisteredServiceProvider; + + + +import net.milkbowl.vault.economy.Economy; + +public class MoneyMixinVault extends MoneyMixinAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static final MoneyMixinVault i = new MoneyMixinVault(); + public static MoneyMixinVault get() { return i; } + + // -------------------------------------------- // + // ACTIVATE & DEACTIVATE + // -------------------------------------------- // + + public void activate() + { + RegisteredServiceProvider rsp = Bukkit.getServicesManager().getRegistration(Economy.class); + this.economy = rsp.getProvider(); + Money.mixin(this); + } + + public void deactivate() + { + Money.mixin(MoneyMixinDefault.get()); + } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private Economy economy = null; + + // -------------------------------------------- // + // ENABLED AND DISABLED + // -------------------------------------------- // + + @Override + public boolean enabled(String universe) + { + return this.economy.isEnabled(); + } + + // -------------------------------------------- // + // FORMAT AND NAME + // -------------------------------------------- // + + @Override + public String format(String universe, double amount) + { + return this.economy.format(amount); + } + + @Override + public String singular(String universe) + { + return this.economy.currencyNameSingular(); + } + + @Override + public String plural(String universe) + { + return this.economy.currencyNamePlural(); + } + + // -------------------------------------------- // + // EXISTS AND CREATE + // -------------------------------------------- // + + @Override + public boolean exists(String universe, String accountId) + { + return this.economy.hasAccount(accountId, universe); + } + + @Override + public boolean create(String universe, String accountId) + { + return this.economy.createPlayerAccount(accountId, universe); + } + + // -------------------------------------------- // + // GET AND SET + // -------------------------------------------- // + + @Override + public double get(String universe, String accountId) + { + return this.economy.getBalance(accountId, universe); + } + + @Override + public boolean set(String universe, String accountId, double amount) + { + double current = get(universe, accountId); + return add(universe, accountId, amount - current); + } + + // -------------------------------------------- // + // MODIFY + // -------------------------------------------- // + + @Override + public boolean add(String universe, String accountId, double amount) + { + if (amount < 0) + { + return subtract(universe, accountId, -amount); + } + return economy.depositPlayer(accountId, universe, amount).transactionSuccess(); + } + + @Override + public boolean subtract(String universe, String accountId, double amount) + { + if (amount < 0) + { + return add(universe, accountId, -amount); + } + return economy.withdrawPlayer(accountId, universe, amount).transactionSuccess(); + } + +} \ No newline at end of file diff --git a/src/com/massivecraft/mcore/usys/Multiverse.java b/src/com/massivecraft/mcore/usys/Multiverse.java index e6e69bc9..78b69534 100644 --- a/src/com/massivecraft/mcore/usys/Multiverse.java +++ b/src/com/massivecraft/mcore/usys/Multiverse.java @@ -58,9 +58,9 @@ public class Multiverse extends Entity // UNIVERSE // -------------------------------------------- // - public boolean containsUniverse(String worldName) + public boolean containsUniverse(String universe) { - return this.getUniverses().contains(worldName); + return this.getUniverses().contains(universe); } public Set newUniverse(String universe) diff --git a/src/com/massivecraft/mcore/util/MUtil.java b/src/com/massivecraft/mcore/util/MUtil.java index c07d6536..405104d0 100644 --- a/src/com/massivecraft/mcore/util/MUtil.java +++ b/src/com/massivecraft/mcore/util/MUtil.java @@ -49,6 +49,7 @@ import com.massivecraft.mcore.InternalListener; import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.WorldNameSetEngine; import com.massivecraft.mcore.util.extractor.Extractor; +import com.massivecraft.mcore.util.extractor.ExtractorMoneyUniverse; import com.massivecraft.mcore.util.extractor.ExtractorPlayer; import com.massivecraft.mcore.util.extractor.ExtractorPlayerName; import com.massivecraft.mcore.util.extractor.ExtractorSender; @@ -572,5 +573,8 @@ public class MUtil registerExtractor(World.class, "world", ExtractorWorld.get()); registerExtractor(String.class, "worldName", ExtractorWorldName.get()); + + registerExtractor(String.class, "moneyUniverse", ExtractorMoneyUniverse.get()); + registerExtractor(String.class, "accountId", ExtractorPlayerName.get()); } } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorLogic.java b/src/com/massivecraft/mcore/util/extractor/ExtractorLogic.java index 9d064ec8..3e8c5863 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorLogic.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorLogic.java @@ -25,8 +25,11 @@ import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEvent; import org.bukkit.event.vehicle.VehicleExitEvent; +import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.mcore.usys.Multiverse; +import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.SenderUtil; public class ExtractorLogic @@ -96,7 +99,6 @@ public class ExtractorLogic if (o == null) return null; if (o instanceof String) return (String)o; if (o instanceof SenderEntity) return ((SenderEntity)o).getId(); - if (o instanceof SenderEntity) return ((SenderEntity)o).getId(); CommandSender sender = senderFromObject(o); if (sender == null) return null; return SenderUtil.getSenderId(sender); @@ -160,4 +162,35 @@ public class ExtractorLogic if (world == null) return null; return world.getName(); } + + // -------------------------------------------- // + // MONEY UNIVERSE + // -------------------------------------------- // + + public static String moneyUniverse(String o) + { + Multiverse m = MCore.get().getMoneyMultiverse(); + if (m.containsUniverse(o)) return o; + return m.getUniverseForWorldName(o); + } + + public static String moneyUniverse(com.massivecraft.mcore.store.Entity o) + { + return o.getUniverse(); + } + + public static String moneyUniverseFromObject(Object o) + { + if (o instanceof String) return moneyUniverse((String)o); + if (o instanceof com.massivecraft.mcore.store.Entity) return moneyUniverse((com.massivecraft.mcore.store.Entity)o); + + String worldName = MUtil.extract(String.class, "worldName", o); + if (worldName != null) + { + return MCore.get().getMoneyMultiverse().getUniverseForWorldName(worldName); + } + + return null; + } + } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorMoneyUniverse.java b/src/com/massivecraft/mcore/util/extractor/ExtractorMoneyUniverse.java new file mode 100644 index 00000000..e82a07bd --- /dev/null +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorMoneyUniverse.java @@ -0,0 +1,22 @@ +package com.massivecraft.mcore.util.extractor; + +public class ExtractorMoneyUniverse implements Extractor +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ExtractorMoneyUniverse i = new ExtractorMoneyUniverse(); + public static ExtractorMoneyUniverse get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + + @Override + public Object extract(Object o) + { + return ExtractorLogic.moneyUniverseFromObject(o); + } + +} diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorPlayer.java b/src/com/massivecraft/mcore/util/extractor/ExtractorPlayer.java index 5b5f8665..7177ac79 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorPlayer.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorPlayer.java @@ -2,17 +2,21 @@ package com.massivecraft.mcore.util.extractor; public class ExtractorPlayer implements Extractor { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ExtractorPlayer i = new ExtractorPlayer(); + public static ExtractorPlayer get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + @Override public Object extract(Object o) { return ExtractorLogic.playerFromObject(o); } - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static ExtractorPlayer i = new ExtractorPlayer(); - public static ExtractorPlayer get() { return i; } - } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorPlayerName.java b/src/com/massivecraft/mcore/util/extractor/ExtractorPlayerName.java index fa681b2d..eff739cc 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorPlayerName.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorPlayerName.java @@ -2,17 +2,21 @@ package com.massivecraft.mcore.util.extractor; public class ExtractorPlayerName implements Extractor { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ExtractorPlayerName i = new ExtractorPlayerName(); + public static ExtractorPlayerName get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + @Override public Object extract(Object o) { return ExtractorLogic.playerNameFromObject(o); } - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static ExtractorPlayerName i = new ExtractorPlayerName(); - public static ExtractorPlayerName get() { return i; } - } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorSender.java b/src/com/massivecraft/mcore/util/extractor/ExtractorSender.java index 072ea8e3..3b8a1056 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorSender.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorSender.java @@ -2,17 +2,21 @@ package com.massivecraft.mcore.util.extractor; public class ExtractorSender implements Extractor { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ExtractorSender i = new ExtractorSender(); + public static ExtractorSender get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + @Override public Object extract(Object o) { return ExtractorLogic.senderFromObject(o); } - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static ExtractorSender i = new ExtractorSender(); - public static ExtractorSender get() { return i; } - } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorSenderId.java b/src/com/massivecraft/mcore/util/extractor/ExtractorSenderId.java index 396738a5..83339d4b 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorSenderId.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorSenderId.java @@ -2,17 +2,21 @@ package com.massivecraft.mcore.util.extractor; public class ExtractorSenderId implements Extractor { - @Override - public Object extract(Object o) - { - return ExtractorLogic.senderIdFromObject(o); - } - // -------------------------------------------- // - // INSTANCE + // INSTANCE & CONSTRUCT // -------------------------------------------- // private static ExtractorSenderId i = new ExtractorSenderId(); public static ExtractorSenderId get() { return i; } + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + + @Override + public Object extract(Object o) + { + return ExtractorLogic.senderIdFromObject(o); + } + } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorWorld.java b/src/com/massivecraft/mcore/util/extractor/ExtractorWorld.java index 4f39bd95..2fda8d85 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorWorld.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorWorld.java @@ -2,17 +2,21 @@ package com.massivecraft.mcore.util.extractor; public class ExtractorWorld implements Extractor { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ExtractorWorld i = new ExtractorWorld(); + public static ExtractorWorld get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + @Override public Object extract(Object o) { return ExtractorLogic.worldFromObject(o); } - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static ExtractorWorld i = new ExtractorWorld(); - public static ExtractorWorld get() { return i; } - } diff --git a/src/com/massivecraft/mcore/util/extractor/ExtractorWorldName.java b/src/com/massivecraft/mcore/util/extractor/ExtractorWorldName.java index de1dc8f0..37cd40a9 100644 --- a/src/com/massivecraft/mcore/util/extractor/ExtractorWorldName.java +++ b/src/com/massivecraft/mcore/util/extractor/ExtractorWorldName.java @@ -2,17 +2,21 @@ package com.massivecraft.mcore.util.extractor; public class ExtractorWorldName implements Extractor { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ExtractorWorldName i = new ExtractorWorldName(); + public static ExtractorWorldName get() { return i; } + + // -------------------------------------------- // + // OVERRIDE: EXTRACTOR + // -------------------------------------------- // + @Override public Object extract(Object o) { return ExtractorLogic.worldNameFromObject(o); } - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static ExtractorWorldName i = new ExtractorWorldName(); - public static ExtractorWorldName get() { return i; } - }