From 165cac8b139650995825412739743cd5e7d41503 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Sun, 23 Dec 2018 17:38:27 +0100 Subject: [PATCH] Fix bStats problem and commit Setup progress --- .../plotsquared/bukkit/BukkitMain.java | 1 + .../plotsquared/plot/commands/Setup.java | 128 +++++++++++++++++- 2 files changed, 122 insertions(+), 7 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index 8294c6c7b..f0190b125 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -735,6 +735,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain if (this.metricsStarted) { return; } + System.setProperty("bstats.relocatecheck", "false"); // We do not want to relocate the package... new org.bstats.bukkit.Metrics(this); // bstats PlotSquared.log(C.PREFIX + "&6Metrics enabled."); this.metricsStarted = true; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java index bdcbbaaab..e866a0bc4 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Setup.java @@ -6,18 +6,15 @@ import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper; -import com.github.intellectualsites.plotsquared.plot.object.PlotArea; -import com.github.intellectualsites.plotsquared.plot.object.PlotId; -import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; -import com.github.intellectualsites.plotsquared.plot.object.SetupObject; +import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; +import lombok.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import javax.annotation.Nullable; +import java.util.*; import java.util.Map.Entry; @CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = { @@ -305,4 +302,121 @@ import java.util.Map.Entry; } return false; } + + private static final class StepPickGenerator extends SetupStep { + + @Getter + private String generator; + + public StepPickGenerator() { + super("generator"); + } + + @Override public Collection showDescriptionMessage() { + SetupUtils.manager.updateGenerators(); + final List messages = new ArrayList<>(); + messages.add(new PlotMessage("What generator do you want?").color("$6")); + for (Entry> 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 parseInut(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 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 showDescriptionMessage() { + final List messages = new ArrayList<>(); + messages.add(new PlotMessage("What world type do you want?").color("$6")); + for (final Map.Entry 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 parseInut(String input) { + if (!WORLD_TYPES.keySet().contains(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 showDescriptionMessage(); + + public abstract boolean parseInut(String input); + + public final PlotMessage getUsage() { + return new PlotMessage("Usage: ").color("$1").text("/plot setup " + this.stepName + " ").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"); + } + } + + } + }