From 399d77c60ffb9a8fd41ee0dbcd26b591e0441315 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 22 May 2021 19:49:22 +0200 Subject: [PATCH] Component-ify plot setup wizard Touches #3068 --- .../core/configuration/ConfigurationNode.java | 9 +++--- .../core/generator/ClassicPlotWorld.java | 31 ++++++++++--------- .../core/plot/world/SinglePlotArea.java | 3 +- .../core/setup/SettingsNodeStep.java | 2 +- Core/src/main/resources/lang/messages_en.json | 16 +++++++++- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java index 3c884bb23..131228b45 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java @@ -25,6 +25,7 @@ */ package com.plotsquared.core.configuration; +import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.util.StringMan; import com.sk89q.worldedit.world.block.BlockState; @@ -41,20 +42,20 @@ public class ConfigurationNode { private final String constant; private final Object defaultValue; - private final String description; + private final Caption description; private final ConfigurationUtil.SettingValue type; private final Collection suggestions; private Object value; public ConfigurationNode( - String constant, Object defaultValue, String description, + String constant, Object defaultValue, Caption description, ConfigurationUtil.SettingValue type ) { this(constant, defaultValue, description, type, new ArrayList<>()); } public ConfigurationNode( - String constant, Object defaultValue, String description, + String constant, Object defaultValue, Caption description, ConfigurationUtil.SettingValue type, Collection suggestions ) { this.constant = constant; @@ -120,7 +121,7 @@ public class ConfigurationNode { return this.constant; } - public String getDescription() { + public Caption getDescription() { return this.description; } diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java index 72cc41df6..eec12e696 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java @@ -28,6 +28,7 @@ package com.plotsquared.core.generator; import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationUtil; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.plot.BlockBucket; @@ -76,43 +77,43 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { @Override public ConfigurationNode[] getSettingNodes() { return new ConfigurationNode[]{ - new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", + new ConfigurationNode("plot.height", this.PLOT_HEIGHT, TranslatableCaption.of("setup.plot_height"), ConfigurationUtil.INTEGER ), - new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", + new ConfigurationNode("plot.size", this.PLOT_WIDTH, TranslatableCaption.of("setup.plot_width"), ConfigurationUtil.INTEGER ), - new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", + new ConfigurationNode("plot.filling", this.MAIN_BLOCK, TranslatableCaption.of("setup.plot_block"), ConfigurationUtil.BLOCK_BUCKET ), - new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", + new ConfigurationNode("wall.place_top_block", this.PLACE_TOP_BLOCK, + TranslatableCaption.of("setup.top_block_boolean"), ConfigurationUtil.BOOLEAN + ), + new ConfigurationNode("plot.floor", this.TOP_BLOCK, TranslatableCaption.of("setup.plot_block_floor"), ConfigurationUtil.BLOCK_BUCKET ), - new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", + new ConfigurationNode("wall.block", this.WALL_BLOCK, TranslatableCaption.of("setup.top_wall_block"), ConfigurationUtil.BLOCK_BUCKET ), new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, - "Wall block (claimed)", ConfigurationUtil.BLOCK_BUCKET + TranslatableCaption.of("setup.wall_block_claimed"), ConfigurationUtil.BLOCK_BUCKET ), - new ConfigurationNode("wall.place_top_block", this.PLACE_TOP_BLOCK, - "Whether a top block should be placed or not", ConfigurationUtil.BOOLEAN - ), - new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", + new ConfigurationNode("road.width", this.ROAD_WIDTH, TranslatableCaption.of("setup.road_width"), ConfigurationUtil.INTEGER ), - new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", + new ConfigurationNode("road.height", this.ROAD_HEIGHT, TranslatableCaption.of("setup.road_height"), ConfigurationUtil.INTEGER ), - new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", + new ConfigurationNode("road.block", this.ROAD_BLOCK, TranslatableCaption.of("setup.road_block"), ConfigurationUtil.BLOCK_BUCKET ), - new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", + new ConfigurationNode("wall.filling", this.WALL_FILLING, TranslatableCaption.of("setup.wall_filling_block"), ConfigurationUtil.BLOCK_BUCKET ), - new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", + new ConfigurationNode("wall.height", this.WALL_HEIGHT, TranslatableCaption.of("setup.wall_height"), ConfigurationUtil.INTEGER ), - new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", + new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, TranslatableCaption.of("setup.bedrock_boolean"), ConfigurationUtil.BOOLEAN )}; } diff --git a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java index be33a72ad..a54e74ce9 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java @@ -29,6 +29,7 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationUtil; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.generator.GridPlotWorld; import com.plotsquared.core.generator.SingleWorldGenerator; @@ -181,7 +182,7 @@ public class SinglePlotArea extends GridPlotWorld { @Override public ConfigurationNode[] getSettingNodes() { return new ConfigurationNode[]{ - new ConfigurationNode("void", this.VOID, "Void world", ConfigurationUtil.BOOLEAN)}; + new ConfigurationNode("void", this.VOID, TranslatableCaption.of("setup.singleplotarea_void_world"), ConfigurationUtil.BOOLEAN)}; } @Nullable diff --git a/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java b/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java index 4f20e426e..8ff2a944b 100644 --- a/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java +++ b/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java @@ -85,7 +85,7 @@ public class SettingsNodeStep implements SetupStep { plotPlayer.sendMessage( TranslatableCaption.of("setup.setup_step"), Template.of("step", String.valueOf(this.getId() + 1)), - Template.of("description", this.configurationNode.getDescription()), + Template.of("description", this.configurationNode.getDescription().getComponent(plotPlayer)), Template.of("type", this.configurationNode.getType().getType()), Template.of("value", String.valueOf(this.configurationNode.getDefaultValue())) ); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 498648915..af4d14c9b 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -128,7 +128,7 @@ "setup.setup_wrong_generator": "The specified generator does not identify as BukkitPlotGenerator - You may need to manually configure the other plugin.", "setup.setup_world_name_format": "Non [a-z0-9_.-] character in the world name: ", "setup.setup_world_apply_plotsquared": "The world you specified already exists. After restarting, new terrain will use PlotSquared, however you may need to reset the world for it to generate correctly!", - "setup.setup_partial_area": "What terrain would you like in plots?\n - NONE - No terrain at all\n - ORE - Just some ore veins and trees\n - ROAD - Terrain separated by roads\n - ALL - Entirely vanilla generation", + "setup.setup_partial_area": "What terrain would you like in plots?\n - ORE - Just some ore veins and trees\n - ROAD - Terrain separated by roads\n - ALL - Entirely vanilla generation", "setup.setup_partial_area_error": "You must choose the terrain!", "setup.setup_area_name": "What would you like this area called?", "setup.setup_area_non_alphanumerical": "The area ID must be alphanumerical!", @@ -138,6 +138,20 @@ "setup.setup_area_max_plot_id": "What should be the maximum Plot ID?", "setup.setup_area_max_plot_id_error": "You must choose a valid maximum Plot ID!", "setup.setup_area_plot_id_greater_than_minimum": "The maximum Plot ID must be greater than the minimum!", + "setup.plot_height": "Plot height", + "setup.plot_width": "Plot width", + "setup.plot_block": "Plot block (Block(s) to fill the plot with from Y0 to the defined plot height (Set in a previous step))", + "setup.top_block_boolean": "Whether a layer of blocks should be put on top of the plot block", + "setup.plot_block_floor": "Plot floor block (One layer of blocks put on top of the plot block)", + "setup.top_wall_block": "Top wall block (Block(s) shaping the border of an unclaimed plot)", + "setup.wall_block_claimed": "Wall block (claimed) (Block(s) shaping the border of a claimed plot)", + "setup.road_width": "Road width", + "setup.road_height": "Road height", + "setup.road_block": "Road block", + "setup.wall_filling_block": "Wall filling block (Block(s) been put under the plot border down to Y1)", + "setup.wall_height": "Wall height", + "setup.bedrock_boolean": "Whether a bedrock layer under the plot should be generated or not", + "setup.singleplotarea_void_world": "Void world", "plotareatype.plot_area_type_normal": "Standard plot generation", "plotareatype.plot_area_type_augmented": "Plot generation with vanilla terrain", "plotareatype.plot_area_type_partial": "Vanilla with clusters of plots",