From 48601e4215a53f915260d589b8dae04be8c1e87f Mon Sep 17 00:00:00 2001 From: benwoo1110 <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 27 Nov 2020 21:14:27 +0800 Subject: [PATCH] Fix cannot remove block currency with mvm set command. Setting currency to 0 is now considered as no currency value. --- .../onarandombox/MultiverseCore/configuration/EntryFee.java | 5 +++++ .../onarandombox/MultiverseCore/TestEntryFeeConversion.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/EntryFee.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/EntryFee.java index be66fb3a..3fff6fe3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/EntryFee.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/EntryFee.java @@ -22,6 +22,8 @@ public class EntryFee extends SerializationConfig { @Nullable private Material currency; + private final Material DISABLED_MATERIAL = Material.AIR; + public EntryFee() { super(); } @@ -51,6 +53,9 @@ public class EntryFee extends SerializationConfig { */ @Nullable public Material getCurrency() { + if (currency == null || currency.equals(DISABLED_MATERIAL)) { + return null; + } return currency; } diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java b/src/test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java index 05b94d33..110e9dd3 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java @@ -50,6 +50,10 @@ public class TestEntryFeeConversion { WorldProperties props = new WorldProperties(config); assertNull(props.entryfee.getCurrency()); + entryFee.put("currency", 0); + props = new WorldProperties(config); + assertNull(props.entryfee.getCurrency()); + entryFee.put("currency", 1); props = new WorldProperties(config); assertEquals(Material.STONE, props.entryfee.getCurrency());