mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Remove usage of SetupObject
This commit is contained in:
parent
5165c439fc
commit
ae1427b189
10 changed files with 114 additions and 507 deletions
|
@ -81,12 +81,13 @@ import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
|
||||||
import com.plotsquared.core.plot.message.PlainChatManager;
|
import com.plotsquared.core.plot.message.PlainChatManager;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.QueueProvider;
|
import com.plotsquared.core.queue.QueueProvider;
|
||||||
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
|
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||||
import com.plotsquared.core.util.ChatManager;
|
import com.plotsquared.core.util.ChatManager;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.ConsoleColors;
|
import com.plotsquared.core.util.ConsoleColors;
|
||||||
|
@ -992,14 +993,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||||
ConfigurationSection worldConfig =
|
ConfigurationSection worldConfig =
|
||||||
PlotSquared.get().worlds.getConfigurationSection("worlds." + worldName);
|
PlotSquared.get().worlds.getConfigurationSection("worlds." + worldName);
|
||||||
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
||||||
SetupObject setup = new SetupObject();
|
PlotAreaBuilder builder = new PlotAreaBuilder()
|
||||||
setup.plotManager = manager;
|
.plotManager(manager)
|
||||||
setup.setupGenerator = worldConfig.getString("generator.init", manager);
|
.generatorName(worldConfig.getString("generator.init", manager))
|
||||||
setup.type = MainUtil.getType(worldConfig);
|
.plotAreaType(MainUtil.getType(worldConfig))
|
||||||
setup.terrain = MainUtil.getTerrain(worldConfig);
|
.terrainType(MainUtil.getTerrain(worldConfig))
|
||||||
setup.step = new ConfigurationNode[0];
|
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
|
||||||
setup.world = worldName;
|
.worldName(worldName);
|
||||||
SetupUtils.manager.setupWorld(setup);
|
SetupUtils.manager.setupWorld(builder);
|
||||||
world = Bukkit.getWorld(worldName);
|
world = Bukkit.getWorld(worldName);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -39,8 +39,8 @@ import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
|
@ -186,20 +186,15 @@ public class Area extends SubCommand {
|
||||||
final BlockVector3 singlePos1 = selectedRegion.getMinimumPoint();
|
final BlockVector3 singlePos1 = selectedRegion.getMinimumPoint();
|
||||||
|
|
||||||
// Now the schematic is saved, which is wonderful!
|
// Now the schematic is saved, which is wonderful!
|
||||||
final SetupObject singleSetup = new SetupObject();
|
PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld)
|
||||||
singleSetup.world = hybridPlotWorld.getWorldName();
|
.plotManager(PlotSquared.imp().getPluginName())
|
||||||
singleSetup.id = hybridPlotWorld.getId();
|
.generatorName(PlotSquared.imp().getPluginName())
|
||||||
singleSetup.terrain = hybridPlotWorld.getTerrain();
|
.maximumId(plotId)
|
||||||
singleSetup.type = hybridPlotWorld.getType();
|
.minimumId(plotId); // TODO will throw exception right now
|
||||||
singleSetup.plotManager = PlotSquared.imp().getPluginName();
|
|
||||||
singleSetup.setupGenerator = PlotSquared.imp().getPluginName();
|
|
||||||
singleSetup.step = hybridPlotWorld.getSettingNodes();
|
|
||||||
singleSetup.max = plotId;
|
|
||||||
singleSetup.min = plotId;
|
|
||||||
Runnable singleRun = () -> {
|
Runnable singleRun = () -> {
|
||||||
final String path =
|
final String path =
|
||||||
"worlds." + hybridPlotWorld.getWorldName() + ".areas." + hybridPlotWorld.getId() + '-'
|
"worlds." + hybridPlotWorld.getWorldName() + ".areas." + hybridPlotWorld.getId() + '-'
|
||||||
+ singleSetup.min + '-' + singleSetup.max;
|
+ singleBuilder.minimumId() + '-' + singleBuilder.maximumId();
|
||||||
final int offsetX = singlePos1.getX();
|
final int offsetX = singlePos1.getX();
|
||||||
final int offsetZ = singlePos1.getZ();
|
final int offsetZ = singlePos1.getZ();
|
||||||
if (offsetX != 0) {
|
if (offsetX != 0) {
|
||||||
|
@ -210,7 +205,7 @@ public class Area extends SubCommand {
|
||||||
PlotSquared.get().worlds
|
PlotSquared.get().worlds
|
||||||
.set(path + ".road.offset.z", offsetZ);
|
.set(path + ".road.offset.z", offsetZ);
|
||||||
}
|
}
|
||||||
final String world = SetupUtils.manager.setupWorld(singleSetup);
|
final String world = SetupUtils.manager.setupWorld(singleBuilder);
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
if (WorldUtil.IMP.isWorld(world)) {
|
||||||
PlotSquared.get().loadWorld(world, null);
|
PlotSquared.get().loadWorld(world, null);
|
||||||
MainUtil.sendMessage(player, Captions.SINGLE_AREA_CREATED);
|
MainUtil.sendMessage(player, Captions.SINGLE_AREA_CREATED);
|
||||||
|
@ -286,19 +281,14 @@ public class Area extends SubCommand {
|
||||||
.send(player, areas.iterator().next().toString());
|
.send(player, areas.iterator().next().toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final SetupObject object = new SetupObject();
|
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area)
|
||||||
object.world = area.getWorldName();
|
.plotManager(PlotSquared.imp().getPluginName())
|
||||||
object.id = area.getId();
|
.generatorName(PlotSquared.imp().getPluginName())
|
||||||
object.terrain = area.getTerrain();
|
.minimumId(new PlotId(1, 1))
|
||||||
object.type = area.getType();
|
.maximumId(new PlotId(numX, numZ));
|
||||||
object.min = new PlotId(1, 1);
|
|
||||||
object.max = new PlotId(numX, numZ);
|
|
||||||
object.plotManager = PlotSquared.imp().getPluginName();
|
|
||||||
object.setupGenerator = PlotSquared.imp().getPluginName();
|
|
||||||
object.step = area.getSettingNodes();
|
|
||||||
final String path =
|
final String path =
|
||||||
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
|
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-'
|
||||||
+ object.min + '-' + object.max;
|
+ builder.minimumId() + '-' + builder.maximumId();
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
if (offsetX != 0) {
|
if (offsetX != 0) {
|
||||||
PlotSquared.get().worlds
|
PlotSquared.get().worlds
|
||||||
|
@ -308,7 +298,7 @@ public class Area extends SubCommand {
|
||||||
PlotSquared.get().worlds
|
PlotSquared.get().worlds
|
||||||
.set(path + ".road.offset.z", offsetZ);
|
.set(path + ".road.offset.z", offsetZ);
|
||||||
}
|
}
|
||||||
final String world = SetupUtils.manager.setupWorld(object);
|
final String world = SetupUtils.manager.setupWorld(builder);
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
if (WorldUtil.IMP.isWorld(world)) {
|
||||||
PlotSquared.get().loadWorld(world, null);
|
PlotSquared.get().loadWorld(world, null);
|
||||||
Captions.SETUP_FINISHED.send(player);
|
Captions.SETUP_FINISHED.send(player);
|
||||||
|
@ -346,9 +336,9 @@ public class Area extends SubCommand {
|
||||||
} else {
|
} else {
|
||||||
id = null;
|
id = null;
|
||||||
}
|
}
|
||||||
final SetupObject object = new SetupObject();
|
PlotAreaBuilder builder = new PlotAreaBuilder();
|
||||||
object.world = split[0];
|
builder.worldName(split[0]);
|
||||||
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id,
|
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
||||||
PlotSquared.get().IMP.getDefaultGenerator(), null, null);
|
PlotSquared.get().IMP.getDefaultGenerator(), null, null);
|
||||||
PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id);
|
PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id);
|
||||||
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
||||||
|
@ -410,13 +400,13 @@ public class Area extends SubCommand {
|
||||||
pa.setTerrain(PlotAreaTerrainType.fromString(pair[1])
|
pa.setTerrain(PlotAreaTerrainType.fromString(pair[1])
|
||||||
.orElseThrow(() -> new IllegalArgumentException(
|
.orElseThrow(() -> new IllegalArgumentException(
|
||||||
pair[1] + " is not a valid terrain.")));
|
pair[1] + " is not a valid terrain.")));
|
||||||
object.terrain = pa.getTerrain();
|
builder.terrainType(pa.getTerrain());
|
||||||
break;
|
break;
|
||||||
case "type":
|
case "type":
|
||||||
pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow(
|
pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow(
|
||||||
() -> new IllegalArgumentException(
|
() -> new IllegalArgumentException(
|
||||||
pair[1] + " is not a valid type.")));
|
pair[1] + " is not a valid type.")));
|
||||||
object.type = pa.getType();
|
builder.plotAreaType(pa.getType());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Captions.COMMAND_SYNTAX.send(player, getCommandString()
|
Captions.COMMAND_SYNTAX.send(player, getCommandString()
|
||||||
|
@ -438,9 +428,9 @@ public class Area extends SubCommand {
|
||||||
PlotSquared.get().worlds.getConfigurationSection(path);
|
PlotSquared.get().worlds.getConfigurationSection(path);
|
||||||
pa.saveConfiguration(section);
|
pa.saveConfiguration(section);
|
||||||
pa.loadConfiguration(section);
|
pa.loadConfiguration(section);
|
||||||
object.plotManager = PlotSquared.imp().getPluginName();
|
builder.plotManager(PlotSquared.imp().getPluginName());
|
||||||
object.setupGenerator = PlotSquared.imp().getPluginName();
|
builder.generatorName(PlotSquared.imp().getPluginName());
|
||||||
String world = SetupUtils.manager.setupWorld(object);
|
String world = SetupUtils.manager.setupWorld(builder);
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
if (WorldUtil.IMP.isWorld(world)) {
|
||||||
Captions.SETUP_FINISHED.send(player);
|
Captions.SETUP_FINISHED.send(player);
|
||||||
player.teleport(WorldUtil.IMP.getSpawn(world),
|
player.teleport(WorldUtil.IMP.getSpawn(world),
|
||||||
|
@ -475,9 +465,9 @@ public class Area extends SubCommand {
|
||||||
TeleportCause.COMMAND);
|
TeleportCause.COMMAND);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object.terrain = PlotAreaTerrainType.NONE;
|
builder.terrainType(PlotAreaTerrainType.NONE);
|
||||||
object.type = PlotAreaType.NORMAL;
|
builder.plotAreaType(PlotAreaType.NORMAL);
|
||||||
SetupUtils.manager.setupWorld(object);
|
SetupUtils.manager.setupWorld(builder);
|
||||||
player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
|
player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
|
||||||
TeleportCause.COMMAND);
|
TeleportCause.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,43 +27,19 @@ package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
|
||||||
import com.plotsquared.core.configuration.StaticCaption;
|
|
||||||
import com.plotsquared.core.events.TeleportCause;
|
|
||||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
|
||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
|
||||||
import com.plotsquared.core.plot.PlotId;
|
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
|
||||||
import com.plotsquared.core.setup.SetupProcess;
|
import com.plotsquared.core.setup.SetupProcess;
|
||||||
import com.plotsquared.core.setup.SetupStep;
|
import com.plotsquared.core.setup.SetupStep;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.StringMan;
|
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "setup",
|
@CommandDeclaration(command = "setup",
|
||||||
permission = "plots.admin.command.setup",
|
permission = "plots.admin.command.setup",
|
||||||
|
@ -72,14 +48,12 @@ import java.util.UUID;
|
||||||
aliases = {"create"},
|
aliases = {"create"},
|
||||||
category = CommandCategory.ADMINISTRATION)
|
category = CommandCategory.ADMINISTRATION)
|
||||||
public class Setup extends SubCommand {
|
public class Setup extends SubCommand {
|
||||||
|
private static final Collection<Command> specialCommands = Arrays.asList(
|
||||||
|
new Command(null, false, "back", "", RequiredType.NONE, null) {},
|
||||||
|
new Command(null, false, "cancel", "", RequiredType.NONE, null) {});
|
||||||
|
|
||||||
private static boolean d(String s) {
|
|
||||||
return s.chars().allMatch((i) -> {
|
|
||||||
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayGenerators(PlotPlayer player) {
|
public void displayGenerators(PlotPlayer<?> player) {
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
message.append("&6What generator do you want?");
|
message.append("&6What generator do you want?");
|
||||||
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||||
|
@ -105,7 +79,7 @@ public class Setup extends SubCommand {
|
||||||
process = new SetupProcess();
|
process = new SetupProcess();
|
||||||
player.setMeta("setup", process);
|
player.setMeta("setup", process);
|
||||||
SetupUtils.manager.updateGenerators();
|
SetupUtils.manager.updateGenerators();
|
||||||
com.plotsquared.core.setup.SetupStep step = process.getCurrentStep();
|
SetupStep step = process.getCurrentStep();
|
||||||
step.announce(player);
|
step.announce(player);
|
||||||
displayGenerators(player);
|
displayGenerators(player);
|
||||||
return true;
|
return true;
|
||||||
|
@ -123,277 +97,11 @@ public class Setup extends SubCommand {
|
||||||
process.getCurrentStep().announce(player);
|
process.getCurrentStep().announce(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
process.getCurrentStep().announce(player);
|
process.getCurrentStep().announce(player);
|
||||||
// TODO return only
|
|
||||||
if (true) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// going through setup
|
|
||||||
SetupObject object = player.getMeta("setup");
|
|
||||||
if (object == null) {
|
|
||||||
object = new SetupObject();
|
|
||||||
player.setMeta("setup", object);
|
|
||||||
SetupUtils.manager.updateGenerators();
|
|
||||||
sendMessage(player, Captions.SETUP_INIT);
|
|
||||||
displayGenerators(player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
if (args[0].equalsIgnoreCase("cancel")) {
|
|
||||||
player.deleteMeta("setup");
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_CANCELLED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("back")) {
|
|
||||||
if (object.setup_index > 0) {
|
|
||||||
object.setup_index--;
|
|
||||||
ConfigurationNode node = object.step[object.setup_index];
|
|
||||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
|
||||||
node.getDescription(), node.getType().getType(),
|
|
||||||
String.valueOf(node.getDefaultValue()));
|
|
||||||
return false;
|
|
||||||
} else if (object.current > 0) {
|
|
||||||
object.current--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int index = object.current;
|
|
||||||
switch (index) {
|
|
||||||
case 0: // choose generator
|
|
||||||
if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) {
|
|
||||||
String prefix = "\n&8 - &7";
|
|
||||||
MainUtil.sendMessage(player,
|
|
||||||
Captions.SETUP_WORLD_GENERATOR_ERROR + prefix + StringMan
|
|
||||||
.join(SetupUtils.generators.keySet(), prefix)
|
|
||||||
.replaceAll(PlotSquared.imp().getPluginName(),
|
|
||||||
"&2" + PlotSquared.imp().getPluginName()));
|
|
||||||
sendMessage(player, Captions.SETUP_INIT);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
object.setupGenerator = args[0];
|
|
||||||
object.current++;
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_TYPE);
|
|
||||||
break;
|
|
||||||
case 1: // choose world type
|
|
||||||
List<String> allTypes = Arrays.asList("normal", "augmented", "partial");
|
|
||||||
List<String> allDesc = Arrays
|
|
||||||
.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
|
||||||
"Vanilla with clusters of plots");
|
|
||||||
ArrayList<String> types = new ArrayList<>();
|
|
||||||
if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
|
|
||||||
types.add("normal");
|
|
||||||
}
|
|
||||||
types.add("augmented");
|
|
||||||
types.add("partial");
|
|
||||||
Optional<PlotAreaType> plotAreaType;
|
|
||||||
if (args.length != 1 || !(plotAreaType = PlotAreaType.fromString(args[0]))
|
|
||||||
.isPresent()) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_TYPE_ERROR);
|
|
||||||
for (String type : types) {
|
|
||||||
int i = allTypes.indexOf(type);
|
|
||||||
if (type.equals("normal")) {
|
|
||||||
MainUtil
|
|
||||||
.sendMessage(player, "&8 - &2" + type + " &8-&7 " + allDesc.get(i));
|
|
||||||
} else {
|
|
||||||
MainUtil
|
|
||||||
.sendMessage(player, "&8 - &7" + type + " &8-&7 " + allDesc.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
object.type = plotAreaType.orElse(PlotAreaType.NORMAL);
|
|
||||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
|
||||||
if (object.type == PlotAreaType.NORMAL) {
|
|
||||||
object.current = 6;
|
|
||||||
if (object.step == null) {
|
|
||||||
object.plotManager = object.setupGenerator;
|
|
||||||
object.step =
|
|
||||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
|
||||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null)
|
|
||||||
.getSettingNodes();
|
|
||||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
|
||||||
.processSetup(object);
|
|
||||||
}
|
|
||||||
if (object.step.length == 0) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_NAME);
|
|
||||||
object.setup_index = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
|
||||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
|
||||||
step.getDescription(), step.getType().getType(),
|
|
||||||
String.valueOf(step.getDefaultValue()));
|
|
||||||
} else {
|
|
||||||
if (gen.isFull()) {
|
|
||||||
object.plotManager = object.setupGenerator;
|
|
||||||
object.setupGenerator = null;
|
|
||||||
object.step =
|
|
||||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
|
||||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null)
|
|
||||||
.getSettingNodes();
|
|
||||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
|
||||||
.processSetup(object);
|
|
||||||
} else {
|
|
||||||
object.plotManager = PlotSquared.imp().getPluginName();
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WRONG_GENERATOR);
|
|
||||||
object.step =
|
|
||||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
|
||||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null)
|
|
||||||
.getSettingNodes();
|
|
||||||
}
|
|
||||||
if (object.type == PlotAreaType.PARTIAL) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_NAME);
|
|
||||||
object.current++;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_PARTIAL_AREA);
|
|
||||||
object.current = 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: // area id
|
|
||||||
if (!StringMan.isAlphanumericUnd(args[0])) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_NON_ALPHANUMERICAL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (PlotArea area : PlotSquared.get().getPlotAreas()) {
|
|
||||||
if (area.getId() != null && area.getId().equalsIgnoreCase(args[0])) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_INVALID_ID);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
object.id = args[0];
|
|
||||||
object.current++;
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_MIN_PLOT_ID);
|
|
||||||
break;
|
|
||||||
case 3: // min
|
|
||||||
try {
|
|
||||||
object.min = PlotId.fromString(args[0]);
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_MIN_PLOT_ID_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
object.current++;
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_MAX_PLOT_ID);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// max
|
|
||||||
PlotId id;
|
|
||||||
try {
|
|
||||||
id = PlotId.fromString(args[0]);
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_MAX_PLOT_ID_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (id.x <= object.min.x || id.y <= object.min.y) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_AREA_PLOT_ID_GREATER_THAN_MINIMUM);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
object.max = id;
|
|
||||||
object.current++;
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_PARTIAL_AREA);
|
|
||||||
break;
|
|
||||||
case 5: { // Choose terrain
|
|
||||||
Optional<PlotAreaTerrainType> optTerrain;
|
|
||||||
if (args.length != 1 || !(optTerrain = PlotAreaTerrainType.fromString(args[0]))
|
|
||||||
.isPresent()) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_PARTIAL_AREA_ERROR,
|
|
||||||
Captions.SETUP_PARTIAL_AREA);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
object.terrain = optTerrain.get();
|
|
||||||
object.current++;
|
|
||||||
if (object.step == null) {
|
|
||||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
|
||||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null)
|
|
||||||
.getSettingNodes();
|
|
||||||
}
|
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
|
||||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
|
||||||
step.getDescription(), step.getType().getType(),
|
|
||||||
String.valueOf(step.getDefaultValue()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 6: // world setup
|
|
||||||
if (object.setup_index == object.step.length) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_NAME);
|
|
||||||
object.setup_index = 0;
|
|
||||||
object.current++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
|
||||||
if (args.length < 1) {
|
|
||||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
|
||||||
step.getDescription(), step.getType().getType(),
|
|
||||||
String.valueOf(step.getDefaultValue()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean valid = false;
|
|
||||||
try {
|
|
||||||
valid = step.isValid(args[0]);
|
|
||||||
} catch (final ConfigurationUtil.UnsafeBlockException e) {
|
|
||||||
Captions.NOT_ALLOWED_BLOCK.send(player, e.getUnsafeBlock().toString());
|
|
||||||
}
|
|
||||||
if (valid) {
|
|
||||||
step.setValue(args[0]);
|
|
||||||
Object value = step.getValue();
|
|
||||||
sendMessage(player, Captions.SETUP_VALID_ARG, step.getConstant(), value);
|
|
||||||
object.setup_index++;
|
|
||||||
if (object.setup_index == object.step.length) {
|
|
||||||
onCommand(player, args);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
step = object.step[object.setup_index];
|
|
||||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
|
||||||
step.getDescription(), step.getType().getType(),
|
|
||||||
String.valueOf(step.getDefaultValue()));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
sendMessage(player, Captions.SETUP_INVALID_ARG, args[0], step.getConstant());
|
|
||||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
|
||||||
step.getDescription(), step.getType().getType(),
|
|
||||||
String.valueOf(step.getDefaultValue()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case 7:
|
|
||||||
if (args.length != 1) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_NAME_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!d(args[0])) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_NAME_FORMAT + args[0]);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (WorldUtil.IMP.isWorld(args[0])) {
|
|
||||||
if (PlotSquared.get().hasPlotArea(args[0])) {
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_NAME_TAKEN);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_APPLY_PLOTSQUARED);
|
|
||||||
}
|
|
||||||
object.world = args[0];
|
|
||||||
player.deleteMeta("setup");
|
|
||||||
String world;
|
|
||||||
if (object.setupManager == null) {
|
|
||||||
world = SetupUtils.manager.setupWorld(object);
|
|
||||||
} else {
|
|
||||||
world = object.setupManager.setupWorld(object);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND);
|
|
||||||
} catch (Exception e) {
|
|
||||||
player.sendMessage("&cAn error occurred. See console for more information");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
sendMessage(player, Captions.SETUP_FINISHED, object.world);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
@Override public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
||||||
|
@ -406,136 +114,15 @@ public class Setup extends SubCommand {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
SetupStep setupStep = process.getCurrentStep();
|
SetupStep setupStep = process.getCurrentStep();
|
||||||
return setupStep.createSuggestions(player, space ? "" : args[0]);
|
List<Command> commands = new ArrayList<>(setupStep.createSuggestions(player, space ? "" : args[0]));
|
||||||
|
tryAddSubCommand("back", args[0], commands);
|
||||||
|
tryAddSubCommand("cancel", args[0], commands);
|
||||||
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private static final class StepPickGenerator extends SetupStep {
|
private void tryAddSubCommand(String subCommand, String argument, List<Command> suggestions) {
|
||||||
|
if (!argument.isEmpty() && subCommand.startsWith(argument)) {
|
||||||
@Getter private String generator;
|
suggestions.add(new Command(null, false, subCommand, "", RequiredType.NONE, null) {});
|
||||||
|
|
||||||
public StepPickGenerator() {
|
|
||||||
super("generator");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Collection<PlotMessage> showDescriptionMessage() {
|
|
||||||
SetupUtils.manager.updateGenerators();
|
|
||||||
final List<PlotMessage> messages = new ArrayList<>();
|
|
||||||
messages.add(new PlotMessage("What generator do you want?").color("$6"));
|
|
||||||
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
|
||||||
final PlotMessage plotMessage = new PlotMessage(" - ").color("$8");
|
|
||||||
if (entry.getKey().equals(PlotSquared.imp().getPluginName())) {
|
|
||||||
plotMessage.text(entry.getKey()).color("$8").tooltip("Select this generator")
|
|
||||||
.color("$2").command("/plot setup generator " + entry.getKey())
|
|
||||||
.text(" (Default Generator)").color("$7");
|
|
||||||
} else if (entry.getValue().isFull()) {
|
|
||||||
plotMessage.text(entry.getKey()).color("$8").tooltip("Select this generator")
|
|
||||||
.color("$7").command("/plot setup generator " + entry.getKey())
|
|
||||||
.text(" (Plot Generator)").color("$7");
|
|
||||||
} else {
|
|
||||||
plotMessage.text(entry.getKey()).color("$8").tooltip("Select this generator")
|
|
||||||
.color("$7").command("/plot setup generator " + entry.getKey())
|
|
||||||
.text(" (Unknown Structure)").color("$7");
|
|
||||||
}
|
|
||||||
messages.add(plotMessage);
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean parseInput(String input) {
|
|
||||||
this.generator = input.toLowerCase();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Override public String getDefault() {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final class StepWorldType extends SetupStep {
|
|
||||||
|
|
||||||
private static final Map<String, String> WORLD_TYPES = new HashMap<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
WORLD_TYPES.put("default", "Standard plot generation");
|
|
||||||
WORLD_TYPES.put("augmented", "Plot generation with vanilla terrain");
|
|
||||||
WORLD_TYPES.put("partial", "Vanilla clusters of plots");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter private String worldType;
|
|
||||||
|
|
||||||
public StepWorldType() {
|
|
||||||
super("type");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Collection<PlotMessage> showDescriptionMessage() {
|
|
||||||
final List<PlotMessage> messages = new ArrayList<>();
|
|
||||||
messages.add(new PlotMessage("What world type do you want?").color("$6"));
|
|
||||||
for (final Map.Entry<String, String> worldType : WORLD_TYPES.entrySet()) {
|
|
||||||
messages.add(new PlotMessage(" - ").color("$8").text(worldType.getKey())
|
|
||||||
.color(worldType.getKey().equals(getDefault()) ? "$2" : "$7")
|
|
||||||
.tooltip("Select this world type")
|
|
||||||
.command("/plot setup type " + worldType.getKey())
|
|
||||||
.text(" (" + worldType.getValue() + ")").color("$7"));
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean parseInput(String input) {
|
|
||||||
if (!WORLD_TYPES.containsKey(input.toLowerCase())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.worldType = input.toLowerCase();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getDefault() {
|
|
||||||
return "default";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(of = "uuid")
|
|
||||||
@AllArgsConstructor
|
|
||||||
private static class SetupContext {
|
|
||||||
|
|
||||||
private final UUID uuid;
|
|
||||||
|
|
||||||
@Getter private String step;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
private abstract static class SetupStep {
|
|
||||||
|
|
||||||
private final String stepName;
|
|
||||||
|
|
||||||
public abstract Collection<PlotMessage> showDescriptionMessage();
|
|
||||||
|
|
||||||
public abstract boolean parseInput(String input);
|
|
||||||
|
|
||||||
public final PlotMessage getUsage() {
|
|
||||||
return new PlotMessage("Usage: ").color("$1")
|
|
||||||
.text("/plot setup " + this.stepName + " <value>").color("$2").suggest(
|
|
||||||
"/plot setup " + this.stepName + (this.getDefault() != null ?
|
|
||||||
this.getDefault() :
|
|
||||||
""));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable public abstract String getDefault();
|
|
||||||
|
|
||||||
public void sendToPlayer(@NonNull final PlotPlayer plotPlayer) {
|
|
||||||
new PlotMessage("Setup Step: ").color("$6").text(this.stepName).color("$7")
|
|
||||||
.send(plotPlayer);
|
|
||||||
this.getUsage().send(plotPlayer);
|
|
||||||
this.showDescriptionMessage().forEach(plotMessage -> plotMessage.send(plotPlayer));
|
|
||||||
if (this.getDefault() != null) {
|
|
||||||
new PlotMessage("Default: ").color("$6").text(this.getDefault()).color("$7");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,9 @@ import com.plotsquared.core.events.TeleportCause;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
|
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||||
import com.plotsquared.core.util.FileBytes;
|
import com.plotsquared.core.util.FileBytes;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
|
@ -181,15 +182,15 @@ public class Template extends SubCommand {
|
||||||
String manager =
|
String manager =
|
||||||
worldConfig.getString("generator.plugin", PlotSquared.imp().getPluginName());
|
worldConfig.getString("generator.plugin", PlotSquared.imp().getPluginName());
|
||||||
String generator = worldConfig.getString("generator.init", manager);
|
String generator = worldConfig.getString("generator.init", manager);
|
||||||
SetupObject setup = new SetupObject();
|
PlotAreaBuilder builder = new PlotAreaBuilder()
|
||||||
setup.type = MainUtil.getType(worldConfig);
|
.plotAreaType(MainUtil.getType(worldConfig))
|
||||||
setup.terrain = MainUtil.getTerrain(worldConfig);
|
.terrainType(MainUtil.getTerrain(worldConfig))
|
||||||
|
.plotManager(manager)
|
||||||
|
.generatorName(generator)
|
||||||
|
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
|
||||||
|
.worldName(world);
|
||||||
|
|
||||||
setup.plotManager = manager;
|
SetupUtils.manager.setupWorld(builder);
|
||||||
setup.setupGenerator = generator;
|
|
||||||
setup.step = new ConfigurationNode[0];
|
|
||||||
setup.world = world;
|
|
||||||
SetupUtils.manager.setupWorld(setup);
|
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
||||||
MainUtil.sendMessage(player, "Done!");
|
MainUtil.sendMessage(player, "Done!");
|
||||||
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND);
|
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND);
|
||||||
|
|
|
@ -38,8 +38,9 @@ import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.plot.PlotSettings;
|
import com.plotsquared.core.plot.PlotSettings;
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
|
||||||
import com.plotsquared.core.plot.flag.FlagContainer;
|
import com.plotsquared.core.plot.flag.FlagContainer;
|
||||||
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
|
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
|
@ -78,13 +79,13 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||||
if (WorldUtil.IMP.isWorld(worldName)) {
|
if (WorldUtil.IMP.isWorld(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetupObject setup = new SetupObject();
|
PlotAreaBuilder builder = new PlotAreaBuilder()
|
||||||
setup.plotManager = "PlotSquared:single";
|
.plotManager("PlotSquared:single")
|
||||||
setup.setupGenerator = "PlotSquared:single";
|
.generatorName("PlotSquared:single")
|
||||||
setup.type = getType();
|
.plotAreaType(getType())
|
||||||
setup.terrain = getTerrain();
|
.terrainType(getTerrain())
|
||||||
setup.step = new ConfigurationNode[0];
|
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
|
||||||
setup.world = worldName;
|
.worldName(worldName);
|
||||||
|
|
||||||
File container = PlotSquared.imp().getWorldContainer();
|
File container = PlotSquared.imp().getWorldContainer();
|
||||||
File destination = new File(container, worldName);
|
File destination = new File(container, worldName);
|
||||||
|
@ -96,7 +97,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Duplicate 0;0
|
// Duplicate 0;0
|
||||||
if (setup.type != PlotAreaType.NORMAL) {
|
if (builder.plotAreaType() != PlotAreaType.NORMAL) {
|
||||||
if (!destination.exists()) {
|
if (!destination.exists()) {
|
||||||
File src = new File(container, "0.0");
|
File src = new File(container, "0.0");
|
||||||
if (src.exists()) {
|
if (src.exists()) {
|
||||||
|
@ -132,7 +133,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupUtils.manager.setupWorld(setup);
|
SetupUtils.manager.setupWorld(builder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// String worldName = plot.getWorldName();
|
// String worldName = plot.getWorldName();
|
||||||
|
|
|
@ -76,11 +76,11 @@ public enum CommonSetupSteps implements SetupStep {
|
||||||
// TODO reimplement SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
// TODO reimplement SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||||
// .processSetup(process);
|
// .processSetup(process);
|
||||||
}
|
}
|
||||||
if (!builder.settingsNodesWrapper().hasNext()) {
|
if (!builder.settingsNodesWrapper().hasStep()) {
|
||||||
// object.setup_index = 0; TODO what did that do?
|
// object.setup_index = 0; TODO what did that do?
|
||||||
return builder.settingsNodesWrapper().getAfterwards(); // skip
|
return builder.settingsNodesWrapper().getAfterwards(); // skip
|
||||||
}
|
}
|
||||||
return builder.settingsNodesWrapper().next();
|
return builder.settingsNodesWrapper().first();
|
||||||
} else {
|
} else {
|
||||||
if (gen.isFull()) {
|
if (gen.isFull()) {
|
||||||
builder.plotManager(builder.generatorName());
|
builder.plotManager(builder.generatorName());
|
||||||
|
@ -179,7 +179,7 @@ public enum CommonSetupSteps implements SetupStep {
|
||||||
builder.settingsNodesWrapper(CommonSetupSteps.wrap(builder.plotManager()));
|
builder.settingsNodesWrapper(CommonSetupSteps.wrap(builder.plotManager()));
|
||||||
}
|
}
|
||||||
SettingsNodesWrapper wrapper = builder.settingsNodesWrapper();
|
SettingsNodesWrapper wrapper = builder.settingsNodesWrapper();
|
||||||
return wrapper.hasNext() ? wrapper.next() : wrapper.getAfterwards();
|
return wrapper.hasStep() ? wrapper.first() : wrapper.getAfterwards();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @Override public String getDefaultValue() {
|
@Nullable @Override public String getDefaultValue() {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.plotsquared.core.setup;
|
package com.plotsquared.core.setup;
|
||||||
|
|
||||||
|
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
@ -22,20 +24,35 @@ public class PlotAreaBuilder {
|
||||||
@Getter @Setter private SettingsNodesWrapper settingsNodesWrapper;
|
@Getter @Setter private SettingsNodesWrapper settingsNodesWrapper;
|
||||||
@Getter @Setter private SetupUtils setupManager;
|
@Getter @Setter private SetupUtils setupManager;
|
||||||
|
|
||||||
public void minimumId(PlotId minimumId) {
|
public static PlotAreaBuilder ofPlotArea(PlotArea area) {
|
||||||
|
return new PlotAreaBuilder()
|
||||||
|
.worldName(area.getWorldName())
|
||||||
|
.areaName(area.getId())
|
||||||
|
.plotAreaType(area.getType())
|
||||||
|
.terrainType(area.getTerrain())
|
||||||
|
.generatorName(area.getGenerator().getName())
|
||||||
|
.plotManager(PlotSquared.imp().getPluginName())
|
||||||
|
.minimumId(area.getMin())
|
||||||
|
.maximumId(area.getMax())
|
||||||
|
.settingsNodesWrapper(new SettingsNodesWrapper(area.getSettingNodes(), null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotAreaBuilder minimumId(PlotId minimumId) {
|
||||||
if (this.maximumId != null
|
if (this.maximumId != null
|
||||||
&& (minimumId.getX() >= this.maximumId.getX() || minimumId.getY() >= this.maximumId.getY())) {
|
&& (minimumId.getX() > this.maximumId.getX() || minimumId.getY() > this.maximumId.getY())) {
|
||||||
throw new IllegalStateException("minId >= maxId");
|
throw new IllegalStateException("minId >= maxId");
|
||||||
}
|
}
|
||||||
this.minimumId = minimumId;
|
this.minimumId = minimumId;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void maximumId(PlotId maximumId) {
|
public PlotAreaBuilder maximumId(PlotId maximumId) {
|
||||||
if (this.minimumId != null
|
if (this.minimumId != null
|
||||||
&& (maximumId.getX() <= this.minimumId.getX() || maximumId.getY() <= this.minimumId.getY())) {
|
&& (maximumId.getX() < this.minimumId.getX() || maximumId.getY() < this.minimumId.getY())) {
|
||||||
throw new IllegalStateException("maxId <= minId");
|
throw new IllegalStateException("maxId <= minId");
|
||||||
}
|
}
|
||||||
this.maximumId = maximumId;
|
this.maximumId = maximumId;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class SettingsNodeStep implements SetupStep {
|
||||||
if (this.configurationNode.isValid(argument)) {
|
if (this.configurationNode.isValid(argument)) {
|
||||||
this.configurationNode.setValue(argument);
|
this.configurationNode.setValue(argument);
|
||||||
}
|
}
|
||||||
return this.wrapper.hasNext() ? wrapper.next() : wrapper.getAfterwards();
|
return this.wrapper.hasNext(this.id) ? wrapper.next(this.id) : wrapper.getAfterwards();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public Collection<String> getSuggestions() {
|
@NotNull @Override public Collection<String> getSuggestions() {
|
||||||
|
|
|
@ -6,25 +6,34 @@ import lombok.Getter;
|
||||||
public class SettingsNodesWrapper {
|
public class SettingsNodesWrapper {
|
||||||
@Getter private final ConfigurationNode[] settingsNodes;
|
@Getter private final ConfigurationNode[] settingsNodes;
|
||||||
@Getter private final SetupStep afterwards;
|
@Getter private final SetupStep afterwards;
|
||||||
private int current;
|
|
||||||
|
|
||||||
public SettingsNodesWrapper(ConfigurationNode[] settingsNodes, SetupStep afterwards) {
|
public SettingsNodesWrapper(ConfigurationNode[] settingsNodes, SetupStep afterwards) {
|
||||||
this.settingsNodes = settingsNodes;
|
this.settingsNodes = settingsNodes;
|
||||||
this.afterwards = afterwards;
|
this.afterwards = afterwards;
|
||||||
this.current = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SettingsNodeStep next() {
|
public SettingsNodeStep next(int current) {
|
||||||
if (this.settingsNodes.length <= this.current) {
|
if (this.settingsNodes.length <= current + 1) {
|
||||||
throw new IllegalStateException("No step left");
|
throw new IllegalStateException("No step left");
|
||||||
} else {
|
} else {
|
||||||
int temp = this.current;
|
return new SettingsNodeStep(this.settingsNodes[current + 1], current + 1, this);
|
||||||
this.current++;
|
|
||||||
return new SettingsNodeStep(this.settingsNodes[temp], temp, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public boolean hasNext() {
|
|
||||||
return this.current < this.settingsNodes.length;
|
public SettingsNodeStep first() {
|
||||||
|
if (this.settingsNodes.length == 0) {
|
||||||
|
throw new IllegalStateException("No step left");
|
||||||
|
} else {
|
||||||
|
return new SettingsNodeStep(this.settingsNodes[0], 0, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNext(int current) {
|
||||||
|
return current + 1 < this.settingsNodes.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasStep() {
|
||||||
|
return this.settingsNodes.length > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public abstract class SetupUtils {
|
||||||
|
|
||||||
public abstract String getGenerator(final PlotArea plotArea);
|
public abstract String getGenerator(final PlotArea plotArea);
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public abstract String setupWorld(final SetupObject object);
|
public abstract String setupWorld(final SetupObject object);
|
||||||
|
|
||||||
public abstract String setupWorld(final PlotAreaBuilder builder);
|
public abstract String setupWorld(final PlotAreaBuilder builder);
|
||||||
|
|
Loading…
Reference in a new issue