Component-ify plot setup wizard

Touches #3068
This commit is contained in:
NotMyFault 2021-05-22 19:49:22 +02:00
parent b768ee6d41
commit 399d77c60f
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
5 changed files with 39 additions and 22 deletions

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.configuration; package com.plotsquared.core.configuration;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -41,20 +42,20 @@ public class ConfigurationNode {
private final String constant; private final String constant;
private final Object defaultValue; private final Object defaultValue;
private final String description; private final Caption description;
private final ConfigurationUtil.SettingValue<?> type; private final ConfigurationUtil.SettingValue<?> type;
private final Collection<String> suggestions; private final Collection<String> suggestions;
private Object value; private Object value;
public ConfigurationNode( public ConfigurationNode(
String constant, Object defaultValue, String description, String constant, Object defaultValue, Caption description,
ConfigurationUtil.SettingValue<?> type ConfigurationUtil.SettingValue<?> type
) { ) {
this(constant, defaultValue, description, type, new ArrayList<>()); this(constant, defaultValue, description, type, new ArrayList<>());
} }
public ConfigurationNode( public ConfigurationNode(
String constant, Object defaultValue, String description, String constant, Object defaultValue, Caption description,
ConfigurationUtil.SettingValue<?> type, Collection<String> suggestions ConfigurationUtil.SettingValue<?> type, Collection<String> suggestions
) { ) {
this.constant = constant; this.constant = constant;
@ -120,7 +121,7 @@ public class ConfigurationNode {
return this.constant; return this.constant;
} }
public String getDescription() { public Caption getDescription() {
return this.description; return this.description;
} }

View File

@ -28,6 +28,7 @@ package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.plot.BlockBucket;
@ -76,43 +77,43 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
@Override @Override
public ConfigurationNode[] getSettingNodes() { public ConfigurationNode[] getSettingNodes() {
return new ConfigurationNode[]{ 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 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 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 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 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 ConfigurationUtil.BLOCK_BUCKET
), ),
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, 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, new ConfigurationNode("road.width", this.ROAD_WIDTH, TranslatableCaption.of("setup.road_width"),
"Whether a top block should be placed or not", ConfigurationUtil.BOOLEAN
),
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width",
ConfigurationUtil.INTEGER 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 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 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 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 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 ConfigurationUtil.BOOLEAN
)}; )};
} }

View File

@ -29,6 +29,7 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.generator.GridPlotWorld; import com.plotsquared.core.generator.GridPlotWorld;
import com.plotsquared.core.generator.SingleWorldGenerator; import com.plotsquared.core.generator.SingleWorldGenerator;
@ -181,7 +182,7 @@ public class SinglePlotArea extends GridPlotWorld {
@Override @Override
public ConfigurationNode[] getSettingNodes() { public ConfigurationNode[] getSettingNodes() {
return new ConfigurationNode[]{ 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 @Nullable

View File

@ -85,7 +85,7 @@ public class SettingsNodeStep implements SetupStep {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("setup.setup_step"), TranslatableCaption.of("setup.setup_step"),
Template.of("step", String.valueOf(this.getId() + 1)), 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("type", this.configurationNode.getType().getType()),
Template.of("value", String.valueOf(this.configurationNode.getDefaultValue())) Template.of("value", String.valueOf(this.configurationNode.getDefaultValue()))
); );

View File

@ -128,7 +128,7 @@
"setup.setup_wrong_generator": "<prefix><red>The specified generator does not identify as BukkitPlotGenerator</red><dark_gray> - </dark_gray><dark_green>You may need to manually configure the other plugin.</dark_green>", "setup.setup_wrong_generator": "<prefix><red>The specified generator does not identify as BukkitPlotGenerator</red><dark_gray> - </dark_gray><dark_green>You may need to manually configure the other plugin.</dark_green>",
"setup.setup_world_name_format": "<prefix><red>Non [a-z0-9_.-] character in the world name:</red><gold> ", "setup.setup_world_name_format": "<prefix><red>Non [a-z0-9_.-] character in the world name:</red><gold> ",
"setup.setup_world_apply_plotsquared": "<prefix><red>The world you specified already exists. After restarting, new terrain will use </red><gold>PlotSquared</gold><red>, however you may need to reset the world for it to generate correctly!</red>", "setup.setup_world_apply_plotsquared": "<prefix><red>The world you specified already exists. After restarting, new terrain will use </red><gold>PlotSquared</gold><red>, however you may need to reset the world for it to generate correctly!</red>",
"setup.setup_partial_area": "<prefix><gold>What terrain would you like in plots?</gold>\n<dark_gray> - </dark_gray><dark_green>NONE</dark_green><dark_gray> - </dark_gray><gray>No terrain at all</gray>\n<dark_gray> - </dark_gray><dark_green>ORE</dark_green><dark_gray> - </dark_gray><gray>Just some ore veins and trees</gray>\n<dark_gray> - </dark_gray><dark_green>ROAD</dark_green><dark_gray> - </dark_gray><gray>Terrain separated by roads</gray>\n<dark_gray> - </dark_gray><dark_green>ALL</dark_green><dark_gray> - </dark_gray><gray>Entirely vanilla generation</gray>", "setup.setup_partial_area": "<prefix><gold>What terrain would you like in plots?</gold>\n<dark_gray> - </dark_gray><dark_green>ORE</dark_green><dark_gray> - </dark_gray><gray>Just some ore veins and trees</gray>\n<dark_gray> - </dark_gray><dark_green>ROAD</dark_green><dark_gray> - </dark_gray><gray>Terrain separated by roads</gray>\n<dark_gray> - </dark_gray><dark_green>ALL</dark_green><dark_gray> - </dark_gray><gray>Entirely vanilla generation</gray>",
"setup.setup_partial_area_error": "<prefix><red>You must choose the terrain!</red>", "setup.setup_partial_area_error": "<prefix><red>You must choose the terrain!</red>",
"setup.setup_area_name": "<prefix><gold>What would you like this area called?</gold>", "setup.setup_area_name": "<prefix><gold>What would you like this area called?</gold>",
"setup.setup_area_non_alphanumerical": "<prefix><red>The area ID must be alphanumerical!</red>", "setup.setup_area_non_alphanumerical": "<prefix><red>The area ID must be alphanumerical!</red>",
@ -138,6 +138,20 @@
"setup.setup_area_max_plot_id": "<prefix><gold>What should be the maximum Plot ID?</gold>", "setup.setup_area_max_plot_id": "<prefix><gold>What should be the maximum Plot ID?</gold>",
"setup.setup_area_max_plot_id_error": "<prefix><red>You must choose a valid maximum Plot ID!</red>", "setup.setup_area_max_plot_id_error": "<prefix><red>You must choose a valid maximum Plot ID!</red>",
"setup.setup_area_plot_id_greater_than_minimum": "<prefix><red>The maximum Plot ID must be greater than the minimum!</red>", "setup.setup_area_plot_id_greater_than_minimum": "<prefix><red>The maximum Plot ID must be greater than the minimum!</red>",
"setup.plot_height": "<gold>Plot height</gold>",
"setup.plot_width": "<gold>Plot width</gold>",
"setup.plot_block": "<gold>Plot block</gold><gray> (Block(s) to fill the plot with from Y0 to the defined plot height (Set in a previous step))</gray>",
"setup.top_block_boolean": "<gold>Whether a layer of blocks should be put on top of the plot block</gold>",
"setup.plot_block_floor": "<gold>Plot floor block</gold><gray> (One layer of blocks put on top of the plot block)</gray>",
"setup.top_wall_block": "<gold>Top wall block</gold><gray> (Block(s) shaping the border of an unclaimed plot)</gray>",
"setup.wall_block_claimed": "<gold>Wall block (claimed)</gold><gray> (Block(s) shaping the border of a claimed plot)</gray>",
"setup.road_width": "<gold>Road width</gold>",
"setup.road_height": "<gold>Road height</gold>",
"setup.road_block": "<gold>Road block</gold>",
"setup.wall_filling_block": "<gold>Wall filling block</gold><gray> (Block(s) been put under the plot border down to Y1)</gray>",
"setup.wall_height": "<gold>Wall height</gold>",
"setup.bedrock_boolean": "<gold>Whether a bedrock layer under the plot should be generated or not</gold>",
"setup.singleplotarea_void_world": "<gold>Void world</gold>",
"plotareatype.plot_area_type_normal": "<gray>Standard plot generation</gray>", "plotareatype.plot_area_type_normal": "<gray>Standard plot generation</gray>",
"plotareatype.plot_area_type_augmented": "<gray>Plot generation with vanilla terrain</gray>", "plotareatype.plot_area_type_augmented": "<gray>Plot generation with vanilla terrain</gray>",
"plotareatype.plot_area_type_partial": "<gray>Vanilla with clusters of plots</gray>", "plotareatype.plot_area_type_partial": "<gray>Vanilla with clusters of plots</gray>",