Skip to content

Commit

Permalink
More additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Redned235 committed Jul 1, 2024
1 parent f6cd2f0 commit daeb4eb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -96,6 +98,8 @@ static void register() {

return MiniMessage.miniMessage().deserialize(value);
});

ArenaConfigParser.registerProvider(BlockData.class, parseString(Bukkit::createBlockData));
}

private static <T> ArenaConfigParser.Parser<T> parseString(Function<String, T> parser) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package org.battleplugins.arena.config;

import org.battleplugins.arena.Arena;
import org.bukkit.block.data.BlockData;

final class DefaultSerializers {

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());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<E> contextConsumer) {
if (this.players.contains(player.getUniqueId())) {
Messages.ERROR_ALREADY_IN_EDITOR.send(player);
return;
Expand Down Expand Up @@ -99,6 +103,10 @@ public void openWizard(Player player, Arena arena) {
}
});

if (contextConsumer != null) {
contextConsumer.accept(context);
}

WizardStage<E> initialStage = iterator.next().getValue();
initialStage.enter(context);

Expand Down

This file was deleted.

0 comments on commit daeb4eb

Please sign in to comment.