mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix bStats problem and commit Setup progress
This commit is contained in:
parent
25b34b419f
commit
165cac8b13
@ -735,6 +735,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
if (this.metricsStarted) {
|
if (this.metricsStarted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
System.setProperty("bstats.relocatecheck", "false"); // We do not want to relocate the package...
|
||||||
new org.bstats.bukkit.Metrics(this); // bstats
|
new org.bstats.bukkit.Metrics(this); // bstats
|
||||||
PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
|
PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
|
||||||
this.metricsStarted = true;
|
this.metricsStarted = true;
|
||||||
|
@ -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.Configuration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
|
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
|
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
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.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = {
|
@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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class StepPickGenerator extends SetupStep {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String generator;
|
||||||
|
|
||||||
|
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 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<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 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<PlotMessage> showDescriptionMessage();
|
||||||
|
|
||||||
|
public abstract boolean parseInut(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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user