From 560921ebc50d82e5b0b06c4e5a6b5ea40f741d03 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Oct 2014 22:30:25 +1000 Subject: [PATCH] fixed setup command (it wasn't working) --- .../src/com/intellectualcrafters/plot/C.java | 2 +- .../plot/WorldGenerator.java | 3 ++- .../plot/commands/Setup.java | 22 ++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index 941c68604..c726abdf3 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -31,7 +31,7 @@ public enum C { SETUP_STEP("&cStep &6%s&c: %s &c"), SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG("&cValue &6%s &cset for step %s"), - SETUP_FINISHED("&cFinished setup for world &c%s. To create it, type &6/plots setup create"), + SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"), SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"), SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup \n&c - &6/p setup back\n&c - &6/p setup cancel"), /* diff --git a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java index 803d4046d..98757d2f8 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java @@ -69,6 +69,7 @@ public class WorldGenerator extends ChunkGenerator { } public WorldGenerator(String world) { + YamlConfiguration config = PlotMain.config; this.plotworld = new PlotWorld(); Map options = new HashMap(); @@ -219,7 +220,7 @@ public class WorldGenerator extends ChunkGenerator { public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) { int maxY = world.getMaxHeight(); - this.result = new short[maxY / 16][]; + this.result = new short[maxY / 16][]; double pathWidthLower; if ((pathsize % 2) == 0) { pathWidthLower = Math.floor(this.pathsize / 2)-1; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java index 45329c38a..b893aea21 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java @@ -42,6 +42,7 @@ import sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -91,7 +92,7 @@ public class Setup extends SubCommand implements Listener { value = Float.parseFloat(string); break; case "biome": - value = Biome.valueOf(string.toUpperCase()); + value = (string.toUpperCase()); break; case "block": value = string; @@ -160,6 +161,9 @@ public class Setup extends SubCommand implements Listener { } public Object getValue() { + if (this.value instanceof String[]) { + return (List)(List) Arrays.asList((String[]) this.value); + } return this.value; } @@ -168,6 +172,9 @@ public class Setup extends SubCommand implements Listener { } public Object getDefaultValue() { + if (this.default_value instanceof String[]) { + return StringUtils.join((String[]) this.default_value,","); + } return this.default_value; } @@ -230,7 +237,7 @@ public class Setup extends SubCommand implements Listener { SetupStep[] steps = object.step; String world = object.world; for (SetupStep step:steps) { - PlotMain.config.set("worlds."+world+"."+step.constant, step.value); + PlotMain.config.set("worlds."+world+"."+step.constant, step.getValue()); } try { PlotMain.config.save(PlotMain.configFile); @@ -238,8 +245,8 @@ public class Setup extends SubCommand implements Listener { e.printStackTrace(); } - World newWorld = WorldCreator.name(world).generator(new WorldGenerator(world)).createWorld(); - plr.teleport(newWorld.getSpawnLocation()); +// World newWorld = WorldCreator.name(world).generator(new WorldGenerator(world)).createWorld(); +// plr.teleport(newWorld.getSpawnLocation()); setupMap.remove(plr.getName()); @@ -272,11 +279,17 @@ public class Setup extends SubCommand implements Listener { sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]); step.setValue(args[0]); object.current++; + if(object.getCurrent() == object.getMax()) { + execute(plr, args); + return true; + } step = object.step[object.current]; sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + ""); + return true; } else { sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant()); sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + ""); + return true; } } } else { @@ -300,7 +313,6 @@ public class Setup extends SubCommand implements Listener { sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + ""); return true; } - return true; } }