Skip to content

Commit

Permalink
Refactor null name with hidden method
Browse files Browse the repository at this point in the history
  • Loading branch information
benwoo1110 committed Feb 28, 2025
1 parent cfd7be2 commit e9e0407
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private <N extends Node> N node(N node) {
.comment("This just signifies the version number so we can see what version of config you have.")
.comment("NEVER TOUCH THIS VALUE")
.defaultValue(0.0)
.name(null)
.hidden()
.build());

// todo: Maybe combine with the similar method in MVCommandCompletion but that has permission checking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.mvplugins.multiverse.core.configuration.functions.NodeSerializer;
import org.mvplugins.multiverse.core.configuration.functions.NodeStringParser;
import org.mvplugins.multiverse.core.configuration.functions.NodeSuggester;
import org.mvplugins.multiverse.core.configuration.handle.StringPropertyHandle;

/**
* A node that contains a value.
Expand Down Expand Up @@ -233,6 +234,15 @@ protected Builder(@NotNull String path, @NotNull Class<T> type) {
return name;
}

/**
* Sets the name as null, and will not be shown in {@link StringPropertyHandle} as a property.
*
* @return This builder.
*/
public @NotNull B hidden() {
return name(null);
}

/**
* Sets the suggester for this node.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private <T> ConfigNode<T> node(ConfigNode.Builder<T, ?> nodeBuilder) {

final ConfigNode<String> biome = node(ConfigNode.builder("biome", String.class)
.defaultValue("@error")
.name(null));
.hidden());

final ConfigNode<Difficulty> difficulty = node(ConfigNode.builder("difficulty", Difficulty.class)
.defaultValue(Difficulty.NORMAL)
Expand Down Expand Up @@ -160,7 +160,7 @@ public Object serialize(Material object, Class<Material> type) {
final ConfigNode<World.Environment> environment = node(ConfigNode
.builder("environment", World.Environment.class)
.defaultValue(World.Environment.NORMAL)
.name(null));
.hidden());

final ConfigNode<GameMode> gamemode = node(ConfigNode.builder("gamemode", GameMode.class)
.defaultValue(GameMode.SURVIVAL)
Expand All @@ -172,7 +172,7 @@ public Object serialize(Material object, Class<Material> type) {
final ConfigNode<String> generator = node(ConfigNode.builder("generator", String.class)
// this should be set on world creation, if @error is shown in config, something went wrong
.defaultValue("@error")
.name(null));
.hidden());

final ConfigNode<Boolean> hidden = node(ConfigNode.builder("hidden", Boolean.class)
.defaultValue(false));
Expand Down Expand Up @@ -221,11 +221,11 @@ public Object serialize(Material object, Class<Material> type) {

final ConfigNode<Long> seed = node(ConfigNode.builder("seed", Long.class)
.defaultValue(Long.MIN_VALUE)
.name(null));
.hidden());

final ConfigNode<SpawnLocation> spawnLocation = node(ConfigNode.builder("spawn-location", SpawnLocation.class)
.defaultValue(NullLocation.get())
.name(null)
.hidden()
.onSetValue((oldValue, newValue) -> {
if (!(world instanceof LoadedMultiverseWorld loadedWorld)) return;
if (newValue == null || newValue instanceof NullLocation) return;
Expand Down Expand Up @@ -286,7 +286,7 @@ public Object serialize(Material object, Class<Material> type) {

final ConfigNode<Double> version = node(ConfigNode.builder("version", Double.class)
.defaultValue(CONFIG_VERSION)
.name(null));
.hidden());

// END CHECKSTYLE-SUPPRESSION: Javadoc
// END CHECKSTYLE-SUPPRESSION: VisibilityModifier
Expand Down

0 comments on commit e9e0407

Please sign in to comment.