Merge pull request #2494 from benwoo1110/property-fix

Fix cannot remove block currency with mvm set command.
This commit is contained in:
Ben Woo 2021-03-04 15:32:34 +08:00 committed by GitHub
commit 7c59dcbcb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,8 @@ public class EntryFee extends SerializationConfig {
@Nullable @Nullable
private Material currency; private Material currency;
private final Material DISABLED_MATERIAL = Material.AIR;
public EntryFee() { public EntryFee() {
super(); super();
} }
@ -51,6 +53,9 @@ public class EntryFee extends SerializationConfig {
*/ */
@Nullable @Nullable
public Material getCurrency() { public Material getCurrency() {
if (currency == null || currency.equals(DISABLED_MATERIAL)) {
return null;
}
return currency; return currency;
} }

View File

@ -50,6 +50,10 @@ public class TestEntryFeeConversion {
WorldProperties props = new WorldProperties(config); WorldProperties props = new WorldProperties(config);
assertNull(props.entryfee.getCurrency()); assertNull(props.entryfee.getCurrency());
entryFee.put("currency", 0);
props = new WorldProperties(config);
assertNull(props.entryfee.getCurrency());
entryFee.put("currency", 1); entryFee.put("currency", 1);
props = new WorldProperties(config); props = new WorldProperties(config);
assertEquals(Material.STONE, props.entryfee.getCurrency()); assertEquals(Material.STONE, props.entryfee.getCurrency());