diff --git a/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java b/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java index f45bec6..12563a0 100644 --- a/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java +++ b/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java @@ -1,17 +1,15 @@ package com.garbagemule.MobArena.things; -import net.milkbowl.vault.economy.Economy; - -import java.util.function.Supplier; +import com.garbagemule.MobArena.MobArena; class MoneyThingParser implements ThingParser { private static final String PREFIX_LONG = "money:"; private static final String PREFIX_SHORT = "$"; - private Supplier economy; + private MobArena plugin; - MoneyThingParser(Supplier economy) { - this.economy = economy; + MoneyThingParser(MobArena plugin) { + this.plugin = plugin; } @Override @@ -20,7 +18,7 @@ class MoneyThingParser implements ThingParser { if (money == null) { return null; } - return new MoneyThing(economy.get(), Double.parseDouble(money)); + return new MoneyThing(plugin.getEconomy(), 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 66985a4..4dc72df 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)); 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 b268a85..0635d40 100644 --- a/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java +++ b/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java @@ -5,7 +5,9 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import com.garbagemule.MobArena.MobArena; import net.milkbowl.vault.economy.Economy; import org.junit.Before; import org.junit.Rule; @@ -21,8 +23,11 @@ public class MoneyThingParserTest { @Before public void setup() { + MobArena plugin = mock(MobArena.class); Economy economy = mock(Economy.class); - subject = new MoneyThingParser(() -> economy); + when(plugin.getEconomy()).thenReturn(economy); + + subject = new MoneyThingParser(plugin); } @Test