mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
Remove SetupObject
This commit is contained in:
parent
505bba7612
commit
f636db49f7
@ -37,7 +37,6 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
import com.plotsquared.core.plot.SetupObject;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
@ -118,111 +117,6 @@ import java.util.Objects;
|
||||
Bukkit.unloadWorld(world, false);
|
||||
}
|
||||
|
||||
@Deprecated @Override public String setupWorld(SetupObject object) {
|
||||
this.updateGenerators();
|
||||
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
||||
String world = object.world;
|
||||
PlotAreaType type = object.type;
|
||||
String worldPath = "worlds." + object.world;
|
||||
switch (type) {
|
||||
case PARTIAL: {
|
||||
if (object.id != null) {
|
||||
if (!this.worldConfiguration.contains(worldPath)) {
|
||||
this.worldConfiguration.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
if (!worldSection.contains(areaPath)) {
|
||||
worldSection.createSection(areaPath);
|
||||
}
|
||||
ConfigurationSection areaSection =
|
||||
worldSection.getConfigurationSection(areaPath);
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
for (ConfigurationNode step : steps) {
|
||||
options.put(step.getConstant(), step.getValue());
|
||||
}
|
||||
options.put("generator.type", object.type.toString());
|
||||
options.put("generator.terrain", object.terrain.toString());
|
||||
options.put("generator.plugin", object.plotManager);
|
||||
if (object.setupGenerator != null && !object.setupGenerator
|
||||
.equals(object.plotManager)) {
|
||||
options.put("generator.init", object.setupGenerator);
|
||||
}
|
||||
for (Entry<String, Object> entry : options.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if (worldSection.contains(key)) {
|
||||
Object current = worldSection.get(key);
|
||||
if (!Objects.equals(value, current)) {
|
||||
areaSection.set(key, value);
|
||||
}
|
||||
} else {
|
||||
worldSection.set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUGMENTED: {
|
||||
if (!object.plotManager.endsWith(":single")) {
|
||||
if (!this.worldConfiguration.contains(worldPath)) {
|
||||
this.worldConfiguration.createSection(worldPath);
|
||||
}
|
||||
if (steps.length != 0) {
|
||||
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
}
|
||||
this.worldConfiguration.set("worlds." + world + ".generator.type", object.type.toString());
|
||||
this.worldConfiguration.set("worlds." + world + ".generator.terrain", object.terrain.toString());
|
||||
this.worldConfiguration.set("worlds." + world + ".generator.plugin", object.plotManager);
|
||||
if (object.setupGenerator != null && !object.setupGenerator
|
||||
.equals(object.plotManager)) {
|
||||
this.worldConfiguration.set("worlds." + world + ".generator.init", object.setupGenerator);
|
||||
}
|
||||
}
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NORMAL: {
|
||||
if (steps.length != 0) {
|
||||
if (!this.worldConfiguration.contains(worldPath)) {
|
||||
this.worldConfiguration.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this.worldConfiguration.save(this.worldFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Objects.requireNonNull(PlotSquared.platform()).getWorldManager()
|
||||
.handleWorldCreation(object.world, object.setupGenerator);
|
||||
|
||||
if (Bukkit.getWorld(world) != null) {
|
||||
return world;
|
||||
}
|
||||
|
||||
return object.world;
|
||||
}
|
||||
|
||||
@Override public String setupWorld(PlotAreaBuilder builder) {
|
||||
this.updateGenerators();
|
||||
ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ?
|
||||
|
@ -28,7 +28,6 @@ package com.plotsquared.core.generator;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.SetupObject;
|
||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||
|
||||
@ -75,7 +74,7 @@ public abstract class IndependentPlotGenerator {
|
||||
* If any additional setup options need to be changed before world creation.
|
||||
* - e.g. If setup doesn't support some standard options
|
||||
*
|
||||
* @param setup setup object
|
||||
* @param setup
|
||||
*/
|
||||
@Deprecated public void processSetup(SetupObject setup) {
|
||||
}
|
||||
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2020 IntellectualSites
|
||||
*
|
||||
* 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, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.plot;
|
||||
|
||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
|
||||
/**
|
||||
* @deprecated will be removed in v6
|
||||
*/
|
||||
@Deprecated
|
||||
public class SetupObject {
|
||||
|
||||
/**
|
||||
* Specify a SetupUtils object here to override the existing
|
||||
*/
|
||||
public SetupUtils setupManager;
|
||||
|
||||
/**
|
||||
* The current state
|
||||
*/
|
||||
public int current = 0;
|
||||
|
||||
/**
|
||||
* The index in generator specific settings
|
||||
*/
|
||||
public int setup_index = 0;
|
||||
|
||||
/**
|
||||
* The name of the world
|
||||
*/
|
||||
public String world = null;
|
||||
|
||||
/**
|
||||
* The name of the plot manager
|
||||
*/
|
||||
public String plotManager = null;
|
||||
|
||||
/**
|
||||
* The name of the generator to use for world creation
|
||||
*/
|
||||
public String setupGenerator = null;
|
||||
|
||||
/**
|
||||
* The management type (normal, augmented, partial)
|
||||
*/
|
||||
public PlotAreaType type;
|
||||
|
||||
/**
|
||||
* The terrain type
|
||||
*/
|
||||
public PlotAreaTerrainType terrain;
|
||||
|
||||
/**
|
||||
* Area ID (may be null)
|
||||
*/
|
||||
public String id;
|
||||
|
||||
/**
|
||||
* Minimum plot id (may be null)
|
||||
*/
|
||||
public PlotId min;
|
||||
|
||||
/**
|
||||
* Max plot id (may be null)
|
||||
*/
|
||||
public PlotId max;
|
||||
|
||||
/**
|
||||
* Generator specific configuration steps
|
||||
*/
|
||||
public ConfigurationNode[] step = null;
|
||||
}
|
@ -27,7 +27,6 @@ package com.plotsquared.core.util;
|
||||
|
||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.SetupObject;
|
||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -40,9 +39,6 @@ public abstract class SetupUtils {
|
||||
|
||||
public abstract String getGenerator(final PlotArea plotArea);
|
||||
|
||||
@Deprecated
|
||||
public abstract String setupWorld(final SetupObject object);
|
||||
|
||||
public abstract String setupWorld(final PlotAreaBuilder builder);
|
||||
|
||||
public abstract void unload(String world, boolean save);
|
||||
|
Loading…
Reference in New Issue
Block a user