From daeb4eb669ebc6ea9965bae853241cc3d3f13050 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 30 Jun 2024 19:14:57 -0500 Subject: [PATCH] More additions --- .../org/battleplugins/arena/config/DefaultParsers.java | 4 ++++ .../battleplugins/arena/config/DefaultSerializers.java | 5 +++++ .../org/battleplugins/arena/editor/ArenaEditorWizard.java | 8 ++++++++ .../org/battleplugins/arena/editor/type/EditType.java | 5 ----- 4 files changed, 17 insertions(+), 5 deletions(-) delete mode 100644 plugin/src/main/java/org/battleplugins/arena/editor/type/EditType.java diff --git a/plugin/src/main/java/org/battleplugins/arena/config/DefaultParsers.java b/plugin/src/main/java/org/battleplugins/arena/config/DefaultParsers.java index eff1f96d..03f9311f 100644 --- a/plugin/src/main/java/org/battleplugins/arena/config/DefaultParsers.java +++ b/plugin/src/main/java/org/battleplugins/arena/config/DefaultParsers.java @@ -12,6 +12,8 @@ import org.battleplugins.arena.config.context.VictoryConditionContextProvider; import org.battleplugins.arena.util.IntRange; import org.battleplugins.arena.util.PositionWithRotation; +import org.bukkit.Bukkit; +import org.bukkit.block.data.BlockData; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; @@ -96,6 +98,8 @@ static void register() { return MiniMessage.miniMessage().deserialize(value); }); + + ArenaConfigParser.registerProvider(BlockData.class, parseString(Bukkit::createBlockData)); } private static ArenaConfigParser.Parser parseString(Function parser) { diff --git a/plugin/src/main/java/org/battleplugins/arena/config/DefaultSerializers.java b/plugin/src/main/java/org/battleplugins/arena/config/DefaultSerializers.java index 532356c3..9878d7be 100644 --- a/plugin/src/main/java/org/battleplugins/arena/config/DefaultSerializers.java +++ b/plugin/src/main/java/org/battleplugins/arena/config/DefaultSerializers.java @@ -1,6 +1,7 @@ package org.battleplugins.arena.config; import org.battleplugins.arena.Arena; +import org.bukkit.block.data.BlockData; final class DefaultSerializers { @@ -8,5 +9,9 @@ static void register() { ArenaConfigSerializer.registerSerializer(Arena.class, (node, section, type) -> { section.set(node, type.getName()); }); + + ArenaConfigSerializer.registerSerializer(BlockData.class, (node, section, type) -> { + section.set(node, type.getAsString()); + }); } } diff --git a/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizard.java b/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizard.java index 037c1e5b..78fe0d60 100644 --- a/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizard.java +++ b/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizard.java @@ -66,6 +66,10 @@ public void onCancel(E context) { } public void openWizard(Player player, Arena arena) { + this.openWizard(player, arena, null); + } + + public void openWizard(Player player, Arena arena, @Nullable Consumer contextConsumer) { if (this.players.contains(player.getUniqueId())) { Messages.ERROR_ALREADY_IN_EDITOR.send(player); return; @@ -99,6 +103,10 @@ public void openWizard(Player player, Arena arena) { } }); + if (contextConsumer != null) { + contextConsumer.accept(context); + } + WizardStage initialStage = iterator.next().getValue(); initialStage.enter(context); diff --git a/plugin/src/main/java/org/battleplugins/arena/editor/type/EditType.java b/plugin/src/main/java/org/battleplugins/arena/editor/type/EditType.java deleted file mode 100644 index f3b606f1..00000000 --- a/plugin/src/main/java/org/battleplugins/arena/editor/type/EditType.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.battleplugins.arena.editor.type; - -public enum EditType { - MAP -}