mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
new setup command
This commit is contained in:
parent
ba35d8b774
commit
76ed708c79
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.6.4</version>
|
<version>2.7.0</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -71,7 +71,6 @@ public enum Command {
|
|||||||
LIST("list", "l"),
|
LIST("list", "l"),
|
||||||
SET("set", "s"),
|
SET("set", "s"),
|
||||||
PURGE("purge"),
|
PURGE("purge"),
|
||||||
SETUP("setup"),
|
|
||||||
OP("op", "add"),
|
OP("op", "add"),
|
||||||
DEOP("deop", "deadmin"),
|
DEOP("deop", "deadmin"),
|
||||||
BAN("ban", "block"),
|
BAN("ban", "block"),
|
||||||
|
@ -49,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
*/
|
*/
|
||||||
public static final String MAIN_PERMISSION = "plots.use";
|
public static final String MAIN_PERMISSION = "plots.use";
|
||||||
|
|
||||||
private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSetup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags() };
|
private final static SubCommand[] _subCommands = new SubCommand[]{new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags() };
|
||||||
|
|
||||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
|
@ -22,229 +22,307 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
|
|
||||||
/**
|
public class Setup extends SubCommand {
|
||||||
* Created 2014-09-26 for PlotSquared
|
|
||||||
*
|
|
||||||
* @author Citymonstret, Empire92
|
|
||||||
*/
|
|
||||||
public class Setup extends SubCommand implements Listener {
|
|
||||||
|
|
||||||
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||||
|
public HashMap<String, PlotGenerator> generators = new HashMap<>();
|
||||||
|
|
||||||
public Setup() {
|
public Setup() {
|
||||||
super("setup", "plots.admin.command.setup", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false);
|
super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SetupObject {
|
||||||
|
int current = 0;
|
||||||
|
int setup_index = 0;
|
||||||
|
String world = null;
|
||||||
|
String generator = null;
|
||||||
|
int type = 0;
|
||||||
|
int terrain = 0;
|
||||||
|
ConfigurationNode[] step = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGenerators() {
|
||||||
|
if (generators.size() > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String testWorld = "CheckingPlotSquaredGenerator";
|
||||||
|
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
|
if (plugin.isEnabled()) {
|
||||||
|
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
||||||
|
if (generator != null) {
|
||||||
|
PlotMain.removePlotWorld(testWorld);
|
||||||
|
final String name = plugin.getDescription().getName();
|
||||||
|
if (generator instanceof PlotGenerator) {
|
||||||
|
generators.put(name, (PlotGenerator) generator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
String plrname;
|
// going through setup
|
||||||
|
|
||||||
if (plr == null) {
|
String name = plr.getName();
|
||||||
plrname = "";
|
if (!setupMap.containsKey(name)) {
|
||||||
} else {
|
SetupObject object = new SetupObject();
|
||||||
plrname = plr.getName();
|
setupMap.put(name, object);
|
||||||
|
updateGenerators();
|
||||||
|
String prefix = "\n&8 - &7";
|
||||||
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
|
PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
if (setupMap.containsKey(plrname)) {
|
|
||||||
final SetupObject object = setupMap.get(plrname);
|
|
||||||
if (object.getCurrent() == object.getMax()) {
|
|
||||||
final ConfigurationNode[] steps = object.step;
|
|
||||||
final String world = object.world;
|
|
||||||
for (final ConfigurationNode step : steps) {
|
|
||||||
PlotMain.config.set("worlds." + world + "." + step.getConstant(), step.getValue());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
PlotMain.config.save(PlotMain.configFile);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creating the worlds
|
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.plugin);
|
|
||||||
} else {
|
|
||||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.plugin);
|
|
||||||
} else {
|
|
||||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
|
||||||
if (plugin.isEnabled()) {
|
|
||||||
if (plugin.getDefaultWorldGenerator("world", "") != null) {
|
|
||||||
final String name = plugin.getDescription().getName();
|
|
||||||
if (object.plugin.equals(name)) {
|
|
||||||
final ChunkGenerator generator = plugin.getDefaultWorldGenerator(world, "");
|
|
||||||
final World myworld = WorldCreator.name(world).generator(generator).createWorld();
|
|
||||||
PlayerFunctions.sendMessage(plr, "&aLoaded world.");
|
|
||||||
if (plr != null) {
|
|
||||||
plr.teleport(myworld.getSpawnLocation());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
plr.teleport(Bukkit.getWorld(world).getSpawnLocation());
|
|
||||||
}
|
|
||||||
catch (Exception e) {}
|
|
||||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
|
||||||
|
|
||||||
setupMap.remove(plrname);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ConfigurationNode step = object.step[object.current];
|
|
||||||
if (args.length < 1) {
|
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (args[0].equalsIgnoreCase("cancel")) {
|
if (args[0].equalsIgnoreCase("cancel")) {
|
||||||
final String world = object.world;
|
setupMap.remove(plr.getName());
|
||||||
PlotMain.config.set("worlds." + world, null);
|
PlayerFunctions.sendMessage(plr, "&aCancelled setup");
|
||||||
try {
|
return false;
|
||||||
PlotMain.config.save(PlotMain.configFile);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
setupMap.remove(plrname);
|
|
||||||
PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("back")) {
|
if (args[0].equalsIgnoreCase("back")) {
|
||||||
if (object.current > 0) {
|
SetupObject object = setupMap.get(plr.getName());
|
||||||
|
if (object.setup_index > 0) {
|
||||||
|
object.setup_index--;
|
||||||
|
ConfigurationNode node = object.step[object.current];
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (object.current > 0 ){
|
||||||
object.current--;
|
object.current--;
|
||||||
step = object.step[object.current];
|
}
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
}
|
||||||
return true;
|
}
|
||||||
} else {
|
SetupObject object = setupMap.get(name);
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
int index = object.current;
|
||||||
|
switch(index) {
|
||||||
|
case 0: { // choose generator
|
||||||
|
if (args.length != 1 || !generators.containsKey(args[0])) {
|
||||||
|
String prefix = "\n&8 - &7";
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
||||||
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
object.generator = args[0];
|
||||||
|
object.current++;
|
||||||
|
PlayerFunctions.sendMessage(plr, "&6What world type do you want?"
|
||||||
|
+ "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||||
|
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
|
||||||
|
+ "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: { // choose world type
|
||||||
|
List<String> types = Arrays.asList(new String[] {"default", "augmented", "partial"});
|
||||||
|
if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!"
|
||||||
|
+ "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||||
|
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
|
||||||
|
+ "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
object.type = types.indexOf(args[0].toLowerCase());
|
||||||
|
if (object.type == 0) {
|
||||||
|
object.current++;
|
||||||
|
if (object.step == null) {
|
||||||
|
object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
||||||
|
}
|
||||||
|
ConfigurationNode step = object.step[object.setup_index];
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?"
|
||||||
|
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||||
|
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||||
|
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
|
}
|
||||||
|
object.current++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: { // Choose terrain
|
||||||
|
List<String> terrain = Arrays.asList(new String[] {"none", "ore", "all"});
|
||||||
|
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!"
|
||||||
|
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||||
|
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||||
|
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
||||||
|
object.current++;
|
||||||
|
if (object.step == null) {
|
||||||
|
object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
||||||
|
}
|
||||||
|
ConfigurationNode step = object.step[object.setup_index];
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: { // world setup
|
||||||
|
if (object.setup_index == object.step.length) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&6What do you want your world to be called?");
|
||||||
|
object.setup_index = 0;
|
||||||
|
object.current++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
ConfigurationNode step = object.step[object.setup_index];
|
||||||
|
if (args.length < 1) {
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
final boolean valid = step.isValid(args[0]);
|
final boolean valid = step.isValid(args[0]);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
||||||
step.setValue(args[0]);
|
step.setValue(args[0]);
|
||||||
object.current++;
|
object.setup_index++;
|
||||||
if (object.getCurrent() == object.getMax()) {
|
if (object.setup_index == object.step.length) {
|
||||||
execute(plr, args);
|
execute(plr, args);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
step = object.step[object.current];
|
step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
return true;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
case 4: {
|
||||||
if (args.length < 1) {
|
if (args.length != 1) {
|
||||||
sendMessage(plr, C.SETUP_MISSING_WORLD);
|
PlayerFunctions.sendMessage(plr, "&cYou need to choose a world name!");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length < 2) {
|
if (Bukkit.getWorld(args[0]) != null) {
|
||||||
sendMessage(plr, C.SETUP_MISSING_GENERATOR);
|
PlayerFunctions.sendMessage(plr, "&cThat world name is already taken!");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
final String world = args[0];
|
object.world = args[0];
|
||||||
if (StringUtils.isNumeric(args[0])) {
|
setupMap.remove(plr.getName());
|
||||||
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
World world = setupWorld(object);
|
||||||
return true;
|
try {
|
||||||
|
plr.teleport(world.getSpawnLocation());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
plr.sendMessage("&cAn error occured. See console for more information");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
|
setupMap.remove(plr.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 0.0 normal hybrid no clusters
|
||||||
|
* 0.1 normal hybrid with clusters
|
||||||
|
* 0.2 normal hybrid require clusters
|
||||||
|
* 1.0 augmented whole world
|
||||||
|
* 1.1 augmented whole world with ore
|
||||||
|
* 1.2 augmented whole world with terrain
|
||||||
|
* 2.1 augmented partial world
|
||||||
|
* 2.2 augmented partial world with ore
|
||||||
|
* 2.3 augmented partial world with terrain
|
||||||
|
* 3.0 no generation + normal manager
|
||||||
|
*
|
||||||
|
* generator.TYPE: PlotSquared, augmented, partial
|
||||||
|
* generator.TERRAIN
|
||||||
|
*
|
||||||
|
* WORLD.TYPE: hybrid, augmented, partial
|
||||||
|
* if (augmented/partial)
|
||||||
|
* WORLD.TERRAIN:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* types (0, 1, 2, 3)
|
||||||
|
* 0: no options
|
||||||
|
* 1:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* - return null
|
||||||
|
* - schedule task to create world later
|
||||||
|
* - externalize multiverse/world hooks to separate class
|
||||||
|
* - create vanilla world
|
||||||
|
* - add augmented populator
|
||||||
|
* - add config option type
|
||||||
|
* - Work on heirarchy for setting nodes so you don't need to provide irrelevent info (world setup)
|
||||||
|
* - use code from setup command for world arguments (above) so that it persists
|
||||||
|
* - work on plot clearing for augmented plot worlds (terrain) (heads, banners, paintings, animals, inventoryhandler)
|
||||||
|
* - make a generic clear function for any generator
|
||||||
|
* - clean up plotmanager class (remove unnecessary methods)
|
||||||
|
* - make simple plot manager which can be used by external generators (don't make abstract)
|
||||||
|
* - plugins will override any of it's methods
|
||||||
|
* - make heirarchy of generators of increasing abstraction:
|
||||||
|
* = totally abstract (circle plots, moving plots, no tesselation)
|
||||||
|
* = tessellating generator
|
||||||
|
* = grid generator
|
||||||
|
* = square generator
|
||||||
|
* = square plot generator (must have plot section and road section) (plot height, road height)
|
||||||
|
* = hybrid generator
|
||||||
|
*
|
||||||
|
* - All will support whole world augmentation
|
||||||
|
* - Only grid will support partial plot worlds
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlotMain.getWorldSettings(world) != null) {
|
public World setupWorld(SetupObject object) {
|
||||||
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
// Configuration
|
||||||
return true;
|
final ConfigurationNode[] steps = object.step;
|
||||||
|
final String world = object.world;
|
||||||
|
for (final ConfigurationNode step : steps) {
|
||||||
|
PlotMain.config.set("worlds." + world + "." + step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
|
if (object.type != 0) {
|
||||||
final ArrayList<String> generators = new ArrayList<>();
|
PlotMain.config.set("worlds." + world + "." + "generator.type", object.type);
|
||||||
|
PlotMain.config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||||
ChunkGenerator generator = null;
|
PlotMain.config.set("worlds." + world + "." + "generator.plugin", object.generator);
|
||||||
|
|
||||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
|
||||||
if (plugin.isEnabled()) {
|
|
||||||
if (plugin.getDefaultWorldGenerator("CheckingPlotSquaredGenerator", "") != null) {
|
|
||||||
PlotMain.removePlotWorld(world);
|
|
||||||
final String name = plugin.getDescription().getName();
|
|
||||||
generators.add(name);
|
|
||||||
if (args[1].equals(name)) {
|
|
||||||
generator = plugin.getDefaultWorldGenerator(world, "");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlotMain.config.set("worlds.CheckingPlotSquaredGenerator", null);
|
|
||||||
try {
|
try {
|
||||||
PlotMain.config.save(PlotMain.configFile);
|
PlotMain.config.save(PlotMain.configFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (generator == null) {
|
if (object.type == 0) {
|
||||||
sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringUtils.join(generators, C.BLOCK_LIST_SEPARATER.s()));
|
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
return true;
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.generator);
|
||||||
}
|
|
||||||
PlotWorld plotworld;
|
|
||||||
if (generator instanceof PlotGenerator) {
|
|
||||||
plotworld = ((PlotGenerator) generator).getNewPlotWorld(world);
|
|
||||||
} else {
|
} else {
|
||||||
plotworld = new HybridPlotWorld(world);
|
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
}
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator);
|
||||||
PlotMain.removePlotWorld(world);
|
} else {
|
||||||
|
WorldCreator wc = new WorldCreator(object.world);
|
||||||
setupMap.put(plrname, new SetupObject(world, plotworld, args[1]));
|
wc.generator(object.generator);
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
wc.environment(Environment.NORMAL);
|
||||||
final SetupObject object = setupMap.get(plrname);
|
World newWorld = Bukkit.createWorld(wc);
|
||||||
final ConfigurationNode step = object.step[object.current];
|
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SetupObject {
|
|
||||||
final String world;
|
|
||||||
final String plugin;
|
|
||||||
final ConfigurationNode[] step;
|
|
||||||
int current = 0;
|
|
||||||
|
|
||||||
public SetupObject(final String world, final PlotWorld plotworld, final String plugin) {
|
|
||||||
this.world = world;
|
|
||||||
this.step = plotworld.getSettingNodes();
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
public int getCurrent() {
|
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
return this.current;
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
|
||||||
}
|
} else {
|
||||||
|
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
public int getMax() {
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
|
||||||
return this.step.length;
|
} else {
|
||||||
|
Bukkit.createWorld(new WorldCreator(object.world).environment(World.Environment.NORMAL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return Bukkit.getWorld(object.world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user