diff --git a/src/main/java/com/garbagemule/MobArena/MobArena.java b/src/main/java/com/garbagemule/MobArena/MobArena.java index 67ed86b..d990f05 100644 --- a/src/main/java/com/garbagemule/MobArena/MobArena.java +++ b/src/main/java/com/garbagemule/MobArena/MobArena.java @@ -202,7 +202,7 @@ public class MobArena extends JavaPlugin private void setupVault() { Plugin vaultPlugin = this.getServer().getPluginManager().getPlugin("Vault"); if (vaultPlugin == null) { - getLogger().warning("Vault was not found. Economy rewards will not work!"); + getLogger().info("Vault was not found. Economy rewards will not work."); return; } diff --git a/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java b/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java index 12563a0..d0e8f00 100644 --- a/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java +++ b/src/main/java/com/garbagemule/MobArena/things/MoneyThingParser.java @@ -1,6 +1,7 @@ package com.garbagemule.MobArena.things; import com.garbagemule.MobArena.MobArena; +import net.milkbowl.vault.economy.Economy; class MoneyThingParser implements ThingParser { private static final String PREFIX_LONG = "money:"; @@ -18,7 +19,11 @@ class MoneyThingParser implements ThingParser { if (money == null) { return null; } - return new MoneyThing(plugin.getEconomy(), Double.parseDouble(money)); + Economy economy = plugin.getEconomy(); + if (economy == null) { + plugin.getLogger().severe("Vault or economy plugin missing while parsing: " + s); + } + return new MoneyThing(economy, Double.parseDouble(money)); } private String trimPrefix(String s) { diff --git a/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java b/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java index 0635d40..ec2586a 100644 --- a/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java +++ b/src/test/java/com/garbagemule/MobArena/things/MoneyThingParserTest.java @@ -4,7 +4,9 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.garbagemule.MobArena.MobArena; @@ -14,16 +16,19 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import java.util.logging.Logger; + public class MoneyThingParserTest { private MoneyThingParser subject; + private MobArena plugin; @Rule public ExpectedException exception = ExpectedException.none(); @Before public void setup() { - MobArena plugin = mock(MobArena.class); + plugin = mock(MobArena.class); Economy economy = mock(Economy.class); when(plugin.getEconomy()).thenReturn(economy); @@ -51,6 +56,17 @@ public class MoneyThingParserTest { assertThat(result, not(nullValue())); } + @Test + public void nullEconomyNullMoney() { + Logger logger = mock(Logger.class); + when(plugin.getEconomy()).thenReturn(null); + when(plugin.getLogger()).thenReturn(logger); + + subject.parse("$500"); + + verify(logger).severe(anyString()); + } + @Test public void numberFormatForNaughtyValues() { exception.expect(NumberFormatException.class);