diff --git a/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java b/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java index 74b8894..f45bec6 100644 --- a/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java +++ b/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java @@ -2,13 +2,15 @@ package com.garbagemule.MobArena.things; import net.milkbowl.vault.economy.Economy; +import java.util.function.Supplier; + class MoneyThingParser implements ThingParser { private static final String PREFIX_LONG = "money:"; private static final String PREFIX_SHORT = "$"; - private Economy economy; + private Supplier economy; - MoneyThingParser(Economy economy) { + MoneyThingParser(Supplier economy) { this.economy = economy; } @@ -18,7 +20,7 @@ class MoneyThingParser implements ThingParser { if (money == null) { return null; } - return new MoneyThing(economy, Double.parseDouble(money)); + return new MoneyThing(economy.get(), Double.parseDouble(money)); } private String trimPrefix(String s) { diff --git a/src/main/java/com/garbagemule/MobArena/things/ThingManager.java b/src/main/java/com/garbagemule/MobArena/things/ThingManager.java index 5b81522..66985a4 100644 --- a/src/main/java/com/garbagemule/MobArena/things/ThingManager.java +++ b/src/main/java/com/garbagemule/MobArena/things/ThingManager.java @@ -12,7 +12,7 @@ public class ThingManager implements ThingParser { public ThingManager(MobArena plugin, ItemStackThingParser parser) { parsers = new ArrayList<>(); parsers.add(new CommandThingParser()); - parsers.add(new MoneyThingParser(plugin.getEconomy())); + parsers.add(new MoneyThingParser(plugin::getEconomy)); items = parser; } diff --git a/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java b/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java index 24c1986..b268a85 100644 --- a/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java +++ b/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java @@ -22,7 +22,7 @@ public class MoneyThingParserTest { @Before public void setup() { Economy economy = mock(Economy.class); - subject = new MoneyThingParser(economy); + subject = new MoneyThingParser(() -> economy); } @Test