Remove dumdum static access

This commit is contained in:
Alexander Söderberg
2020-07-10 19:25:05 +02:00
parent 7687d7705b
commit 55bf41d2da
27 changed files with 453 additions and 401 deletions

View File

@ -27,8 +27,11 @@ package com.plotsquared.bukkit.util;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.annoations.WorldConfig;
import com.plotsquared.core.annoations.WorldFile;
import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
@ -45,6 +48,7 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map.Entry;
@ -53,9 +57,15 @@ import java.util.Objects;
public class BukkitSetupUtils extends SetupUtils {
private final PlotAreaManager plotAreaManager;
private final YamlConfiguration worldConfiguration;
private final File worldFile;
public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager) {
public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@WorldFile @NotNull final File worldFile) {
this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile;
}
@Override public void updateGenerators() {
@ -115,11 +125,10 @@ public class BukkitSetupUtils extends SetupUtils {
switch (type) {
case PARTIAL: {
if (object.id != null) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
String areaName = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaName;
if (!worldSection.contains(areaPath)) {
@ -159,26 +168,21 @@ public class BukkitSetupUtils extends SetupUtils {
}
case AUGMENTED: {
if (!object.plotManager.endsWith(":single")) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
if (steps.length != 0) {
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
}
PlotSquared.get().worlds
.set("worlds." + world + ".generator.type", object.type.toString());
PlotSquared.get().worlds
.set("worlds." + world + ".generator.terrain", object.terrain.toString());
PlotSquared.get().worlds
.set("worlds." + world + ".generator.plugin", object.plotManager);
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)) {
PlotSquared.get().worlds
.set("worlds." + world + ".generator.init", object.setupGenerator);
this.worldConfiguration.set("worlds." + world + ".generator.init", object.setupGenerator);
}
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
@ -189,11 +193,10 @@ public class BukkitSetupUtils extends SetupUtils {
}
case NORMAL: {
if (steps.length != 0) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
@ -203,7 +206,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
this.worldConfiguration.save(this.worldFile);
} catch (IOException e) {
e.printStackTrace();
}
@ -228,11 +231,11 @@ public class BukkitSetupUtils extends SetupUtils {
switch (type) {
case PARTIAL: {
if (builder.areaName() != null) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
this.worldConfiguration.getConfigurationSection(worldPath);
String areaName = builder.areaName() + "-" + builder.minimumId() + "-" + builder.maximumId();
String areaPath = "areas." + areaName;
if (!worldSection.contains(areaPath)) {
@ -272,25 +275,25 @@ public class BukkitSetupUtils extends SetupUtils {
}
case AUGMENTED: {
if (!builder.plotManager().endsWith(":single")) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
if (steps.length != 0) {
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
this.worldConfiguration.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
}
PlotSquared.get().worlds
this.worldConfiguration
.set("worlds." + world + ".generator.type", builder.plotAreaType().toString());
PlotSquared.get().worlds
this.worldConfiguration
.set("worlds." + world + ".generator.terrain", builder.terrainType().toString());
PlotSquared.get().worlds
this.worldConfiguration
.set("worlds." + world + ".generator.plugin", builder.plotManager());
if (builder.generatorName() != null && !builder.generatorName()
.equals(builder.plotManager())) {
PlotSquared.get().worlds
this.worldConfiguration
.set("worlds." + world + ".generator.init", builder.generatorName());
}
}
@ -302,11 +305,11 @@ public class BukkitSetupUtils extends SetupUtils {
}
case NORMAL: {
if (steps.length != 0) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
this.worldConfiguration.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
@ -316,7 +319,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
this.worldConfiguration.save(this.worldFile);
} catch (IOException e) {
e.printStackTrace();
}