mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-25 09:41:23 +01:00
Config node automatically use the enum node serializer
This commit is contained in:
parent
decf20f95f
commit
54c8bac3d3
@ -111,6 +111,7 @@ public class ConfigNode<T> extends ConfigHeaderNode implements ValueNode<T> {
|
||||
* @param <B> The type of the builder.
|
||||
*/
|
||||
public static class Builder<T, B extends ConfigNode.Builder<T, B>> extends ConfigHeaderNode.Builder<B> {
|
||||
private static final NodeSerializer<?> ENUM_NODE_SERIALIZER = new EnumNodeSerializer<>();
|
||||
|
||||
protected @Nullable String name;
|
||||
protected @NotNull final Class<T> type;
|
||||
@ -129,6 +130,9 @@ public class ConfigNode<T> extends ConfigHeaderNode implements ValueNode<T> {
|
||||
super(path);
|
||||
this.name = path;
|
||||
this.type = type;
|
||||
if (type.isEnum()) {
|
||||
this.serializer = (NodeSerializer<T>) ENUM_NODE_SERIALIZER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.onarandombox.MultiverseCore.worldnew.config;
|
||||
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ConfigNode;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.EnumNodeSerializer;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.Node;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeSerializer;
|
||||
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
@ -14,8 +12,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WorldConfigNodes {
|
||||
private static final NodeSerializer<?> ENUM_NODE_SERIALIZER = new EnumNodeSerializer<>();
|
||||
|
||||
private final NodeGroup nodes = new NodeGroup();
|
||||
|
||||
WorldConfigNodes() {
|
||||
@ -63,19 +59,16 @@ public class WorldConfigNodes {
|
||||
public final ConfigNode<Difficulty> DIFFICULTY = node(ConfigNode.builder("difficulty", Difficulty.class)
|
||||
.defaultValue(Difficulty.NORMAL)
|
||||
.name("difficulty")
|
||||
.serializer((NodeSerializer<Difficulty>) ENUM_NODE_SERIALIZER)
|
||||
.build());
|
||||
|
||||
public final ConfigNode<World.Environment> ENVIRONMENT = node(ConfigNode.builder("environment", World.Environment.class)
|
||||
.defaultValue(World.Environment.NORMAL)
|
||||
.name("environment")
|
||||
.serializer((NodeSerializer<World.Environment>) ENUM_NODE_SERIALIZER)
|
||||
.build());
|
||||
|
||||
public final ConfigNode<GameMode> GAMEMODE = node(ConfigNode.builder("gamemode", GameMode.class)
|
||||
.defaultValue(GameMode.SURVIVAL)
|
||||
.name("gamemode")
|
||||
.serializer((NodeSerializer<GameMode>) ENUM_NODE_SERIALIZER)
|
||||
.build());
|
||||
|
||||
public final ConfigNode<String> GENERATOR = node(ConfigNode.builder("generator", String.class)
|
||||
@ -106,7 +99,6 @@ public class WorldConfigNodes {
|
||||
public final ConfigNode<AllowedPortalType> PORTAL_FORM = node(ConfigNode.builder("portal-form", AllowedPortalType.class)
|
||||
.defaultValue(AllowedPortalType.ALL)
|
||||
.name("portal-form")
|
||||
.serializer((NodeSerializer<AllowedPortalType>) ENUM_NODE_SERIALIZER)
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> PVP = node(ConfigNode.builder("pvp", Boolean.class)
|
||||
|
Loading…
Reference in New Issue
Block a user