mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Fix /plot setup back
This commit is contained in:
parent
ae1427b189
commit
67b80bb8e8
@ -76,11 +76,7 @@ public enum CommonSetupSteps implements SetupStep {
|
||||
// TODO reimplement SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
// .processSetup(process);
|
||||
}
|
||||
if (!builder.settingsNodesWrapper().hasStep()) {
|
||||
// object.setup_index = 0; TODO what did that do?
|
||||
return builder.settingsNodesWrapper().getAfterwards(); // skip
|
||||
}
|
||||
return builder.settingsNodesWrapper().first();
|
||||
return builder.settingsNodesWrapper().getFirstStep();
|
||||
} else {
|
||||
if (gen.isFull()) {
|
||||
builder.plotManager(builder.generatorName());
|
||||
@ -179,7 +175,7 @@ public enum CommonSetupSteps implements SetupStep {
|
||||
builder.settingsNodesWrapper(CommonSetupSteps.wrap(builder.plotManager()));
|
||||
}
|
||||
SettingsNodesWrapper wrapper = builder.settingsNodesWrapper();
|
||||
return wrapper.hasStep() ? wrapper.first() : wrapper.getAfterwards();
|
||||
return wrapper.getFirstStep();
|
||||
}
|
||||
|
||||
@Nullable @Override public String getDefaultValue() {
|
||||
|
@ -17,19 +17,23 @@ import java.util.Collections;
|
||||
public class SettingsNodeStep implements SetupStep {
|
||||
@Getter private final ConfigurationNode configurationNode;
|
||||
@Getter private final int id;
|
||||
private final SettingsNodesWrapper wrapper;
|
||||
private final SetupStep next;
|
||||
|
||||
public SettingsNodeStep(ConfigurationNode configurationNode, int id, SettingsNodesWrapper wrapper) {
|
||||
this.configurationNode = configurationNode;
|
||||
this.id = id;
|
||||
this.wrapper = wrapper;
|
||||
if (wrapper.getSettingsNodes().length > id + 1) {
|
||||
this.next = new SettingsNodeStep(wrapper.getSettingsNodes()[id + 1], id + 1, wrapper);
|
||||
} else {
|
||||
this.next = wrapper.getAfterwards();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public SetupStep handleInput(PlotPlayer<?> plotPlayer, PlotAreaBuilder builder, String argument) {
|
||||
if (this.configurationNode.isValid(argument)) {
|
||||
this.configurationNode.setValue(argument);
|
||||
}
|
||||
return this.wrapper.hasNext(this.id) ? wrapper.next(this.id) : wrapper.getAfterwards();
|
||||
return this.next;
|
||||
}
|
||||
|
||||
@NotNull @Override public Collection<String> getSuggestions() {
|
||||
|
@ -12,28 +12,7 @@ public class SettingsNodesWrapper {
|
||||
this.afterwards = afterwards;
|
||||
}
|
||||
|
||||
|
||||
public SettingsNodeStep next(int current) {
|
||||
if (this.settingsNodes.length <= current + 1) {
|
||||
throw new IllegalStateException("No step left");
|
||||
} else {
|
||||
return new SettingsNodeStep(this.settingsNodes[current + 1], current + 1, this);
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsNodeStep first() {
|
||||
if (this.settingsNodes.length == 0) {
|
||||
throw new IllegalStateException("No step left");
|
||||
} else {
|
||||
return new SettingsNodeStep(this.settingsNodes[0], 0, this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNext(int current) {
|
||||
return current + 1 < this.settingsNodes.length;
|
||||
}
|
||||
|
||||
public boolean hasStep() {
|
||||
return this.settingsNodes.length > 0;
|
||||
public SetupStep getFirstStep() {
|
||||
return this.settingsNodes.length == 0 ? this.afterwards : new SettingsNodeStep(this.settingsNodes[0], 0, this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user