mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Remove dumdum static access
This commit is contained in:
@ -70,6 +70,7 @@ import com.plotsquared.core.configuration.ChatFormatter;
|
||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||
import com.plotsquared.core.generator.HybridGen;
|
||||
@ -188,7 +189,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
private PlotAreaManager plotAreaManager;
|
||||
private EventDispatcher eventDispatcher;
|
||||
private PlotListener plotListener;
|
||||
|
||||
private YamlConfiguration worldConfiguration;
|
||||
private File worldfile;
|
||||
|
||||
@Override public int[] getServerVersion() {
|
||||
if (this.version == null) {
|
||||
try {
|
||||
@ -224,6 +227,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
this.eventDispatcher = plotSquared.getEventDispatcher();
|
||||
this.plotListener = plotSquared.getPlotListener();
|
||||
this.playerManager = new BukkitPlayerManager(this.plotAreaManager, this.eventDispatcher);
|
||||
this.worldConfiguration = plotSquared.getWorldConfiguration();
|
||||
this.worldfile = plotSquared.getWorldsFile();
|
||||
|
||||
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
||||
System.out.println(
|
||||
@ -903,7 +908,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
}
|
||||
|
||||
@Override public void registerPlayerEvents() {
|
||||
final PlayerEvents main = new PlayerEvents(this.plotAreaManager, this.eventDispatcher);
|
||||
final PlayerEvents main = new PlayerEvents(this.plotAreaManager, this.eventDispatcher, worldEdit);
|
||||
getServer().getPluginManager().registerEvents(main, this);
|
||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
||||
@ -1002,7 +1007,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
}
|
||||
|
||||
@Override public SetupUtils initSetupUtils() {
|
||||
return new BukkitSetupUtils(this.plotAreaManager);
|
||||
return new BukkitSetupUtils(this.plotAreaManager, this.worldConfiguration, this.worldfile);
|
||||
}
|
||||
|
||||
@Override public void startMetrics() {
|
||||
@ -1057,7 +1062,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
}
|
||||
|
||||
@NotNull @Override public IndependentPlotGenerator getDefaultGenerator() {
|
||||
return new HybridGen(this.eventDispatcher, this.plotListener);
|
||||
return new HybridGen(this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
}
|
||||
|
||||
@Override public InventoryUtil initInventoryUtil() {
|
||||
@ -1068,8 +1073,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
World world = BukkitUtil.getWorld(worldName);
|
||||
if (world == null) {
|
||||
// create world
|
||||
ConfigurationSection worldConfig =
|
||||
PlotSquared.get().worlds.getConfigurationSection("worlds." + worldName);
|
||||
ConfigurationSection worldConfig = this.worldConfiguration.getConfigurationSection("worlds." + worldName);
|
||||
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
||||
PlotAreaBuilder builder = new PlotAreaBuilder().plotManager(manager)
|
||||
.generatorName(worldConfig.getString("generator.init", manager))
|
||||
@ -1096,7 +1100,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
PlotSquared.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
||||
} else if (gen != null) {
|
||||
PlotSquared.get().loadWorld(worldName, new BukkitPlotGenerator(worldName, gen, this.plotAreaManager));
|
||||
} else if (PlotSquared.get().worlds.contains("worlds." + worldName)) {
|
||||
} else if (this.worldConfiguration.contains("worlds." + worldName)) {
|
||||
PlotSquared.get().loadWorld(worldName, null);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ import com.plotsquared.core.util.PremiumVerification;
|
||||
import com.plotsquared.core.util.RegExUtil;
|
||||
import com.plotsquared.core.util.entity.EntityCategories;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import io.papermc.lib.PaperLib;
|
||||
@ -234,6 +235,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
private float lastRadius;
|
||||
@ -243,10 +245,13 @@ import java.util.regex.Pattern;
|
||||
private PlayerMoveEvent moveTmp;
|
||||
private String internalVersion;
|
||||
|
||||
public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||
public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final WorldEdit worldEdit) {
|
||||
super(eventDispatcher);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.worldEdit = worldEdit;
|
||||
try {
|
||||
fieldPlayer = PlayerEvent.class.getDeclaredField("player");
|
||||
fieldPlayer.setAccessible(true);
|
||||
@ -1077,9 +1082,9 @@ import java.util.regex.Pattern;
|
||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
return;
|
||||
}
|
||||
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
|
||||
if (this.worldEdit!= null && pp.getAttribute("worldedit")) {
|
||||
if (player.getInventory().getItemInMainHand().getType() == Material
|
||||
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
||||
.getMaterial(this.worldEdit.getConfiguration().wandItem)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1150,7 +1155,7 @@ import java.util.regex.Pattern;
|
||||
if (plot != null) {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
if (PlotSquared.get().worldedit != null) {
|
||||
if (this.worldEdit != null) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
pp.removeAttribute("worldedit");
|
||||
@ -2114,9 +2119,9 @@ import java.util.regex.Pattern;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
|
||||
if (this.worldEdit != null && pp.getAttribute("worldedit")) {
|
||||
if (event.getMaterial() == Material
|
||||
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
||||
.getMaterial(this.worldEdit.getConfiguration().wandItem)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user