From f55ceda42c6ee9ef169e12537a1da9eea0840bec Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Mon, 19 Oct 2026 10:42:42 +0800 Subject: [PATCH 1/2] Fix command input not allowing @unset, @bukkit spawn values --- .../world/entity/SpawnCategoryConfig.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/org/mvplugins/multiverse/core/world/entity/SpawnCategoryConfig.java b/src/main/java/org/mvplugins/multiverse/core/world/entity/SpawnCategoryConfig.java index 1457fab3b..0e7902030 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/entity/SpawnCategoryConfig.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entity/SpawnCategoryConfig.java @@ -9,6 +9,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.SpawnCategory; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.mvplugins.multiverse.core.config.CoreConfig; import org.mvplugins.multiverse.core.config.handle.MemoryConfigurationHandle; import org.mvplugins.multiverse.core.config.handle.StringPropertyHandle; @@ -16,13 +17,19 @@ import org.mvplugins.multiverse.core.config.node.ListConfigNode; import org.mvplugins.multiverse.core.config.node.Node; import org.mvplugins.multiverse.core.config.node.NodeGroup; +import org.mvplugins.multiverse.core.config.node.functions.NodeStringParser; import org.mvplugins.multiverse.core.config.node.serializer.NodeSerializer; +import org.mvplugins.multiverse.core.exceptions.MultiverseException; +import org.mvplugins.multiverse.core.locale.MVCorei18n; +import org.mvplugins.multiverse.core.locale.message.Message; import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; import org.mvplugins.multiverse.core.world.MultiverseWorld; import java.util.ArrayList; import java.util.List; +import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace; + public final class SpawnCategoryConfig { private final CoreConfig config; @@ -177,6 +184,7 @@ private N node(N node) { final ConfigNode tickRate = node(ConfigNode.builder("tick-rate", Integer.class) .defaultValue(-2) .suggester(input -> List.of("@unset", "@bukkit", "10", "100", "400", "1000")) + .stringParser(SpawnValueStringParser.INSTANCE) .serializer(SpawnValueSerializer.INSTANCE) .onLoadAndChange((oldValue, newValue) -> applyConfigToWorld()) .onChange((sender, oldValue, newValue) -> { @@ -193,6 +201,7 @@ private N node(N node) { final ConfigNode spawnLimit = node(ConfigNode.builder("spawn-limit", Integer.class) .defaultValue(-2) .suggester(input -> List.of("@unset", "@bukkit", "10", "100", "400", "1000")) + .stringParser(SpawnValueStringParser.INSTANCE) .serializer(SpawnValueSerializer.INSTANCE) .onLoadAndChange((oldValue, newValue) -> applyConfigToWorld()) .onChange((sender, oldValue, newValue) -> { @@ -215,6 +224,27 @@ private N node(N node) { .build()); } + private static class SpawnValueStringParser implements NodeStringParser { + private static final SpawnValueStringParser INSTANCE = new SpawnValueStringParser(); + + @Override + public @NotNull Try parse(@Nullable String input, @NotNull Class type) { + String str = String.valueOf(input).trim(); + if (str.equalsIgnoreCase("@unset")) { + return Try.success(-2); + } + if (str.equalsIgnoreCase("@bukkit")) { + return Try.success(-1); + } + try { + return Try.success(Integer.parseInt(str)); + } catch (NumberFormatException e) { + return Try.failure(new MultiverseException(Message.of(MVCorei18n.CONFIG_STRING_PARSER_INVALIDINTEGER, + replace("{input}").with(input)))); + } + } + } + private static class SpawnValueSerializer implements NodeSerializer { private static final SpawnValueSerializer INSTANCE = new SpawnValueSerializer(); From 7a9b21f9a0250438b36480b188628c61156d2418 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Mon, 19 Oct 2026 10:43:25 +0800 Subject: [PATCH 2/2] Fix command input not allowing @vault-economy currency type --- .../multiverse/core/locale/MVCorei18n.java | 1 + .../multiverse/core/world/WorldConfigNodes.java | 17 +++++++++++++++++ .../resources/multiverse-core_en.properties | 1 + 3 files changed, 19 insertions(+) diff --git a/src/main/java/org/mvplugins/multiverse/core/locale/MVCorei18n.java b/src/main/java/org/mvplugins/multiverse/core/locale/MVCorei18n.java index 4ec67906d..adcbeff4a 100644 --- a/src/main/java/org/mvplugins/multiverse/core/locale/MVCorei18n.java +++ b/src/main/java/org/mvplugins/multiverse/core/locale/MVCorei18n.java @@ -26,6 +26,7 @@ public enum MVCorei18n implements MessageKeyProvider { CONFIG_STRING_PARSER_INVALIDDOUBLE, CONFIG_STRING_PARSER_INVALIDFLOAT, CONFIG_STRING_PARSER_INVALIDLONG, + CONFIG_STRING_PARSER_INVALIDMATERIAL, // core config CORE_CONFIG_CUSTOMPORTALSEARCHRADIUS_NONNEGATIVE, diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldConfigNodes.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldConfigNodes.java index b31040a31..9956e03ae 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldConfigNodes.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldConfigNodes.java @@ -6,6 +6,7 @@ import com.dumptruckman.minecraft.util.Logging; import io.vavr.control.Option; +import io.vavr.control.Try; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Difficulty; @@ -26,6 +27,9 @@ import org.mvplugins.multiverse.core.config.node.ListConfigNode; import org.mvplugins.multiverse.core.config.node.NodeGroup; import org.mvplugins.multiverse.core.economy.MVEconomist; +import org.mvplugins.multiverse.core.exceptions.MultiverseException; +import org.mvplugins.multiverse.core.locale.MVCorei18n; +import org.mvplugins.multiverse.core.locale.message.Message; import org.mvplugins.multiverse.core.utils.MaterialConverter; import org.mvplugins.multiverse.core.utils.text.ChatTextFormatter; import org.mvplugins.multiverse.core.world.helpers.AliasNameConflictChecker; @@ -35,6 +39,8 @@ import org.mvplugins.multiverse.core.world.location.SpawnLocation; import org.mvplugins.multiverse.core.world.entity.EntitySpawnConfig; +import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace; + /** * Represents nodes in a world configuration. */ @@ -169,11 +175,22 @@ private ConfigNode node(ConfigNode.Builder nodeBuilder) { final ConfigNode entryFeeCurrency = node(ConfigNode.builder("entry-fee.currency", Material.class) .defaultValue(MVEconomist.VAULT_ECONOMY_MATERIAL) .name("entryfee-currency") + .stringParser((value, clazz) -> { + if (value != null && value.equalsIgnoreCase(MVEconomist.VAULT_ECONOMY_CODE)) { + return Try.success(MVEconomist.VAULT_ECONOMY_MATERIAL); + } + return Try.of(() -> MaterialConverter.stringToMaterial(value)) + .filter(Objects::nonNull) + .orElse(Try.failure(new MultiverseException(Message.of( + MVCorei18n.CONFIG_STRING_PARSER_INVALIDMATERIAL, + replace("{input}").with(value))))); + }) .serializer(new NodeSerializer<>() { @Override public Material deserialize(Object object, Class type) { return Option.of(object) .map(String::valueOf) + .filter(s -> !s.isBlank()) .map(materialStr -> { if (materialStr.equalsIgnoreCase(MVEconomist.VAULT_ECONOMY_CODE)) { return MVEconomist.VAULT_ECONOMY_MATERIAL; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index b44852b70..bb80023ef 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -7,6 +7,7 @@ mv-core.config.string.parser.invalidinteger=Unable to convert '{input}' to numbe mv-core.config.string.parser.invaliddouble=Unable to convert '{input}' to number. (double) mv-core.config.string.parser.invalidfloat=Unable to convert '{input}' to number. (float) mv-core.config.string.parser.invalidlong=Unable to convert '{input}' to number. (long) +mv-core.config.string.parser.invalidmaterial='{input}' is not a valid material. # core config mv-core.core.config.customportalsearchradius.nonnegative=The value must be greater than or equal to 0.