From 0e5f29ef2a845b6a3a5523a920992a55182e46ca Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 16 May 2015 02:23:59 +1000 Subject: [PATCH] fixed setup --- PlotSquared/pom.xml | 2 +- .../plot/commands/DebugSetup.java | 114 ++++++++++++++++++ .../plot/commands/Setup.java | 7 +- .../plot/util/bukkit/BukkitSetupUtils.java | 4 + 4 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSetup.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 1baeb36ee..e76aa7413 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.11.4 + 2.11.5 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSetup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSetup.java new file mode 100644 index 000000000..65448a1bd --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSetup.java @@ -0,0 +1,114 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import java.util.Map.Entry; + +import org.bukkit.generator.ChunkGenerator; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.SetupObject; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetupUtils; + +public class DebugSetup extends SubCommand { + public DebugSetup() { + super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, false); + } + + public void displayGenerators(PlotPlayer plr) { + StringBuffer message = new StringBuffer(); + message.append("&6What generator do you want?"); + for (Entry entry : SetupUtils.generators.entrySet()) { + if (entry.getKey().equals("PlotSquared")) { + message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)"); + } + else if (entry.getValue() instanceof HybridGen) { + message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)"); + } + else if (entry.getValue() instanceof PlotGenerator) { + message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)"); + } + else { + message.append("\n&8 - &7" + entry.getKey() + " (Unknown structure)"); + } + } + MainUtil.sendMessage(plr, message.toString()); + } + + @Override + public boolean execute(final PlotPlayer plr, final String... args) { + // going through setup + String name; + if (plr == null) { + name = "*"; + } + else { + name = plr.getName(); + } + if (!SetupUtils.setupMap.containsKey(name)) { + final SetupObject object = new SetupObject(); + SetupUtils.setupMap.put(name, object); + SetupUtils.manager.updateGenerators(); + sendMessage(plr, C.SETUP_INIT); + displayGenerators(plr); + return false; + } + if (args.length == 1) { + if (args[0].equalsIgnoreCase("cancel")) { + SetupUtils.setupMap.remove(name); + MainUtil.sendMessage(plr, "&aCancelled setup"); + return false; + } + if (args[0].equalsIgnoreCase("back")) { + final SetupObject object = SetupUtils.setupMap.get(name); + if (object.setup_index > 0) { + object.setup_index--; + final ConfigurationNode node = object.step[object.setup_index]; + sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + ""); + return false; + } else if (object.current > 0) { + object.current--; + } + } + } + final SetupObject object = SetupUtils.setupMap.get(name); + final int index = object.current; + switch (index) { + case 0: { // choose plot manager // skip if 1 option + } + case 1: { // choose type (default, augmented, cluster) + } + case 2: { // Choose generator (vanilla, non plot generator) // skip if one option + } + case 3: { // world setup // skip if one option + } + case 4: { // world name + } + } + return false; + } + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 66a6de3b9..ab0faab32 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -48,9 +48,8 @@ public class Setup extends SubCommand { StringBuffer message = new StringBuffer(); message.append("&6What generator do you want?"); for (Entry entry : SetupUtils.generators.entrySet()) { -// + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared") if (entry.getKey().equals("PlotSquared")) { - message.append("\n&8 - &2" + entry.getKey() + " (Hybrid Generator)"); + message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)"); } else if (entry.getValue() instanceof HybridGen) { message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)"); @@ -93,8 +92,8 @@ public class Setup extends SubCommand { final SetupObject object = SetupUtils.setupMap.get(name); if (object.setup_index > 0) { object.setup_index--; - final ConfigurationNode node = object.step[object.current]; - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + ""); + final ConfigurationNode node = object.step[object.setup_index]; + sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + ""); return false; } else if (object.current > 0) { object.current--; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 2dfeabb86..c2ae5c586 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -57,6 +57,10 @@ public class BukkitSetupUtils extends SetupUtils { if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) { PlotSquared.config.set("worlds." + world + "." + "generator.init", object.setupGenerator); } + ChunkGenerator gen = generators.get(object.setupGenerator); + if (gen instanceof PlotGenerator) { + object.setupGenerator = null; + } } try { PlotSquared.config.save(PlotSquared.configFile);