mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 06:36:44 +01:00
Remove dumdum static access
This commit is contained in:
parent
7687d7705b
commit
55bf41d2da
@ -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,6 +189,8 @@ 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) {
|
||||
@ -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();
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ package com.plotsquared.core;
|
||||
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
@ -89,26 +88,6 @@ import java.util.UUID;
|
||||
PlotSquared.get().addPlotArea(plotArea);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration file for this plugin.
|
||||
*
|
||||
* @return the configuration file for PlotSquared
|
||||
* =
|
||||
*/
|
||||
public YamlConfiguration getConfig() {
|
||||
return PlotSquared.get().getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PlotSquared storage file.
|
||||
*
|
||||
* @return storage configuration
|
||||
* @see PlotSquared#storage
|
||||
*/
|
||||
public YamlConfiguration getStorage() {
|
||||
return PlotSquared.get().storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChunkManager class contains several useful methods.
|
||||
* <ul>
|
||||
|
@ -144,16 +144,14 @@ public class PlotSquared {
|
||||
@Getter private final UUIDPipeline backgroundUUIDPipeline =
|
||||
new UUIDPipeline(Executors.newSingleThreadExecutor());
|
||||
// WorldEdit instance
|
||||
public WorldEdit worldedit;
|
||||
public File styleFile;
|
||||
public File configFile;
|
||||
public File worldsFile;
|
||||
public File translationFile;
|
||||
public YamlConfiguration style;
|
||||
public YamlConfiguration worlds;
|
||||
public YamlConfiguration storage;
|
||||
@Getter private WorldEdit worldedit;
|
||||
@Getter private File configFile;
|
||||
@Getter private File worldsFile;
|
||||
public File translationFile; // TODO: REMOVE
|
||||
public YamlConfiguration style; // TODO: REMOVE
|
||||
@Getter private YamlConfiguration worldConfiguration;
|
||||
// Temporary hold the plots/clusters before the worlds load
|
||||
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
||||
private HashMap<String, Set<PlotCluster>> clustersTmp;
|
||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||
private YamlConfiguration config;
|
||||
// Implementation logger
|
||||
@ -217,14 +215,33 @@ public class PlotSquared {
|
||||
+ ".use_THIS.yml");
|
||||
Captions.load(this.translationFile);
|
||||
|
||||
// WorldEdit
|
||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||
try {
|
||||
if (this.platform.initWorldEdit()) {
|
||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
||||
+ " hooked into WorldEdit.");
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber(this.plotAreaManager));
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
new WE_Anywhere();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
PlotSquared.debug(
|
||||
"Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
||||
}
|
||||
}
|
||||
|
||||
// Create Event utility class
|
||||
this.eventDispatcher = new EventDispatcher();
|
||||
this.eventDispatcher = new EventDispatcher(this.worldedit);
|
||||
// Create plot listener
|
||||
this.plotListener = new PlotListener(this.eventDispatcher);
|
||||
|
||||
// Setup plotAreaManager
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
this.plotAreaManager = new SinglePlotAreaManager(this.eventDispatcher, this.plotListener);
|
||||
this.plotAreaManager = new SinglePlotAreaManager(this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
} else {
|
||||
this.plotAreaManager = new DefaultPlotAreaManager();
|
||||
}
|
||||
@ -281,24 +298,6 @@ public class PlotSquared {
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
this.platform.registerCommands();
|
||||
}
|
||||
// WorldEdit
|
||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||
try {
|
||||
if (this.platform.initWorldEdit()) {
|
||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
||||
+ " hooked into WorldEdit.");
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber(this.plotAreaManager));
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
new WE_Anywhere();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
PlotSquared.debug(
|
||||
"Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
||||
}
|
||||
}
|
||||
// Economy
|
||||
if (Settings.Enabled_Components.ECONOMY) {
|
||||
TaskManager.runTask(() -> EconHandler.initializeEconHandler());
|
||||
@ -314,7 +313,7 @@ public class PlotSquared {
|
||||
}
|
||||
|
||||
// World generators:
|
||||
final ConfigurationSection section = this.worlds.getConfigurationSection("worlds");
|
||||
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
|
||||
if (section != null) {
|
||||
for (String world : section.getKeys(false)) {
|
||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||
@ -505,10 +504,10 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
Set<PlotCluster> clusters;
|
||||
if (clusters_tmp == null || (clusters = clusters_tmp.remove(plotArea.toString())) == null) {
|
||||
if (clustersTmp == null || (clusters = clustersTmp.remove(plotArea.toString())) == null) {
|
||||
if (plotArea.getType() == PlotAreaType.PARTIAL) {
|
||||
clusters = this.clusters_tmp != null ?
|
||||
this.clusters_tmp.get(plotArea.getWorldName()) :
|
||||
clusters = this.clustersTmp != null ?
|
||||
this.clustersTmp.get(plotArea.getWorldName()) :
|
||||
null;
|
||||
if (clusters != null) {
|
||||
Iterator<PlotCluster> iterator = clusters.iterator();
|
||||
@ -594,10 +593,10 @@ public class PlotSquared {
|
||||
for (Plot plot : area.getPlots()) {
|
||||
map.put(plot.getId(), plot);
|
||||
}
|
||||
if (this.clusters_tmp == null) {
|
||||
this.clusters_tmp = new HashMap<>();
|
||||
if (this.clustersTmp == null) {
|
||||
this.clustersTmp = new HashMap<>();
|
||||
}
|
||||
this.clusters_tmp.put(area.toString(), area.getClusters());
|
||||
this.clustersTmp.put(area.toString(), area.getClusters());
|
||||
}
|
||||
|
||||
public Set<PlotCluster> getClusters(@NotNull final String world) {
|
||||
@ -932,13 +931,13 @@ public class PlotSquared {
|
||||
}
|
||||
this.plotAreaManager.addWorld(world);
|
||||
Set<String> worlds;
|
||||
if (this.worlds.contains("worlds")) {
|
||||
worlds = this.worlds.getConfigurationSection("worlds").getKeys(false);
|
||||
if (this.worldConfiguration.contains("worlds")) {
|
||||
worlds = this.worldConfiguration.getConfigurationSection("worlds").getKeys(false);
|
||||
} else {
|
||||
worlds = new HashSet<>();
|
||||
}
|
||||
String path = "worlds." + world;
|
||||
ConfigurationSection worldSection = this.worlds.getConfigurationSection(path);
|
||||
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(path);
|
||||
PlotAreaType type;
|
||||
if (worldSection != null) {
|
||||
type = MainUtil.getType(worldSection);
|
||||
@ -981,14 +980,14 @@ public class PlotSquared {
|
||||
PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
PlotSquared.log(
|
||||
Captions.PREFIX + "&3 - plotAreaManager: &7" + plotManager.getClass().getName());
|
||||
if (!this.worlds.contains(path)) {
|
||||
this.worlds.createSection(path);
|
||||
worldSection = this.worlds.getConfigurationSection(path);
|
||||
if (!this.worldConfiguration.contains(path)) {
|
||||
this.worldConfiguration.createSection(path);
|
||||
worldSection = this.worldConfiguration.getConfigurationSection(path);
|
||||
}
|
||||
plotArea.saveConfiguration(worldSection);
|
||||
plotArea.loadDefaultConfiguration(worldSection);
|
||||
try {
|
||||
this.worlds.save(this.worldsFile);
|
||||
this.worldConfiguration.save(this.worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1009,7 +1008,7 @@ public class PlotSquared {
|
||||
String gen_string = worldSection.getString("generator.plugin", platform.getPluginName());
|
||||
if (type == PlotAreaType.PARTIAL) {
|
||||
Set<PlotCluster> clusters =
|
||||
this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<>();
|
||||
this.clustersTmp != null ? this.clustersTmp.get(world) : new HashSet<>();
|
||||
if (clusters == null) {
|
||||
throw new IllegalArgumentException("No cluster exists for world: " + world);
|
||||
}
|
||||
@ -1032,7 +1031,7 @@ public class PlotSquared {
|
||||
pa.saveConfiguration(worldSection);
|
||||
pa.loadDefaultConfiguration(worldSection);
|
||||
try {
|
||||
this.worlds.save(this.worldsFile);
|
||||
this.worldConfiguration.save(this.worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1061,7 +1060,7 @@ public class PlotSquared {
|
||||
pa.saveConfiguration(worldSection);
|
||||
pa.loadDefaultConfiguration(worldSection);
|
||||
try {
|
||||
this.worlds.save(this.worldsFile);
|
||||
this.worldConfiguration.save(this.worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1138,7 +1137,7 @@ public class PlotSquared {
|
||||
}
|
||||
pa.loadDefaultConfiguration(clone);
|
||||
try {
|
||||
this.worlds.save(this.worldsFile);
|
||||
this.worldConfiguration.save(this.worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1212,7 +1211,7 @@ public class PlotSquared {
|
||||
}
|
||||
|
||||
HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator,
|
||||
null, null, this.eventDispatcher, this.plotListener);
|
||||
null, null, this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
for (String element : split) {
|
||||
String[] pair = element.split("=");
|
||||
if (pair.length != 2) {
|
||||
@ -1226,41 +1225,41 @@ public class PlotSquared {
|
||||
switch (key) {
|
||||
case "s":
|
||||
case "size":
|
||||
this.worlds.set(base + "plot.size",
|
||||
this.worldConfiguration.set(base + "plot.size",
|
||||
ConfigurationUtil.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
case "g":
|
||||
case "gap":
|
||||
this.worlds.set(base + "road.width",
|
||||
this.worldConfiguration.set(base + "road.width",
|
||||
ConfigurationUtil.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
case "h":
|
||||
case "height":
|
||||
this.worlds.set(base + "road.height",
|
||||
this.worldConfiguration.set(base + "road.height",
|
||||
ConfigurationUtil.INTEGER.parseString(value).shortValue());
|
||||
this.worlds.set(base + "plot.height",
|
||||
this.worldConfiguration.set(base + "plot.height",
|
||||
ConfigurationUtil.INTEGER.parseString(value).shortValue());
|
||||
this.worlds.set(base + "wall.height",
|
||||
this.worldConfiguration.set(base + "wall.height",
|
||||
ConfigurationUtil.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
case "f":
|
||||
case "floor":
|
||||
this.worlds.set(base + "plot.floor",
|
||||
this.worldConfiguration.set(base + "plot.floor",
|
||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
|
||||
break;
|
||||
case "m":
|
||||
case "main":
|
||||
this.worlds.set(base + "plot.filling",
|
||||
this.worldConfiguration.set(base + "plot.filling",
|
||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
|
||||
break;
|
||||
case "w":
|
||||
case "wall":
|
||||
this.worlds.set(base + "wall.filling",
|
||||
this.worldConfiguration.set(base + "wall.filling",
|
||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
|
||||
break;
|
||||
case "b":
|
||||
case "border":
|
||||
this.worlds.set(base + "wall.block",
|
||||
this.worldConfiguration.set(base + "wall.block",
|
||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
|
||||
break;
|
||||
default:
|
||||
@ -1275,10 +1274,10 @@ public class PlotSquared {
|
||||
}
|
||||
try {
|
||||
ConfigurationSection section =
|
||||
this.worlds.getConfigurationSection("worlds." + world);
|
||||
this.worldConfiguration.getConfigurationSection("worlds." + world);
|
||||
plotworld.saveConfiguration(section);
|
||||
plotworld.loadDefaultConfiguration(section);
|
||||
this.worlds.save(this.worldsFile);
|
||||
this.worldConfiguration.save(this.worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1425,19 +1424,19 @@ public class PlotSquared {
|
||||
this.platform.shutdown(); //shutdown used instead of disable because no database is set
|
||||
return;
|
||||
}
|
||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, this.eventDispatcher, this.plotListener);
|
||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
this.plots_tmp = DBFunc.getPlots();
|
||||
if (plotAreaManager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) plotAreaManager).getArea();
|
||||
addPlotArea(area);
|
||||
ConfigurationSection section = worlds.getConfigurationSection("worlds.*");
|
||||
ConfigurationSection section = worldConfiguration.getConfigurationSection("worlds.*");
|
||||
if (section == null) {
|
||||
section = worlds.createSection("worlds.*");
|
||||
section = worldConfiguration.createSection("worlds.*");
|
||||
}
|
||||
area.saveConfiguration(section);
|
||||
area.loadDefaultConfiguration(section);
|
||||
}
|
||||
this.clusters_tmp = DBFunc.getClusters();
|
||||
this.clustersTmp = DBFunc.getClusters();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
PlotSquared.log(Captions.PREFIX
|
||||
+ "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
@ -1472,9 +1471,9 @@ public class PlotSquared {
|
||||
if (getConfig().contains("worlds")) {
|
||||
ConfigurationSection worldSection =
|
||||
getConfig().getConfigurationSection("worlds");
|
||||
worlds.set("worlds", worldSection);
|
||||
worldConfiguration.set("worlds", worldSection);
|
||||
try {
|
||||
worlds.save(worldsFile);
|
||||
worldConfiguration.save(worldsFile);
|
||||
} catch (IOException e) {
|
||||
PlotSquared.debug("Failed to save " + platform.getPluginName() + " worlds.yml");
|
||||
e.printStackTrace();
|
||||
@ -1518,12 +1517,12 @@ public class PlotSquared {
|
||||
PlotSquared.log(
|
||||
"Could not create the worlds file, please create \"worlds.yml\" manually.");
|
||||
}
|
||||
this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile);
|
||||
this.worldConfiguration = YamlConfiguration.loadConfiguration(this.worldsFile);
|
||||
|
||||
if (this.worlds.contains("worlds")) {
|
||||
if (!this.worlds.contains("configuration_version") || (
|
||||
!this.worlds.getString("configuration_version")
|
||||
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) && !this.worlds
|
||||
if (this.worldConfiguration.contains("worlds")) {
|
||||
if (!this.worldConfiguration.contains("configuration_version") || (
|
||||
!this.worldConfiguration.getString("configuration_version")
|
||||
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) && !this.worldConfiguration
|
||||
.getString("configuration_version").equalsIgnoreCase("v5"))) {
|
||||
// Conversion needed
|
||||
log(Captions.LEGACY_CONFIG_FOUND.getTranslated());
|
||||
@ -1532,10 +1531,10 @@ public class PlotSquared {
|
||||
.copy(this.worldsFile, new File(folder, "worlds.yml.old"));
|
||||
log(Captions.LEGACY_CONFIG_BACKUP.getTranslated());
|
||||
final ConfigurationSection worlds =
|
||||
this.worlds.getConfigurationSection("worlds");
|
||||
this.worldConfiguration.getConfigurationSection("worlds");
|
||||
final LegacyConverter converter = new LegacyConverter(worlds);
|
||||
converter.convert();
|
||||
this.worlds.set("worlds", worlds);
|
||||
this.worldConfiguration.set("worlds", worlds);
|
||||
this.setConfigurationVersion(LegacyConverter.CONFIGURATION_VERSION);
|
||||
log(Captions.LEGACY_CONFIG_DONE.getTranslated());
|
||||
} catch (final Exception e) {
|
||||
@ -1547,7 +1546,7 @@ public class PlotSquared {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
this.worlds.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
|
||||
this.worldConfiguration.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
PlotSquared.log("Failed to save settings.yml");
|
||||
@ -1564,20 +1563,21 @@ public class PlotSquared {
|
||||
PlotSquared.log("Failed to save settings.yml");
|
||||
}
|
||||
try {
|
||||
this.styleFile = MainUtil.getFile(platform.getDirectory(),
|
||||
// TODO: REMOVE
|
||||
File styleFile = MainUtil.getFile(platform.getDirectory(),
|
||||
Settings.Paths.TRANSLATIONS + File.separator + "style.yml");
|
||||
if (!this.styleFile.exists()) {
|
||||
if (!this.styleFile.getParentFile().exists()) {
|
||||
this.styleFile.getParentFile().mkdirs();
|
||||
if (!styleFile.exists()) {
|
||||
if (!styleFile.getParentFile().exists()) {
|
||||
styleFile.getParentFile().mkdirs();
|
||||
}
|
||||
if (!this.styleFile.createNewFile()) {
|
||||
if (!styleFile.createNewFile()) {
|
||||
PlotSquared.log(
|
||||
"Could not create the style file, please create \"translations/style.yml\" manually");
|
||||
}
|
||||
}
|
||||
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
||||
this.style = YamlConfiguration.loadConfiguration(styleFile);
|
||||
setupStyle();
|
||||
this.style.save(this.styleFile);
|
||||
this.style.save(styleFile);
|
||||
} catch (IOException err) {
|
||||
err.printStackTrace();
|
||||
PlotSquared.log("Failed to save style.yml");
|
||||
@ -1588,7 +1588,7 @@ public class PlotSquared {
|
||||
PlotSquared.log(
|
||||
"Could not the storage settings file, please create \"storage.yml\" manually.");
|
||||
}
|
||||
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
||||
YamlConfiguration.loadConfiguration(this.storageFile);
|
||||
setupStorage();
|
||||
} catch (IOException ignored) {
|
||||
PlotSquared.log("Failed to save storage.yml");
|
||||
@ -1597,13 +1597,13 @@ public class PlotSquared {
|
||||
}
|
||||
|
||||
public String getConfigurationVersion() {
|
||||
return this.worlds.get("configuration_version", LegacyConverter.CONFIGURATION_VERSION)
|
||||
return this.worldConfiguration.get("configuration_version", LegacyConverter.CONFIGURATION_VERSION)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public void setConfigurationVersion(final String newVersion) throws IOException {
|
||||
this.worlds.set("configuration_version", newVersion);
|
||||
this.worlds.save(this.worldsFile);
|
||||
this.worldConfiguration.set("configuration_version", newVersion);
|
||||
this.worldConfiguration.save(this.worldsFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1612,7 +1612,7 @@ public class PlotSquared {
|
||||
private void setupStorage() {
|
||||
Storage.load(storageFile);
|
||||
Storage.save(storageFile);
|
||||
storage = YamlConfiguration.loadConfiguration(storageFile);
|
||||
YamlConfiguration.loadConfiguration(storageFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.annoations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ConfigFile {
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.annoations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WorldConfig {
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.annoations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WorldFile {
|
||||
}
|
@ -26,9 +26,12 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.annoations.WorldFile;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.generator.AugmentedUtils;
|
||||
import com.plotsquared.core.generator.HybridPlotWorld;
|
||||
@ -68,7 +71,6 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@ -88,12 +90,25 @@ import java.util.Set;
|
||||
aliases = "world",
|
||||
usage = "/plot area <create|info|list|tp|regen>",
|
||||
confirmation = true)
|
||||
@RequiredArgsConstructor
|
||||
public class Area extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotListener plotListener;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
private final File worldFile;
|
||||
|
||||
public Area(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @NotNull final File worldFile) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.worldFile = worldFile;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
@ -150,7 +165,8 @@ public class Area extends SubCommand {
|
||||
// There's only one plot in the area...
|
||||
final PlotId plotId = new PlotId(1, 1);
|
||||
final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorldName(), args[1],
|
||||
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId, this.eventDispatcher, this.plotListener);
|
||||
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId,
|
||||
this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
// Plot size is the same as the region width
|
||||
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
|
||||
// We use a schematic generator
|
||||
@ -210,12 +226,10 @@ public class Area extends SubCommand {
|
||||
final int offsetX = singlePos1.getX();
|
||||
final int offsetZ = singlePos1.getZ();
|
||||
if (offsetX != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.x", offsetX);
|
||||
this.worldConfiguration.set(path + ".road.offset.x", offsetX);
|
||||
}
|
||||
if (offsetZ != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.z", offsetZ);
|
||||
this.worldConfiguration.set(path + ".road.offset.z", offsetZ);
|
||||
}
|
||||
final String world = SetupUtils.manager.setupWorld(singleBuilder);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
@ -303,12 +317,10 @@ public class Area extends SubCommand {
|
||||
+ builder.minimumId() + '-' + builder.maximumId();
|
||||
Runnable run = () -> {
|
||||
if (offsetX != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.x", offsetX);
|
||||
this.worldConfiguration.set(path + ".road.offset.x", offsetX);
|
||||
}
|
||||
if (offsetZ != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.z", offsetZ);
|
||||
this.worldConfiguration.set(path + ".road.offset.z", offsetZ);
|
||||
}
|
||||
final String world = SetupUtils.manager.setupWorld(builder);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
@ -351,7 +363,8 @@ public class Area extends SubCommand {
|
||||
PlotAreaBuilder builder = new PlotAreaBuilder();
|
||||
builder.worldName(split[0]);
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
|
||||
PlotSquared.platform().getDefaultGenerator(), null, null, this.eventDispatcher, this.plotListener);
|
||||
PlotSquared.platform().getDefaultGenerator(), null, null, this.eventDispatcher,
|
||||
this.plotListener, this.worldConfiguration);
|
||||
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
|
||||
if (other != null && Objects.equals(pa.getId(), other.getId())) {
|
||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||
@ -433,11 +446,10 @@ public class Area extends SubCommand {
|
||||
}
|
||||
Runnable run = () -> {
|
||||
String path = "worlds." + pa.getWorldName();
|
||||
if (!PlotSquared.get().worlds.contains(path)) {
|
||||
PlotSquared.get().worlds.createSection(path);
|
||||
if (!this.worldConfiguration.contains(path)) {
|
||||
this.worldConfiguration.createSection(path);
|
||||
}
|
||||
ConfigurationSection section =
|
||||
PlotSquared.get().worlds.getConfigurationSection(path);
|
||||
ConfigurationSection section = this.worldConfiguration.getConfigurationSection(path);
|
||||
pa.saveConfiguration(section);
|
||||
pa.loadConfiguration(section);
|
||||
builder.plotManager(PlotSquared.platform().getPluginName());
|
||||
@ -453,7 +465,7 @@ public class Area extends SubCommand {
|
||||
.getWorldName());
|
||||
}
|
||||
try {
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
this.worldConfiguration.save(this.worldFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.database.Database;
|
||||
import com.plotsquared.core.database.MySQL;
|
||||
@ -64,12 +66,14 @@ public class DatabaseCommand extends SubCommand {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotListener plotListener;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
|
||||
public DatabaseCommand(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener) {
|
||||
@NotNull final PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
}
|
||||
|
||||
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
||||
@ -127,7 +131,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
MainUtil.sendMessage(player, "&6Starting...");
|
||||
implementation = new SQLite(file);
|
||||
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "",
|
||||
this.eventDispatcher, this.plotListener);
|
||||
this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||
plots = new ArrayList<>();
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
@ -202,7 +206,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
return MainUtil.sendMessage(player, "/plot database [sqlite/mysql]");
|
||||
}
|
||||
try {
|
||||
SQLManager manager = new SQLManager(implementation, prefix, this.eventDispatcher, this.plotListener);
|
||||
SQLManager manager = new SQLManager(implementation, prefix, this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
DatabaseCommand.insertPlots(manager, plots, player);
|
||||
return true;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
|
@ -60,8 +60,10 @@ import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
@ -87,12 +89,15 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final WorldEdit worldEdit;
|
||||
private ScriptEngine engine;
|
||||
private Bindings scope;
|
||||
|
||||
public DebugExec(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
||||
public DebugExec(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||
@Nullable final WorldEdit worldEdit) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.worldEdit = worldEdit;
|
||||
init();
|
||||
/*
|
||||
try {
|
||||
@ -164,7 +169,7 @@ public class DebugExec extends SubCommand {
|
||||
this.scope.put("PS", PlotSquared.get());
|
||||
this.scope.put("GlobalBlockQueue", GlobalBlockQueue.IMP);
|
||||
this.scope.put("ExpireManager", ExpireManager.IMP);
|
||||
if (PlotSquared.get().worldedit != null) {
|
||||
if (this.worldEdit != null) {
|
||||
this.scope.put("WEManager", new WEManager());
|
||||
}
|
||||
this.scope.put("TaskManager", TaskManager.IMP);
|
||||
|
@ -28,6 +28,8 @@ package com.plotsquared.core.command;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.ConfigFile;
|
||||
import com.plotsquared.core.annoations.WorldFile;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
@ -36,6 +38,7 @@ import com.plotsquared.core.util.PremiumVerification;
|
||||
import com.plotsquared.core.util.net.IncendoPaster;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import lombok.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -59,6 +62,15 @@ import java.util.stream.Collectors;
|
||||
requiredType = RequiredType.NONE)
|
||||
public class DebugPaste extends SubCommand {
|
||||
|
||||
private final File configFile;
|
||||
private final File worldfile;
|
||||
|
||||
public DebugPaste(@ConfigFile @NotNull final File configFile,
|
||||
@WorldFile @NotNull final File worldFile) {
|
||||
this.configFile = configFile;
|
||||
this.worldfile = worldFile;
|
||||
}
|
||||
|
||||
private static String readFile(@NonNull final File file) throws IOException {
|
||||
final List<String> lines;
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
@ -142,13 +154,13 @@ public class DebugPaste extends SubCommand {
|
||||
|
||||
try {
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("settings.yml",
|
||||
readFile(PlotSquared.get().configFile)));
|
||||
readFile(this.configFile)));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cSkipping settings.yml because it's empty");
|
||||
}
|
||||
try {
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("worlds.yml",
|
||||
readFile(PlotSquared.get().worldsFile)));
|
||||
readFile(this.worldfile)));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cSkipping worlds.yml because it's empty");
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package com.plotsquared.core.command;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
@ -41,7 +42,9 @@ import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -68,17 +71,20 @@ public class MainCommand extends Command {
|
||||
final PlotAreaManager plotAreaManager = PlotSquared.get().getPlotAreaManager();
|
||||
final EventDispatcher eventDispatcher = PlotSquared.get().getEventDispatcher();
|
||||
final PlotListener plotListener = PlotSquared.get().getPlotListener();
|
||||
final YamlConfiguration worldconfiguration = PlotSquared.get().getWorldConfiguration();
|
||||
final File worldFile = PlotSquared.get().getWorldsFile();
|
||||
final WorldEdit worldEdit = PlotSquared.get().getWorldedit();
|
||||
|
||||
new Caps();
|
||||
new Buy(eventDispatcher);
|
||||
new Save(plotAreaManager);
|
||||
new Load(plotAreaManager);
|
||||
new Confirm();
|
||||
new Template(plotAreaManager);
|
||||
new Template(plotAreaManager, worldconfiguration, worldFile);
|
||||
new Download(plotAreaManager);
|
||||
new Template(plotAreaManager);
|
||||
new Template(plotAreaManager, worldconfiguration, worldFile);
|
||||
new Setup();
|
||||
new Area(plotAreaManager, eventDispatcher, plotListener);
|
||||
new Area(plotAreaManager, eventDispatcher, plotListener, worldconfiguration, worldFile);
|
||||
new DebugSaveTest();
|
||||
new DebugLoadTest();
|
||||
new CreateRoadSchematic();
|
||||
@ -103,20 +109,20 @@ public class MainCommand extends Command {
|
||||
new SchematicCmd(plotAreaManager);
|
||||
new PluginCmd();
|
||||
new Purge(plotAreaManager, plotListener);
|
||||
new Reload(plotAreaManager);
|
||||
new Reload(plotAreaManager, worldconfiguration, worldFile);
|
||||
new Relight();
|
||||
new Merge(eventDispatcher);
|
||||
new DebugPaste();
|
||||
new DebugPaste(PlotSquared.get().getConfigFile(), PlotSquared.get().getWorldsFile());
|
||||
new Unlink(eventDispatcher);
|
||||
new Kick(plotAreaManager);
|
||||
new Inbox();
|
||||
new Comment();
|
||||
new DatabaseCommand(plotAreaManager, eventDispatcher, plotListener);
|
||||
new DatabaseCommand(plotAreaManager, eventDispatcher, plotListener, worldconfiguration);
|
||||
new Swap();
|
||||
new Music();
|
||||
new DebugRoadRegen();
|
||||
new Trust(eventDispatcher);
|
||||
new DebugExec(plotAreaManager, eventDispatcher);
|
||||
new DebugExec(plotAreaManager, eventDispatcher, worldEdit);
|
||||
new FlagCommand();
|
||||
new Target();
|
||||
new Move(plotAreaManager);
|
||||
|
@ -26,6 +26,8 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.annoations.WorldFile;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.MemorySection;
|
||||
@ -36,6 +38,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -48,9 +51,15 @@ import java.util.Objects;
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
private final File worldFile;
|
||||
|
||||
public Reload(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
public Reload(@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 boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
@ -60,7 +69,7 @@ public class Reload extends SubCommand {
|
||||
PlotSquared.get().setupConfigs();
|
||||
Captions.load(PlotSquared.get().translationFile);
|
||||
this.plotAreaManager.forEachPlotArea(area -> {
|
||||
ConfigurationSection worldSection = PlotSquared.get().worlds
|
||||
ConfigurationSection worldSection = this.worldConfiguration
|
||||
.getConfigurationSection("worlds." + area.getWorldName());
|
||||
if (worldSection == null) {
|
||||
return;
|
||||
@ -106,7 +115,7 @@ public class Reload extends SubCommand {
|
||||
area.loadDefaultConfiguration(clone);
|
||||
}
|
||||
});
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
this.worldConfiguration.save(this.worldFile);
|
||||
MainUtil.sendMessage(player, Captions.RELOADED_CONFIGS);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -26,6 +26,8 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.annoations.WorldFile;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
@ -64,9 +66,15 @@ import java.util.zip.ZipOutputStream;
|
||||
public class Template extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
private final File worldFile;
|
||||
|
||||
public Template(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
public Template(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @NotNull final File worldFile) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.worldFile = worldFile;
|
||||
}
|
||||
|
||||
public static boolean extractAllFiles(String world, String template) {
|
||||
@ -113,8 +121,7 @@ public class Template extends SubCommand {
|
||||
}
|
||||
|
||||
public static byte[] getBytes(PlotArea plotArea) {
|
||||
ConfigurationSection section =
|
||||
PlotSquared.get().worlds.getConfigurationSection("worlds." + plotArea.getWorldName());
|
||||
ConfigurationSection section = PlotSquared.get().getWorldConfiguration().getConfigurationSection("worlds." + plotArea.getWorldName());
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
String generator = SetupUtils.manager.getGenerator(plotArea);
|
||||
if (generator != null) {
|
||||
@ -180,10 +187,10 @@ public class Template extends SubCommand {
|
||||
File worldFile = MainUtil.getFile(PlotSquared.platform().getDirectory(),
|
||||
Settings.Paths.TEMPLATES + File.separator + "tmp-data.yml");
|
||||
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
|
||||
PlotSquared.get().worlds.set("worlds." + world, worldConfig.get(""));
|
||||
this.worldConfiguration.set("worlds." + world, worldConfig.get(""));
|
||||
try {
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
PlotSquared.get().worlds.load(PlotSquared.get().worldsFile);
|
||||
this.worldConfiguration.save(this.worldFile);
|
||||
this.worldConfiguration.load(this.worldFile);
|
||||
} catch (InvalidConfigurationException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -27,10 +27,12 @@ package com.plotsquared.core.database;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.Storage;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.location.BlockLoc;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
@ -132,6 +134,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotListener plotListener;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -141,12 +144,16 @@ public class SQLManager implements AbstractDB {
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public SQLManager(final Database database, String prefix,
|
||||
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener)
|
||||
public SQLManager(@NotNull final Database database,
|
||||
@NotNull final String prefix,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration)
|
||||
throws SQLException, ClassNotFoundException {
|
||||
// Private final
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.database = database;
|
||||
this.connection = database.openConnection();
|
||||
this.mySQL = database instanceof MySQL;
|
||||
@ -1750,9 +1757,8 @@ public class SQLManager implements AbstractDB {
|
||||
HashMap<Integer, Plot> plots = new HashMap<>();
|
||||
try {
|
||||
HashSet<String> areas = new HashSet<>();
|
||||
if (PlotSquared.get().worlds.contains("worlds")) {
|
||||
ConfigurationSection worldSection =
|
||||
PlotSquared.get().worlds.getConfigurationSection("worlds");
|
||||
if (this.worldConfiguration.contains("worlds")) {
|
||||
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection("worlds");
|
||||
if (worldSection != null) {
|
||||
for (String worldKey : worldSection.getKeys(false)) {
|
||||
areas.add(worldKey);
|
||||
@ -2714,9 +2720,8 @@ public class SQLManager implements AbstractDB {
|
||||
HashMap<Integer, PlotCluster> clusters = new HashMap<>();
|
||||
try {
|
||||
HashSet<String> areas = new HashSet<>();
|
||||
if (PlotSquared.get().worlds.contains("worlds")) {
|
||||
ConfigurationSection worldSection =
|
||||
PlotSquared.get().worlds.getConfigurationSection("worlds");
|
||||
if (this.worldConfiguration.contains("worlds")) {
|
||||
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection("worlds");
|
||||
if (worldSection != null) {
|
||||
for (String worldKey : worldSection.getKeys(false)) {
|
||||
areas.add(worldKey);
|
||||
|
@ -25,15 +25,18 @@
|
||||
*/
|
||||
package com.plotsquared.core.generator;
|
||||
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.plot.BlockBucket;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
@ -55,10 +58,15 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
// BlockUtil.get((short) 155, (byte) 0);
|
||||
public boolean PLOT_BEDROCK = true;
|
||||
|
||||
public ClassicPlotWorld(String worldName, String id,
|
||||
@NotNull IndependentPlotGenerator generator, PlotId min, PlotId max, @NotNull final
|
||||
EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||
public ClassicPlotWorld(@NotNull final String worldName,
|
||||
@Nullable final String id,
|
||||
@NotNull final IndependentPlotGenerator generator,
|
||||
@NotNull final PlotId min,
|
||||
@NotNull final PlotId max,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,8 @@
|
||||
*/
|
||||
package com.plotsquared.core.generator;
|
||||
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
@ -37,7 +39,7 @@ public abstract class GridPlotWorld extends PlotArea {
|
||||
|
||||
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||
PlotListener plotListener) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||
PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ package com.plotsquared.core.generator;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
@ -38,13 +40,21 @@ import com.plotsquared.core.util.MathMan;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@RequiredArgsConstructor public class HybridGen extends IndependentPlotGenerator {
|
||||
public class HybridGen extends IndependentPlotGenerator {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotListener plotListener;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
|
||||
public HybridGen(@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
}
|
||||
|
||||
@Override public String getName() {
|
||||
return PlotSquared.platform().getPluginName();
|
||||
@ -227,7 +237,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
}
|
||||
|
||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return new HybridPlotWorld(world, id, this, min, max, this.eventDispatcher, this.plotListener);
|
||||
return new HybridPlotWorld(world, id, this, min, max, this.eventDispatcher,
|
||||
this.plotListener, this.worldConfiguration);
|
||||
}
|
||||
|
||||
@Override public void initialize(PlotArea area) {
|
||||
|
@ -26,9 +26,11 @@
|
||||
package com.plotsquared.core.generator;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
@ -74,10 +76,15 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
private Location SIGN_LOCATION;
|
||||
@Getter private File root = null;
|
||||
|
||||
public HybridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||
PlotListener plotListener) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||
public HybridPlotWorld(final String worldName,
|
||||
final String id,
|
||||
@NotNull final IndependentPlotGenerator generator,
|
||||
final PlotId min,
|
||||
final PlotId max,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration);
|
||||
}
|
||||
|
||||
public static byte wrap(byte data, int start) {
|
||||
@ -188,7 +195,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean isCompatible(PlotArea plotArea) {
|
||||
@Override public boolean isCompatible(@NotNull final PlotArea plotArea) {
|
||||
if (!(plotArea instanceof SquarePlotWorld)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -26,7 +26,9 @@
|
||||
package com.plotsquared.core.generator;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
@ -41,8 +43,8 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||
|
||||
public SquarePlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||
PlotListener plotListener) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener);
|
||||
PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration);
|
||||
}
|
||||
|
||||
@Override public void loadConfiguration(ConfigurationSection config) {
|
||||
|
@ -28,6 +28,7 @@ package com.plotsquared.core.plot;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.collection.QuadMap;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
@ -35,6 +36,7 @@ import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.generator.GridPlotWorld;
|
||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
@ -137,11 +139,12 @@ public abstract class PlotArea {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotListener plotListener;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
|
||||
public PlotArea(@NotNull final String worldName, @Nullable final String id,
|
||||
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
|
||||
@Nullable final PlotId max, @NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener) {
|
||||
@NotNull final PlotListener plotListener, @WorldConfig @Nullable final YamlConfiguration worldConfiguration) {
|
||||
this.worldName = worldName;
|
||||
this.id = id;
|
||||
this.plotManager = createManager();
|
||||
@ -160,6 +163,7 @@ public abstract class PlotArea {
|
||||
this.worldHash = worldName.hashCode();
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
}
|
||||
|
||||
@NotNull protected abstract PlotManager createManager();
|
||||
@ -242,8 +246,8 @@ public abstract class PlotArea {
|
||||
* @param plotArea the {@code PlotArea} to compare
|
||||
* @return true if both areas are compatible
|
||||
*/
|
||||
public boolean isCompatible(PlotArea plotArea) {
|
||||
ConfigurationSection section = PlotSquared.get().worlds.getConfigurationSection("worlds");
|
||||
public boolean isCompatible(@NotNull final PlotArea plotArea) {
|
||||
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
|
||||
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
|
||||
Object constant = section.get(plotArea.worldName + '.' + setting.getConstant());
|
||||
if (constant == null || !constant
|
||||
|
@ -390,7 +390,7 @@ public class PlotAnalysis {
|
||||
// Save calibration
|
||||
PlotSquared.debug(" $1Saving calibration");
|
||||
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
|
||||
Settings.save(PlotSquared.get().worldsFile);
|
||||
Settings.save(PlotSquared.get().getWorldsFile());
|
||||
PlotSquared.debug("$1Done!");
|
||||
running = false;
|
||||
for (Plot plot : plots) {
|
||||
|
@ -26,9 +26,11 @@
|
||||
package com.plotsquared.core.plot.world;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.generator.GridPlotWorld;
|
||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
@ -61,8 +63,11 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotListener plotListener;
|
||||
|
||||
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
||||
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null, eventDispatcher, plotListener);
|
||||
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null, eventDispatcher, plotListener, worldConfiguration);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
this.setAllowSigns(false);
|
||||
|
@ -25,7 +25,9 @@
|
||||
*/
|
||||
package com.plotsquared.core.plot.world;
|
||||
|
||||
import com.plotsquared.core.annoations.WorldConfig;
|
||||
import com.plotsquared.core.collection.ArrayUtil;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.location.Location;
|
||||
@ -42,9 +44,10 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
private SinglePlotArea area;
|
||||
private PlotArea[] all;
|
||||
|
||||
public SinglePlotAreaManager(@NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||
PlotListener plotListener) {
|
||||
this.area = new SinglePlotArea(this, eventDispatcher, plotListener);
|
||||
public SinglePlotAreaManager(@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
this.area = new SinglePlotArea(this, eventDispatcher, plotListener, worldConfiguration);
|
||||
this.array = new SinglePlotArea[] {area};
|
||||
this.all = new PlotArea[] {area};
|
||||
SetupUtils.generators.put("PlotSquared:single",
|
||||
|
@ -26,7 +26,6 @@
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
@ -69,10 +68,12 @@ import com.plotsquared.core.plot.flag.implementations.VehiclePlaceFlag;
|
||||
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -80,9 +81,13 @@ import java.util.UUID;
|
||||
|
||||
public class EventDispatcher {
|
||||
|
||||
private EventBus eventBus = new EventBus("PlotSquaredEvents");
|
||||
private final EventBus eventBus = new EventBus("PlotSquaredEvents");
|
||||
private final List<Object> listeners = new ArrayList<>();
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
private List<Object> listeners = new ArrayList<>();
|
||||
public EventDispatcher(@Nullable final WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
public void registerListener(Object listener) {
|
||||
eventBus.register(listener);
|
||||
@ -104,13 +109,13 @@ public class EventDispatcher {
|
||||
eventBus.post(event);
|
||||
}
|
||||
|
||||
public PlayerClaimPlotEvent callClaim(PlotPlayer player, Plot plot, String schematic) {
|
||||
public PlayerClaimPlotEvent callClaim(PlotPlayer<?> player, Plot plot, String schematic) {
|
||||
PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, schematic);
|
||||
callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerAutoPlotEvent callAuto(PlotPlayer player, PlotArea area, String schematic,
|
||||
public PlayerAutoPlotEvent callAuto(PlotPlayer<?> player, PlotArea area, String schematic,
|
||||
int size_x, int size_z) {
|
||||
PlayerAutoPlotEvent event =
|
||||
new PlayerAutoPlotEvent(player, area, schematic, size_x, size_z);
|
||||
@ -118,7 +123,7 @@ public class EventDispatcher {
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerTeleportToPlotEvent callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||
public PlayerTeleportToPlotEvent callTeleport(PlotPlayer<?> player, Location from, Plot plot) {
|
||||
PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot);
|
||||
callEvent(event);
|
||||
return event;
|
||||
@ -154,7 +159,7 @@ public class EventDispatcher {
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlotMergeEvent callMerge(Plot plot, Direction dir, int max, PlotPlayer player) {
|
||||
public PlotMergeEvent callMerge(Plot plot, Direction dir, int max, PlotPlayer<?> player) {
|
||||
PlotMergeEvent event = new PlotMergeEvent(plot.getWorldName(), plot, dir, max, player);
|
||||
callEvent(event);
|
||||
return event;
|
||||
@ -173,40 +178,40 @@ public class EventDispatcher {
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerEnterPlotEvent callEntry(PlotPlayer player, Plot plot) {
|
||||
public PlayerEnterPlotEvent callEntry(PlotPlayer<?> player, Plot plot) {
|
||||
PlayerEnterPlotEvent event = new PlayerEnterPlotEvent(player, plot);
|
||||
callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerLeavePlotEvent callLeave(PlotPlayer player, Plot plot) {
|
||||
public PlayerLeavePlotEvent callLeave(PlotPlayer<?> player, Plot plot) {
|
||||
PlayerLeavePlotEvent event = new PlayerLeavePlotEvent(player, plot);
|
||||
callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerPlotDeniedEvent callDenied(PlotPlayer initiator, Plot plot, UUID player,
|
||||
public PlayerPlotDeniedEvent callDenied(PlotPlayer<?> initiator, Plot plot, UUID player,
|
||||
boolean added) {
|
||||
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(initiator, plot, player, added);
|
||||
callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerPlotTrustedEvent callTrusted(PlotPlayer initiator, Plot plot, UUID player,
|
||||
public PlayerPlotTrustedEvent callTrusted(PlotPlayer<?> initiator, Plot plot, UUID player,
|
||||
boolean added) {
|
||||
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(initiator, plot, player, added);
|
||||
callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlayerPlotHelperEvent callMember(PlotPlayer initiator, Plot plot, UUID player,
|
||||
public PlayerPlotHelperEvent callMember(PlotPlayer<?> initiator, Plot plot, UUID player,
|
||||
boolean added) {
|
||||
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(initiator, plot, player, added);
|
||||
callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlotChangeOwnerEvent callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner,
|
||||
public PlotChangeOwnerEvent callOwnerChange(PlotPlayer<?> initiator, Plot plot, UUID oldOwner,
|
||||
UUID newOwner, boolean hasOldOwner) {
|
||||
PlotChangeOwnerEvent event =
|
||||
new PlotChangeOwnerEvent(initiator, plot, oldOwner, newOwner, hasOldOwner);
|
||||
@ -214,7 +219,7 @@ public class EventDispatcher {
|
||||
return event;
|
||||
}
|
||||
|
||||
public PlotRateEvent callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
public PlotRateEvent callRating(PlotPlayer<?> player, Plot plot, Rating rating) {
|
||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||
eventBus.post(event);
|
||||
return event;
|
||||
@ -226,14 +231,14 @@ public class EventDispatcher {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void doJoinTask(final PlotPlayer player) {
|
||||
public void doJoinTask(final PlotPlayer<?> player) {
|
||||
if (player == null) {
|
||||
return; //possible future warning message to figure out where we are retrieving null
|
||||
}
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.handleJoin(player);
|
||||
}
|
||||
if (PlotSquared.get().worldedit != null) {
|
||||
if (this.worldEdit != null) {
|
||||
if (player.getAttribute("worldedit")) {
|
||||
MainUtil.sendMessage(player, Captions.WORLDEDIT_BYPASSED);
|
||||
}
|
||||
@ -249,7 +254,7 @@ public class EventDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
public void doRespawnTask(final PlotPlayer player) {
|
||||
public void doRespawnTask(final PlotPlayer<?> player) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (Settings.Teleport.ON_DEATH && plot != null) {
|
||||
TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {
|
||||
@ -258,7 +263,7 @@ public class EventDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer player, @NotNull PlayerBlockEventType type,
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer<?> player, @NotNull PlayerBlockEventType type,
|
||||
Location location, BlockType blockType, boolean notifyPerms) {
|
||||
PlotArea area = location.getPlotArea();
|
||||
assert area != null;
|
||||
|
@ -1,154 +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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.plot.util;
|
||||
|
||||
import com.plotsquared.core.events.PlayerAutoPlotEvent;
|
||||
import com.plotsquared.core.events.PlayerClaimPlotEvent;
|
||||
import com.plotsquared.core.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.core.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.core.events.PlayerPlotDeniedEvent;
|
||||
import com.plotsquared.core.events.PlayerPlotHelperEvent;
|
||||
import com.plotsquared.core.events.PlayerPlotTrustedEvent;
|
||||
import com.plotsquared.core.events.PlayerTeleportToPlotEvent;
|
||||
import com.plotsquared.core.events.PlotAutoMergeEvent;
|
||||
import com.plotsquared.core.events.PlotChangeOwnerEvent;
|
||||
import com.plotsquared.core.events.PlotClearEvent;
|
||||
import com.plotsquared.core.events.PlotComponentSetEvent;
|
||||
import com.plotsquared.core.events.PlotDeleteEvent;
|
||||
import com.plotsquared.core.events.PlotDoneEvent;
|
||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.core.events.PlotMergeEvent;
|
||||
import com.plotsquared.core.events.PlotRateEvent;
|
||||
import com.plotsquared.core.events.PlotUnlinkEvent;
|
||||
import com.plotsquared.core.location.Direction;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.Rating;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EventDispatcherTest extends EventDispatcher {
|
||||
|
||||
@Override public PlotRateEvent callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerClaimPlotEvent callClaim(PlotPlayer player, Plot plot, String schematic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAutoPlotEvent callAuto(PlotPlayer player, PlotArea area, String schematic,
|
||||
int size_x, int size_z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerTeleportToPlotEvent callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotComponentSetEvent callComponentSet(Plot plot, String component, Pattern pattern) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotClearEvent callClear(Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotDeleteEvent callDelete(Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotFlagAddEvent callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotFlagRemoveEvent callFlagRemove(PlotFlag<?, ?> flag, Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotMergeEvent callMerge(Plot plot, Direction dir, int max, PlotPlayer player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotAutoMergeEvent callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotUnlinkEvent callUnlink(PlotArea area, Plot plot, boolean createRoad,
|
||||
boolean createSign, PlotUnlinkEvent.REASON reason) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlayerEnterPlotEvent callEntry(PlotPlayer player, Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlayerLeavePlotEvent callLeave(PlotPlayer player, Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerPlotDeniedEvent callDenied(PlotPlayer initiator, Plot plot, UUID player,
|
||||
boolean added) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerPlotTrustedEvent callTrusted(PlotPlayer initiator, Plot plot, UUID player,
|
||||
boolean added) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerPlotHelperEvent callMember(PlotPlayer initiator, Plot plot, UUID player,
|
||||
boolean added) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotChangeOwnerEvent callOwnerChange(PlotPlayer initiator, Plot plot, UUID newOwner,
|
||||
UUID oldOwner, boolean hasOldOwner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotDoneEvent callDone(Plot plot) {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user