extends ILogger {
/**
* Logs a message to console.
@@ -93,20 +92,6 @@ public interface IPlotMain
extends ILogger {
*/
void shutdown();
- /**
- * Gets the version of the PlotSquared being used.
- *
- * @return the plugin version
- */
- int[] getPluginVersion();
-
- /**
- * Gets the version of the PlotSquared being used as a string.
- *
- * @return the plugin version as a string
- */
- String getPluginVersionString();
-
default String getPluginName() {
return "PlotSquared";
}
@@ -128,13 +113,6 @@ public interface IPlotMain
extends ILogger {
*/
ChatManager initChatManager();
- /**
- * The task manager will run and manage Minecraft tasks.
- *
- * @return the PlotSquared task manager
- */
- TaskManager getTaskManager();
-
- /**
- * Run the task that will kill road mobs.
- */
- void runEntityTask();
-
- /**
- * Registerss the implementation specific commands.
- */
- void registerCommands();
-
- /**
- * Register the protection system.
- */
- void registerPlayerEvents();
-
- /**
- * Register force field events.
- */
- void registerForceFieldEvents();
-
- /**
- * Registers the WorldEdit hook.
- */
- boolean initWorldEdit();
-
- /**
- * Gets the economy provider, if there is one
- *
- * @return the PlotSquared economy manager
- */
- @Nullable EconHandler getEconomyHandler();
-
- /**
- * Gets the permission provider, if there is one
- *
- * @return the PlotSquared permission manager
- */
- @Nullable PermHandler getPermissionHandler();
-
- /**
- * Gets the {@link QueueProvider} class.
- */
- QueueProvider initBlockQueue();
-
- /**
- * Gets the {@link WorldUtil} class.
- */
- WorldUtil initWorldUtil();
-
- /**
- * Gets the chunk manager.
- *
- * @return the PlotSquared chunk manager
- */
- ChunkManager initChunkManager();
-
- /**
- * Gets the region manager.
- *
- * @return the PlotSquared region manager
- */
- RegionManager initRegionManager();
-
- /**
- * Gets the {@link SetupUtils} class.
- */
- SetupUtils initSetupUtils();
-
- /**
- * Gets {@link HybridUtils} class.
- */
- HybridUtils initHybridUtils();
-
/**
* Start Metrics.
*/
@@ -234,12 +132,6 @@ public interface IPlotMain
extends ILogger {
*/
void setGenerator(String world);
- /**
- * Gets the {@link InventoryUtil} class (used for implementation specific
- * inventory guis).
- */
- InventoryUtil initInventoryUtil();
-
/**
* Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
*
@@ -258,48 +150,120 @@ public interface IPlotMain
extends ILogger {
GeneratorWrapper> wrapPlotGenerator(String world, IndependentPlotGenerator generator);
- /**
- * Register the chunk processor which will clean out chunks that have too
- * many block states or entities.
- */
- void registerChunkProcessor();
-
- /**
- * Register the world initialization events (used to keep track of worlds
- * being generated).
- */
- void registerWorldEvents();
-
/**
* Usually HybridGen
*
* @return Default implementation generator
*/
- @NotNull IndependentPlotGenerator getDefaultGenerator();
+ @Nonnull default IndependentPlotGenerator getDefaultGenerator() {
+ return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
+ }
List, Boolean>> getPluginIds();
- Actor getConsole();
-
/**
* Get the backup manager instance
*
* @return Backup manager
*/
- @NotNull BackupManager getBackupManager();
+ @Nonnull default BackupManager getBackupManager() {
+ return getInjector().getInstance(BackupManager.class);
+ }
/**
* Get the platform specific world manager
*
* @return World manager
*/
- @NotNull PlatformWorldManager> getWorldManager();
+ @Nonnull default PlatformWorldManager> getWorldManager() {
+ return getInjector().getInstance(PlatformWorldManager.class);
+ }
/**
* Get the player manager implementation for the platform
*
* @return Player manager
*/
- @NotNull PlayerManager extends PlotPlayer
, ? extends P> getPlayerManager() {
+ return getInjector().getInstance(PlayerManager.class);
+ }
+
+ /**
+ * Get a platform world wrapper from a world name
+ *
+ * @param worldName World name
+ * @return Platform world wrapper
+ */
+ @Nonnull World> getPlatformWorld(@Nonnull final String worldName);
+
+ /**
+ * Get the {@link com.google.inject.Injector} instance used by PlotSquared
+ *
+ * @return Injector instance
+ */
+ @Nonnull Injector getInjector();
+
+ /**
+ * Get the world utility implementation
+ *
+ * @return World utility
+ */
+ @Nonnull default WorldUtil getWorldUtil() {
+ return getInjector().getInstance(WorldUtil.class);
+ }
+
+ /**
+ * Get the global block queue implementation
+ *
+ * @return Global block queue implementation
+ */
+ @Nonnull default GlobalBlockQueue getGlobalBlockQueue() {
+ return getInjector().getInstance(GlobalBlockQueue.class);
+ }
+
+ /**
+ * Get the {@link HybridUtils} implementation for the platform
+ *
+ * @return Hybrid utils
+ */
+ @Nonnull default HybridUtils getHybridUtils() {
+ return getInjector().getInstance(HybridUtils.class);
+ }
+
+ /**
+ * Get the {@link SetupUtils}Â implementation for the platform
+ *
+ * @return Setup utils
+ */
+ @Nonnull default SetupUtils getSetupUtils() {
+ return getInjector().getInstance(SetupUtils.class);
+ }
+
+ /**
+ * Get the {@link EconHandler} implementation for the platform
+ * *
+ * @return Econ handler
+ */
+ @Nullable default EconHandler getEconHandler() {
+ return getInjector().getInstance(EconHandler.class);
+ }
+
+ /**
+ * Get the {@link RegionManager} implementation for the platform
+ *
+ * @return Region manager
+ */
+ @Nonnull default RegionManager getRegionManager() {
+ return getInjector().getInstance(RegionManager.class);
+ }
+
+ /**
+ * Get the {@link ChunkManager} implementation for the platform
+ *
+ * @return Region manager
+ */
+ @Nonnull default ChunkManager getChunkManager() {
+ return getInjector().getInstance(ChunkManager.class);
+ }
}
diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java
index d5618ed0f..9a3220f79 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java
@@ -25,8 +25,6 @@
*/
package com.plotsquared.core;
-import com.plotsquared.core.command.WE_Anywhere;
-import com.plotsquared.core.components.ComponentPresetManager;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
@@ -44,53 +42,37 @@ import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.generator.IndependentPlotGenerator;
-import com.plotsquared.core.listener.WESubscriber;
+import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
+import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.Location;
-import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotCluster;
-import com.plotsquared.core.plot.PlotFilter;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotManager;
-import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.ExpiryTask;
-import com.plotsquared.core.plot.world.DefaultPlotAreaManager;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
-import com.plotsquared.core.queue.GlobalBlockQueue;
-import com.plotsquared.core.util.ChatManager;
-import com.plotsquared.core.util.ChunkManager;
-import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher;
-import com.plotsquared.core.util.InventoryUtil;
import com.plotsquared.core.util.LegacyConverter;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.ReflectionUtils;
-import com.plotsquared.core.util.RegionManager;
-import com.plotsquared.core.util.SchematicHandler;
-import com.plotsquared.core.util.SetupUtils;
-import com.plotsquared.core.util.StringMan;
-import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.uuid.UUIDPipeline;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector2;
-import com.sk89q.worldedit.regions.CuboidRegion;
import lombok.Getter;
-import lombok.NonNull;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -115,33 +97,29 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
-import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* An implementation of the core, with a static getter for easy access.
*/
-@SuppressWarnings({"unused", "WeakerAccess"})
+@SuppressWarnings({"WeakerAccess"})
public class PlotSquared {
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotSquared.class.getSimpleName());
-
private static final Set EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
private static PlotSquared instance;
+
// Implementation
- public final IPlotMain> IMP;
+ private final PlotPlatform> platform;
// Current thread
private final Thread thread;
// UUID pipelines
@@ -150,16 +128,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> clusters_tmp;
+ private HashMap> clustersTmp;
public HashMap> plots_tmp;
private YamlConfiguration config;
// Platform / Version / Update URL
@@ -167,23 +143,23 @@ public class PlotSquared {
// Files and configuration
@Getter private File jarFile = null; // This file
private File storageFile;
- @Getter private PlotAreaManager plotAreaManager;
@Getter private EventDispatcher eventDispatcher;
+ @Getter private PlotListener plotListener;
/**
* Initialize PlotSquared with the desired Implementation class.
*
- * @param iPlotMain Implementation of {@link IPlotMain} used
+ * @param iPlotMain Implementation of {@link PlotPlatform} used
* @param platform The platform being used
*/
- public PlotSquared(final IPlotMain iPlotMain, final String platform) {
+ public PlotSquared(final PlotPlatform> iPlotMain, final String platform) {
if (instance != null) {
throw new IllegalStateException("Cannot re-initialize the PlotSquared singleton");
}
instance = this;
this.thread = Thread.currentThread();
- this.IMP = iPlotMain;
+ this.platform = iPlotMain;
Settings.PLATFORM = platform;
//
@@ -192,7 +168,7 @@ public class PlotSquared {
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
try {
- new ReflectionUtils(this.IMP.getNMSPackage());
+ new ReflectionUtils(this.platform.getNMSPackage());
try {
URL logurl = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation();
this.jarFile = new File(
@@ -200,143 +176,28 @@ public class PlotSquared {
.toURI().getPath());
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
e.printStackTrace();
- this.jarFile = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared.jar");
+ this.jarFile = new File(this.platform.getDirectory().getParentFile(), "PlotSquared.jar");
if (!this.jarFile.exists()) {
- this.jarFile = new File(this.IMP.getDirectory().getParentFile(),
+ this.jarFile = new File(this.platform.getDirectory().getParentFile(),
"PlotSquared-" + platform + ".jar");
}
}
- TaskManager.IMP = this.IMP.getTaskManager();
-
- // World Util. Has to be done before config files are loaded
- WorldUtil.IMP = this.IMP.initWorldUtil();
if (!setupConfigs()) {
return;
}
- this.translationFile = MainUtil.getFile(this.IMP.getDirectory(),
- Settings.Paths.TRANSLATIONS + File.separator + IMP.getPluginName()
+
+ this.translationFile = MainUtil.getFile(this.platform.getDirectory(),
+ Settings.Paths.TRANSLATIONS + File.separator + this.platform.getPluginName()
+ ".use_THIS.yml");
Captions.load(this.translationFile);
- // Setup plotAreaManager
- if (Settings.Enabled_Components.WORLDS) {
- this.plotAreaManager = new SinglePlotAreaManager();
- } else {
- this.plotAreaManager = new DefaultPlotAreaManager();
- }
+ this.worldedit = WorldEdit.getInstance();
- // Database
- if (Settings.Enabled_Components.DATABASE) {
- setupDatabase();
- }
-
- // Check if we need to convert old flag values, etc
- if (!getConfigurationVersion().equalsIgnoreCase("v5")) {
- // Perform upgrade
- if (DBFunc.dbManager.convertFlags()) {
- logger.info("[P2] Flags were converted successfully");
- // Update the config version
- setConfigurationVersion("v5");
- }
- }
-
- // Comments
- CommentManager.registerDefaultInboxes();
- // Kill entities
- if (Settings.Enabled_Components.KILL_ROAD_MOBS
- || Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
- this.IMP.runEntityTask();
- }
- if (Settings.Enabled_Components.EVENTS) {
- this.IMP.registerPlayerEvents();
- }
- // Required
- this.IMP.registerWorldEvents();
- if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
- this.IMP.registerChunkProcessor();
- }
- startExpiryTasks();
// Create Event utility class
- eventDispatcher = new EventDispatcher();
- // create Hybrid utility class
- HybridUtils.manager = this.IMP.initHybridUtils();
- // Inventory utility class
- InventoryUtil.manager = this.IMP.initInventoryUtil();
- // create setup util class
- SetupUtils.manager = this.IMP.initSetupUtils();
- // Set block
- GlobalBlockQueue.IMP =
- new GlobalBlockQueue(IMP.initBlockQueue(), 1, Settings.QUEUE.TARGET_TIME);
- GlobalBlockQueue.IMP.runTask();
- // Set chunk
- ChunkManager.manager = this.IMP.initChunkManager();
- RegionManager.manager = this.IMP.initRegionManager();
- // Schematic handler
- SchematicHandler.manager = this.IMP.initSchematicHandler();
- // Chat
- ChatManager.manager = this.IMP.initChatManager();
- // Commands
- if (Settings.Enabled_Components.COMMANDS) {
- this.IMP.registerCommands();
- }
- // WorldEdit
- if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
- try {
- if (this.IMP.initWorldEdit()) {
- logger.info("[P2] {} hooked into WorldEdit", imp().getPluginName());
- this.worldedit = WorldEdit.getInstance();
- WorldEdit.getInstance().getEventBus().register(new WESubscriber());
- if (Settings.Enabled_Components.COMMANDS) {
- new WE_Anywhere();
- }
-
- }
- } catch (Throwable e) {
- logger.error("[P2] Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
-
- }
- }
- // Economy
- if (Settings.Enabled_Components.ECONOMY) {
- TaskManager.runTask(() -> EconHandler.initializeEconHandler());
- }
-
- if (Settings.Enabled_Components.COMPONENT_PRESETS) {
- try {
- new ComponentPresetManager();
- } catch (final Exception e) {
- logger.error("[P2] Failed to initialize the preset system", e);
- }
- }
-
- // World generators:
- final ConfigurationSection section = this.worlds.getConfigurationSection("worlds");
- if (section != null) {
- for (String world : section.getKeys(false)) {
- if (world.equals("CheckingPlotSquaredGenerator")) {
- continue;
- }
- if (WorldUtil.IMP.isWorld(world)) {
- this.IMP.setGenerator(world);
- }
- }
- TaskManager.runTaskLater(() -> {
- for (String world : section.getKeys(false)) {
- if (world.equals("CheckingPlotSquaredGenerator")) {
- continue;
- }
- if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
- logger.warn("[P2] `{}` was not properly loaded - {} will now try to load it properly",
- world, imp().getPluginName());
- logger.warn("[P2] - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
- logger.warn("[P2] - Your world management plugin may be faulty (or non existent)");
- logger.warn("[P2] This message may also be a false positive and could be ignored.");
- PlotSquared.this.IMP.setGenerator(world);
- }
- }
- }, 1);
- }
+ this.eventDispatcher = new EventDispatcher(this.worldedit);
+ // Create plot listener
+ this.plotListener = new PlotListener(this.eventDispatcher);
// Copy files
copyFile("addplots.js", Settings.Paths.SCRIPTS);
@@ -361,7 +222,15 @@ public class PlotSquared {
} catch (Throwable e) {
e.printStackTrace();
}
+ }
+ /**
+ * Get the platform specific {@link PlotAreaManager} instance
+ *
+ * @return Plot area manager
+ */
+ @Nonnull public PlotAreaManager getPlotAreaManager() {
+ return this.platform.getInjector().getInstance(PlotAreaManager.class);
}
/**
@@ -373,19 +242,24 @@ public class PlotSquared {
return PlotSquared.instance;
}
- @NotNull public static IPlotMain> imp() {
- if (instance != null && instance.IMP != null) {
- return instance.IMP;
+ /**
+ * Get the platform specific implementation of PlotSquared
+ *
+ * @return Platform implementation
+ */
+ @Nonnull public static PlotPlatform> platform() {
+ if (instance != null && instance.platform != null) {
+ return instance.platform;
}
- throw new IllegalStateException("Plot main implementation is missing");
+ throw new IllegalStateException("Plot platform implementation is missing");
}
- private void startExpiryTasks() {
+ public void startExpiryTasks() {
if (Settings.Enabled_Components.PLOT_EXPIRY) {
- ExpireManager.IMP = new ExpireManager();
+ ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
ExpireManager.IMP.runAutomatedTask();
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
- ExpiryTask task = new ExpiryTask(settings);
+ ExpiryTask task = new ExpiryTask(settings, this.getPlotAreaManager());
ExpireManager.IMP.addTask(task);
}
}
@@ -427,15 +301,6 @@ public class PlotSquared {
return Settings.PLATFORM;
}
- public PlotManager getPlotManager(Plot plot) {
- return plot.getArea().getPlotManager();
- }
-
- public PlotManager getPlotManager(Location location) {
- PlotArea pa = getPlotAreaAbs(location);
- return pa != null ? pa.getPlotManager() : null;
- }
-
/**
* Add a global reference to a plot world.
*
@@ -465,10 +330,10 @@ public class PlotSquared {
}
}
Set 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 iterator = clusters.iterator();
@@ -486,13 +351,13 @@ public class PlotSquared {
cluster.setArea(plotArea);
}
}
- plotAreaManager.addPlotArea(plotArea);
+ getPlotAreaManager().addPlotArea(plotArea);
plotArea.setupBorder();
if (!Settings.Enabled_Components.PERSISTENT_ROAD_REGEN) {
return;
}
File file = new File(
- this.IMP.getDirectory() + File.separator + "persistent_regen_data_" + plotArea.getId()
+ this.platform.getDirectory() + File.separator + "persistent_regen_data_" + plotArea.getId()
+ "_" + plotArea.getWorldName());
if (!file.exists()) {
return;
@@ -511,7 +376,7 @@ public class PlotSquared {
logger.info("[P2] - Regions: {}", regions.size());
logger.info("[P2] - Chunks: {}", chunks.size());
HybridUtils.UPDATE = true;
- HybridUtils.manager.scheduleRoadUpdate(plotArea, regions, height, chunks);
+ PlotSquared.platform().getHybridUtils().scheduleRoadUpdate(plotArea, regions, height, chunks);
} catch (IOException | ClassNotFoundException e) {
logger.error("[P2] Error restarting road regeneration", e);
} finally {
@@ -528,12 +393,12 @@ public class PlotSquared {
* @param area the {@code PlotArea} to remove
*/
public void removePlotArea(PlotArea area) {
- plotAreaManager.removePlotArea(area);
+ getPlotAreaManager().removePlotArea(area);
setPlotsTmp(area);
}
- public void removePlotAreas(String world) {
- for (PlotArea area : getPlotAreas(world)) {
+ public void removePlotAreas(@Nonnull final String world) {
+ for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) {
if (area.getWorldName().equals(world)) {
removePlotArea(area);
}
@@ -549,15 +414,15 @@ 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 getClusters(String world) {
- Set set = new HashSet<>();
- for (PlotArea area : getPlotAreas(world)) {
+ public Set getClusters(@Nonnull final String world) {
+ final Set set = new HashSet<>();
+ for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) {
set.addAll(area.getClusters());
}
return Collections.unmodifiableSet(set);
@@ -764,13 +629,13 @@ public class PlotSquared {
// group by world
// sort each
HashMap> map = new HashMap<>();
- int totalSize = getPlotCount();
+ int totalSize = Arrays.stream(this.getPlotAreaManager().getAllPlotAreas()).mapToInt(PlotArea::getPlotCount).sum();
if (plots.size() == totalSize) {
- for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
+ for (PlotArea area : getPlotAreaManager().getAllPlotAreas()) {
map.put(area, area.getPlots());
}
} else {
- for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
+ for (PlotArea area : getPlotAreaManager().getAllPlotAreas()) {
map.put(area, new ArrayList<>(0));
}
Collection lastList = null;
@@ -785,7 +650,7 @@ public class PlotSquared {
}
}
}
- List areas = Arrays.asList(plotAreaManager.getAllPlotAreas());
+ List areas = Arrays.asList(getPlotAreaManager().getAllPlotAreas());
areas.sort((a, b) -> {
if (priorityArea != null) {
if (a.equals(priorityArea)) {
@@ -818,199 +683,25 @@ public class PlotSquared {
return toReturn;
}
- /**
- * A more generic way to filter plots - make your own method
- * if you need complex filters.
- *
- * @param filters the filter
- * @return a filtered set of plots
- * @deprecated Use {@link PlotQuery}
- */
- @Deprecated public Set getPlots(final PlotFilter... filters) {
- final List areas = new LinkedList<>();
- for (final PlotArea plotArea : this.getPlotAreas()) {
- for (final PlotFilter filter : filters) {
- if (filter.allowsArea(plotArea)) {
- areas.add(plotArea);
- }
- }
- }
- return PlotQuery.newQuery().inAreas(areas).thatPasses(plot -> {
- for (final PlotFilter filter : filters) {
- if (!filter.allowsPlot(plot)) {
- return false;
- }
- }
- return true;
- }).asSet();
- }
-
- /**
- * Gets all the plots across all plotworlds in one {@code Set}.
- *
- * @return all the plots on the server loaded by this plugin
- */
- public Set getPlots() {
- int size = getPlotCount();
- final Set result = new HashSet<>(size);
- forEachPlotArea(value -> result.addAll(value.getPlots()));
- return result;
- }
-
- public void setPlots(HashMap> plots) {
+ public void setPlots(@Nonnull final Map> plots) {
if (this.plots_tmp == null) {
this.plots_tmp = new HashMap<>();
}
- for (Entry> entry : plots.entrySet()) {
- String world = entry.getKey();
- PlotArea area = getPlotArea(world, null);
- if (area == null) {
- HashMap map =
- this.plots_tmp.computeIfAbsent(world, k -> new HashMap<>());
+ for (final Entry> entry : plots.entrySet()) {
+ final String world = entry.getKey();
+ final PlotArea plotArea = this.getPlotAreaManager().getPlotArea(world, null);
+ if (plotArea == null) {
+ Map map = this.plots_tmp.computeIfAbsent(world, k -> new HashMap<>());
map.putAll(entry.getValue());
} else {
for (Plot plot : entry.getValue().values()) {
- plot.setArea(area);
- area.addPlot(plot);
+ plot.setArea(plotArea);
+ plotArea.addPlot(plot);
}
}
}
}
- /**
- * Gets all the plots owned by a player name.
- *
- * @param world the world
- * @param player the plot owner
- * @return Set of Plot
- */
- public Set getPlots(String world, String player) {
- final UUID uuid = this.impromptuUUIDPipeline.getSingle(player, Settings.UUID.BLOCKING_TIMEOUT);
- return getPlots(world, uuid);
- }
-
- /**
- * Gets all the plots owned by a player name.
- *
- * @param area the PlotArea
- * @param player the plot owner
- * @return Set of Plot
- */
- public Set getPlots(PlotArea area, String player) {
- final UUID uuid = this.impromptuUUIDPipeline.getSingle(player, Settings.UUID.BLOCKING_TIMEOUT);
- return getPlots(area, uuid);
- }
-
- /**
- * Gets all plots by a PlotPlayer.
- *
- * @param world the world
- * @param player the plot owner
- * @return Set of plot
- */
- public Set getPlots(String world, PlotPlayer player) {
- return PlotQuery.newQuery().inWorld(world).ownedBy(player).asSet();
- }
-
- /**
- * Gets all plots by a PlotPlayer.
- *
- * @param area the PlotArea
- * @param player the plot owner
- * @return Set of plot
- */
- public Set getPlots(PlotArea area, PlotPlayer player) {
- return PlotQuery.newQuery().inArea(area).ownedBy(player).asSet();
- }
-
- /**
- * Gets all plots by a UUID in a world.
- *
- * @param world the world
- * @param uuid the plot owner
- * @return Set of plot
- */
- public Set getPlots(String world, UUID uuid) {
- return PlotQuery.newQuery().inWorld(world).ownedBy(uuid).asSet();
- }
-
- /**
- * Gets all plots by a UUID in an area.
- *
- * @param area the {@code PlotArea}
- * @param uuid the plot owner
- * @return Set of plots
- */
- public Set getPlots(PlotArea area, UUID uuid) {
- return PlotQuery.newQuery().inArea(area).ownedBy(uuid).asSet();
- }
-
- /**
- * Check if a plot world.
- *
- * @param world the world
- * @return if a plot world is registered
- * @see #getPlotAreaByString(String) to get the PlotArea object
- */
- public boolean hasPlotArea(String world) {
- return plotAreaManager.getPlotAreas(world, null).length != 0;
- }
-
- public Collection getPlots(String world) {
- return PlotQuery.newQuery().inWorld(world).asCollection();
- }
-
- /**
- * Gets the plots for a PlotPlayer.
- *
- * @param player the player to retrieve the plots for
- * @return Set of Plot
- */
- public Set getPlots(PlotPlayer player) {
- return PlotQuery.newQuery().ownedBy(player).asSet();
- }
-
- public Collection getPlots(PlotArea area) {
- return area == null ? EMPTY_SET : area.getPlots();
- }
-
- public Plot getPlot(PlotArea area, PlotId id) {
- return area == null ? null : id == null ? null : area.getPlot(id);
- }
-
- public Set getBasePlots(PlotPlayer player) {
- return getBasePlots(player.getUUID());
- }
-
- /**
- * Gets the plots for a UUID.
- *
- * @param uuid the plot owner
- * @return Set of Plot's owned by the player
- */
- public Set getPlots(final UUID uuid) {
- return PlotQuery.newQuery().ownedBy(uuid).asSet();
- }
-
- public boolean hasPlot(final UUID uuid) {
- return Arrays.stream(plotAreaManager.getAllPlotAreas())
- .anyMatch(area -> area.hasPlot(uuid));
- }
-
- public Set getBasePlots(final UUID uuid) {
- return PlotQuery.newQuery().ownedBy(uuid).whereBasePlot().asSet();
- }
-
- /**
- * Gets the plots for a UUID.
- *
- * @param uuid the UUID of the owner
- * @return Set of Plot
- */
- public Set getPlotsAbs(final UUID uuid) {
- return PlotQuery.newQuery().ownedBy(uuid).asSet();
- }
-
/**
* Unregisters a plot from local memory without calling the database.
*
@@ -1059,15 +750,15 @@ public class PlotSquared {
if (world.equals("CheckingPlotSquaredGenerator")) {
return;
}
- this.plotAreaManager.addWorld(world);
+ this.getPlotAreaManager().addWorld(world);
Set 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);
@@ -1075,7 +766,7 @@ public class PlotSquared {
type = PlotAreaType.NORMAL;
}
if (type == PlotAreaType.NORMAL) {
- if (plotAreaManager.getPlotAreas(world, null).length != 0) {
+ if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
return;
}
IndependentPlotGenerator plotGenerator;
@@ -1084,13 +775,13 @@ public class PlotSquared {
} else if (worldSection != null) {
String secondaryGeneratorName = worldSection.getString("generator.plugin");
GeneratorWrapper> secondaryGenerator =
- this.IMP.getGenerator(world, secondaryGeneratorName);
+ this.platform.getGenerator(world, secondaryGeneratorName);
if (secondaryGenerator != null && secondaryGenerator.isFull()) {
plotGenerator = secondaryGenerator.getPlotGenerator();
} else {
String primaryGeneratorName = worldSection.getString("generator.init");
GeneratorWrapper> primaryGenerator =
- this.IMP.getGenerator(world, primaryGeneratorName);
+ this.platform.getGenerator(world, primaryGeneratorName);
if (primaryGenerator != null && primaryGenerator.isFull()) {
plotGenerator = primaryGenerator.getPlotGenerator();
} else {
@@ -1107,14 +798,14 @@ public class PlotSquared {
logger.info("[P2] - generator: {}>{}", baseGenerator, plotGenerator);
logger.info("[P2] - plot world: {}", plotArea.getClass().getCanonicalName());
logger.info("[P2] - plot area manager: {}", plotManager.getClass().getCanonicalName());
- 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();
}
@@ -1127,14 +818,14 @@ public class PlotSquared {
}
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
if (areasSection == null) {
- if (plotAreaManager.getPlotAreas(world, null).length != 0) {
+ if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
return;
}
logger.info("[P2] Detected world load for '{}'", world);
- String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
+ String gen_string = worldSection.getString("generator.plugin", platform.getPluginName());
if (type == PlotAreaType.PARTIAL) {
Set 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);
}
@@ -1147,7 +838,7 @@ public class PlotSquared {
worldSection.createSection("areas." + fullId);
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
logger.info("[P2] - {}-{}-{}", name, pos1, pos2);
- GeneratorWrapper> areaGen = this.IMP.getGenerator(world, gen_string);
+ GeneratorWrapper> areaGen = this.platform.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
}
@@ -1156,7 +847,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();
}
@@ -1173,7 +864,7 @@ public class PlotSquared {
}
return;
}
- GeneratorWrapper> areaGen = this.IMP.getGenerator(world, gen_string);
+ GeneratorWrapper> areaGen = this.platform.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
}
@@ -1181,7 +872,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();
}
@@ -1212,7 +903,7 @@ public class PlotSquared {
throw new IllegalArgumentException("Invalid Area identifier: " + areaId
+ ". Expected form `--`");
}
- PlotArea existing = getPlotArea(world, name);
+ final PlotArea existing = this.getPlotAreaManager().getPlotArea(world, name);
if (existing != null && name.equals(existing.getId())) {
continue;
}
@@ -1234,8 +925,8 @@ public class PlotSquared {
clone.set(key, worldSection.get(key));
}
}
- String gen_string = clone.getString("generator.plugin", IMP.getPluginName());
- GeneratorWrapper> areaGen = this.IMP.getGenerator(world, gen_string);
+ String gen_string = clone.getString("generator.plugin", platform.getPluginName());
+ GeneratorWrapper> areaGen = this.platform.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
}
@@ -1257,7 +948,7 @@ public class PlotSquared {
}
pa.loadDefaultConfiguration(clone);
try {
- this.worlds.save(this.worldsFile);
+ this.worldConfiguration.save(this.worldsFile);
} catch (IOException e) {
e.printStackTrace();
}
@@ -1329,7 +1020,9 @@ public class PlotSquared {
split = combinedArgs;
}
- HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null);
+ final HybridPlotWorldFactory hybridPlotWorldFactory = this.platform.getInjector().getInstance(HybridPlotWorldFactory.class);
+ final HybridPlotWorld plotWorld = hybridPlotWorldFactory.create(world, null, generator, null, null);
+
for (String element : split) {
String[] pair = element.split("=");
if (pair.length != 2) {
@@ -1343,41 +1036,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:
@@ -1392,10 +1085,10 @@ public class PlotSquared {
}
try {
ConfigurationSection section =
- this.worlds.getConfigurationSection("worlds." + world);
- plotworld.saveConfiguration(section);
- plotworld.loadDefaultConfiguration(section);
- this.worlds.save(this.worldsFile);
+ this.worldConfiguration.getConfigurationSection("worlds." + world);
+ plotWorld.saveConfiguration(section);
+ plotWorld.loadDefaultConfiguration(section);
+ this.worldConfiguration.save(this.worldsFile);
} catch (IOException e) {
e.printStackTrace();
}
@@ -1403,17 +1096,6 @@ public class PlotSquared {
return true;
}
- public boolean canUpdate(@NonNull final String current, @NonNull final String other) {
- final String s1 = normalisedVersion(current);
- final String s2 = normalisedVersion(other);
- return s1.compareTo(s2) < 0;
- }
-
- public String normalisedVersion(@NonNull final String version) {
- final String[] split = Pattern.compile(".", Pattern.LITERAL).split(version);
- return Arrays.stream(split).map(s -> String.format("%4s", s)).collect(Collectors.joining());
- }
-
/**
* Copies a file from inside the jar to a location
*
@@ -1422,7 +1104,7 @@ public class PlotSquared {
*/
public void copyFile(String file, String folder) {
try {
- File output = this.IMP.getDirectory();
+ File output = this.platform.getDirectory();
if (!output.exists()) {
output.mkdirs();
}
@@ -1430,7 +1112,7 @@ public class PlotSquared {
if (newFile.exists()) {
return;
}
- try (InputStream stream = this.IMP.getClass().getResourceAsStream(file)) {
+ try (InputStream stream = this.platform.getClass().getResourceAsStream(file)) {
byte[] buffer = new byte[2048];
if (stream == null) {
try (ZipInputStream zis = new ZipInputStream(
@@ -1469,19 +1151,6 @@ public class PlotSquared {
}
}
- private Map> getPlotsRaw() {
- HashMap> map = new HashMap<>();
- for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
- Map map2 = map.get(area.toString());
- if (map2 == null) {
- map.put(area.toString(), area.getPlotsMap());
- } else {
- map2.putAll(area.getPlotsMap());
- }
- }
- return map;
- }
-
/**
* Safely closes the database connection.
*/
@@ -1529,7 +1198,7 @@ public class PlotSquared {
list.add(chunks);
list.add(HybridUtils.height);
File file = new File(
- this.IMP.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
+ this.platform.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
.getId() + "_" + HybridUtils.area.getWorldName());
if (file.exists() && !file.delete()) {
logger.error("[P2] persistent_regene_data file already exists and could not be deleted");
@@ -1556,34 +1225,34 @@ public class PlotSquared {
database = new MySQL(Storage.MySQL.HOST, Storage.MySQL.PORT, Storage.MySQL.DATABASE,
Storage.MySQL.USER, Storage.MySQL.PASSWORD);
} else if (Storage.SQLite.USE) {
- File file = MainUtil.getFile(IMP.getDirectory(), Storage.SQLite.DB + ".db");
+ File file = MainUtil.getFile(platform.getDirectory(), Storage.SQLite.DB + ".db");
database = new SQLite(file);
} else {
logger.error("[P2] No storage type is set. Disabling PlotSquared");
- this.IMP.shutdown(); //shutdown used instead of disable because no database is set
+ this.platform.shutdown(); //shutdown used instead of disable because no database is set
return;
}
- DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
+ 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();
+ if (getPlotAreaManager() instanceof SinglePlotAreaManager) {
+ SinglePlotArea area = ((SinglePlotAreaManager) getPlotAreaManager()).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) {
logger.error("[P2] Failed to open database connection ({}). Disabling PlotSquared", Storage.MySQL.USE ? "MySQL" : "SQLite");
logger.error("[P2] ==== Here is an ugly stacktrace, if you are interested in those things ===");
e.printStackTrace();
logger.error("[P2] &d==== End of stacktrace ====");
logger.error("[P2] &6Please go to the {} 'storage.yml' and configure the database correctly",
- imp().getPluginName());
- this.IMP.shutdown(); //shutdown used instead of disable because of database error
+ platform.getPluginName());
+ this.platform.shutdown(); //shutdown used instead of disable because of database error
}
}
@@ -1603,9 +1272,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) {
logger.error("[P2] Failed to save worlds.yml", e);
e.printStackTrace();
@@ -1638,7 +1307,7 @@ public class PlotSquared {
* - Translation: PlotSquared.use_THIS.yml, style.yml
*/
public boolean setupConfigs() {
- File folder = new File(this.IMP.getDirectory(), "config");
+ File folder = new File(this.platform.getDirectory(), "config");
if (!folder.exists() && !folder.mkdirs()) {
logger.error("[P2] Failed to create the /plugins/config folder. Please create it manually");
}
@@ -1647,12 +1316,12 @@ public class PlotSquared {
if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) {
logger.error("[P2] 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
logger.info(Captions.LEGACY_CONFIG_FOUND.getTranslated());
@@ -1661,21 +1330,21 @@ public class PlotSquared {
.copy(this.worldsFile, new File(folder, "worlds.yml.old"));
logger.info(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);
logger.info(Captions.LEGACY_CONFIG_DONE.getTranslated());
} catch (final Exception e) {
logger.error(Captions.LEGACY_CONFIG_CONVERSION_FAILED.getTranslated(), e);
}
// Disable plugin
- this.IMP.shutdown();
+ this.platform.shutdown();
return false;
}
} else {
- this.worlds.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
+ this.worldConfiguration.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
}
} catch (IOException ignored) {
logger.error("[P2] Failed to save worlds.yml");
@@ -1691,17 +1360,18 @@ public class PlotSquared {
logger.error("[P2] Failed to save settings.yml");
}
try {
- this.styleFile = MainUtil.getFile(IMP.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()) {
logger.error("[P2] Failed to create the style file. Please create 'translations/style.yml' manually");
}
}
- this.style = YamlConfiguration.loadConfiguration(this.styleFile);
+ this.style = YamlConfiguration.loadConfiguration(styleFile);
setupStyle();
} catch (IOException ignored) {
logger.error("[P2] Failed to save style.yml");
@@ -1711,27 +1381,22 @@ public class PlotSquared {
if (!this.storageFile.exists() && !this.storageFile.createNewFile()) {
logger.error("[P2] Could not create the storage settings file. Please create 'storage.yml' manually");
}
- this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
+ YamlConfiguration.loadConfiguration(this.storageFile);
setupStorage();
} catch (IOException ignored) {
logger.error("[P2] Failed to save storage.yml");
}
- try {
- this.style.save(this.styleFile);
- } catch (IOException e) {
- logger.error("[P2] Configuration file saving failed", e);
- }
return true;
}
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);
}
/**
@@ -1740,7 +1405,7 @@ public class PlotSquared {
private void setupStorage() {
Storage.load(storageFile);
Storage.save(storageFile);
- storage = YamlConfiguration.loadConfiguration(storageFile);
+ YamlConfiguration.loadConfiguration(storageFile);
}
/**
@@ -1793,39 +1458,8 @@ public class PlotSquared {
}
}
- /**
- * Gets the Java version.
- *
- * @return the java version
- */
- private double getJavaVersion() {
- return Double.parseDouble(System.getProperty("java.specification.version"));
- }
-
- public void forEachPlotArea(Consumer super PlotArea> action) {
- for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
- action.accept(area);
- }
- }
-
- public void forEachPlotArea(@NonNull final String world, Consumer consumer) {
- final PlotArea[] array = this.plotAreaManager.getPlotAreas(world, null);
- if (array == null) {
- return;
- }
- for (final PlotArea area : array) {
- consumer.accept(area);
- }
- }
-
- public void forEachPlot(Consumer consumer) {
- for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
- area.getPlots().forEach(consumer);
- }
- }
-
public void forEachPlotRaw(Consumer consumer) {
- for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
+ for (final PlotArea area : this.getPlotAreaManager().getAllPlotAreas()) {
area.getPlots().forEach(consumer);
}
if (this.plots_tmp != null) {
@@ -1835,32 +1469,6 @@ public class PlotSquared {
}
}
- public void forEachBasePlot(Consumer consumer) {
- for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
- area.forEachBasePlot(consumer);
- }
- }
-
- public PlotArea getFirstPlotArea() {
- PlotArea[] areas = plotAreaManager.getAllPlotAreas();
- return areas.length > 0 ? areas[0] : null;
- }
-
- public int getPlotAreaCount() {
- return this.plotAreaManager.getAllPlotAreas().length;
- }
-
- public int getPlotCount() {
- return Arrays.stream(this.plotAreaManager.getAllPlotAreas())
- .mapToInt(PlotArea::getPlotCount).sum();
- }
-
- public Set getPlotAreas() {
- final Set set = new HashSet<>();
- Collections.addAll(set, plotAreaManager.getAllPlotAreas());
- return Collections.unmodifiableSet(set);
- }
-
/**
* Check if the chunk uses vanilla/non-PlotSquared generation
*
@@ -1868,115 +1476,16 @@ public class PlotSquared {
* @param chunkCoordinates Chunk coordinates
* @return True if the chunk uses non-standard generation, false if not
*/
- public boolean isNonStandardGeneration(@NotNull final String world,
- @NotNull final BlockVector2 chunkCoordinates) {
- final Location location = new Location(world, chunkCoordinates.getBlockX() << 4, 64, chunkCoordinates.getBlockZ() << 4);
- final PlotArea area = plotAreaManager.getApplicablePlotArea(location);
+ public boolean isNonStandardGeneration(@Nonnull final String world,
+ @Nonnull final BlockVector2 chunkCoordinates) {
+ final Location location = Location.at(world, chunkCoordinates.getBlockX() << 4, 64, chunkCoordinates.getBlockZ() << 4);
+ final PlotArea area = getPlotAreaManager().getApplicablePlotArea(location);
if (area == null) {
return true;
}
return area.getTerrain() != PlotAreaTerrainType.NONE;
}
- public boolean isAugmented(@NonNull final String world) {
- final PlotArea[] areas = plotAreaManager.getPlotAreas(world, null);
- return areas != null && (areas.length > 1 || areas[0].getType() != PlotAreaType.NORMAL);
- }
-
- /**
- * Gets a list of PlotArea objects.
- *
- * @param world the world
- * @return Collection of PlotArea objects
- */
- public Set getPlotAreas(@NonNull final String world) {
- final Set set = new HashSet<>();
- Collections.addAll(set, plotAreaManager.getPlotAreas(world, null));
- return set;
- }
-
- /**
- * Gets the relevant plot area for a specified location.
- *
- *
If there is only one plot area globally that will be returned.
- *
If there is only one plot area in the world, it will return that.
- *
If the plot area for a location cannot be unambiguously
- * resolved, null will be returned.
- *
- * Note: An applicable plot area may not include the location i.e. clusters
- *
- * @param location the location
- * @return
- */
- public PlotArea getApplicablePlotArea(@NonNull final Location location) {
- return plotAreaManager.getApplicablePlotArea(location);
- }
-
- public PlotArea getPlotArea(@NonNull final String world, final String id) {
- return plotAreaManager.getPlotArea(world, id);
- }
-
- /**
- * Gets the {@code PlotArea} which contains a location.
- *
- *
If the plot area does not contain a location, null
- * will be returned.
- *
- *
- * @param location the location
- * @return the {@link PlotArea} in the location, null if non existent
- */
- public PlotArea getPlotAreaAbs(@NonNull final Location location) {
- return plotAreaManager.getPlotArea(location);
- }
-
- public PlotArea getPlotAreaByString(@NonNull final String search) {
- String[] split = search.split("[;,]");
- PlotArea[] areas = plotAreaManager.getPlotAreas(split[0], null);
- if (areas == null) {
- for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
- if (area.getWorldName().equalsIgnoreCase(split[0])) {
- if (area.getId() == null || split.length == 2 && area.getId()
- .equalsIgnoreCase(split[1])) {
- return area;
- }
- }
- }
- return null;
- }
- if (areas.length == 1) {
- return areas[0];
- } else if (split.length == 1) {
- return null;
- } else {
- for (PlotArea area : areas) {
- if (StringMan.isEqual(split[1], area.getId())) {
- return area;
- }
- }
- return null;
- }
- }
-
- /**
- * Gets Plots based on alias
- *
- * @param alias to search plots
- * @param worldname to filter alias to a specific world [optional] null means all worlds
- * @return Set<{@link Plot }> empty if nothing found
- */
- public Set getPlotsByAlias(@Nullable final String alias,
- @NonNull final String worldname) {
- return PlotQuery.newQuery().inWorld(worldname).withAlias(alias).asSet();
- }
-
- public Set getPlotAreas(final String world, final CuboidRegion region) {
- final PlotArea[] areas = plotAreaManager.getPlotAreas(world, region);
- final Set set = new HashSet<>();
- Collections.addAll(set, areas);
- return Collections.unmodifiableSet(set);
- }
-
public YamlConfiguration getConfig() {
return config;
}
diff --git a/Core/src/main/java/com/plotsquared/core/backup/Backup.java b/Core/src/main/java/com/plotsquared/core/backup/Backup.java
index a84fc497f..111edd8a7 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/Backup.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/Backup.java
@@ -28,7 +28,7 @@ package com.plotsquared.core.backup;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nullable;
import java.io.IOException;
import java.nio.file.Files;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java
index 4ba4a44f4..5ae0dcdfe 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java
@@ -28,8 +28,8 @@ package com.plotsquared.core.backup;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.Objects;
@@ -45,8 +45,8 @@ public interface BackupManager {
* @param plot Plot to perform the automatic backup on
* @param whenDone Action that runs when the automatic backup has been completed
*/
- static void backup(@Nullable PlotPlayer player, @NotNull final Plot plot, @NotNull Runnable whenDone) {
- Objects.requireNonNull(PlotSquared.imp()).getBackupManager().automaticBackup(player, plot, whenDone);
+ static void backup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone) {
+ Objects.requireNonNull(PlotSquared.platform()).getBackupManager().automaticBackup(player, plot, whenDone);
}
/**
@@ -56,7 +56,7 @@ public interface BackupManager {
* @param plot Plot to get the backup profile for
* @return Backup profile
*/
- @NotNull BackupProfile getProfile(@NotNull final Plot plot);
+ @Nonnull BackupProfile getProfile(@Nonnull final Plot plot);
/**
* This will perform an automatic backup of the plot iff the plot has an owner,
@@ -67,14 +67,14 @@ public interface BackupManager {
* @param plot Plot to perform the automatic backup on
* @param whenDone Action that runs when the automatic backup has been completed
*/
- void automaticBackup(@Nullable PlotPlayer player, @NotNull final Plot plot, @NotNull Runnable whenDone);
+ void automaticBackup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone);
/**
* Get the directory in which backups are stored
*
* @return Backup directory path
*/
- @NotNull Path getBackupPath();
+ @Nonnull Path getBackupPath();
/**
* Get the maximum amount of backups that may be stored for
diff --git a/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java
index 6664246e4..1a9dc7baa 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java
@@ -25,7 +25,7 @@
*/
package com.plotsquared.core.backup;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.List;
@@ -38,7 +38,7 @@ public interface BackupProfile {
*
* @return Future that will be completed with available backups
*/
- @NotNull CompletableFuture> listBackups();
+ @Nonnull CompletableFuture> listBackups();
/**
* Remove all backups stored for this profile
@@ -51,7 +51,7 @@ public interface BackupProfile {
*
* @return Folder that contains the backups for this profile
*/
- @NotNull Path getBackupDirectory();
+ @Nonnull Path getBackupDirectory();
/**
* Create a backup of the plot. If the profile is at the
@@ -59,7 +59,7 @@ public interface BackupProfile {
*
* @return Future that completes with the created backup.
*/
- @NotNull CompletableFuture createBackup();
+ @Nonnull CompletableFuture createBackup();
/**
* Restore a backup
@@ -67,6 +67,6 @@ public interface BackupProfile {
* @param backup Backup to restore
* @return Future that completes when the backup has finished
*/
- @NotNull CompletableFuture restoreBackup(@NotNull final Backup backup);
+ @Nonnull CompletableFuture restoreBackup(@Nonnull final Backup backup);
}
diff --git a/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java
index 2d8c04a76..c83a36c24 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java
@@ -25,11 +25,12 @@
*/
package com.plotsquared.core.backup;
+import com.google.inject.Singleton;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.Objects;
@@ -37,19 +38,19 @@ import java.util.Objects;
/**
* {@inheritDoc}
*/
-public class NullBackupManager implements BackupManager {
+@Singleton public class NullBackupManager implements BackupManager {
- @Override @NotNull public BackupProfile getProfile(@NotNull Plot plot) {
+ @Override @Nonnull public BackupProfile getProfile(@Nonnull Plot plot) {
return new NullBackupProfile();
}
@Override public void automaticBackup(@Nullable PlotPlayer plotPlayer,
- @NotNull Plot plot, @NotNull Runnable whenDone) {
+ @Nonnull Plot plot, @Nonnull Runnable whenDone) {
whenDone.run();
}
- @Override @NotNull public Path getBackupPath() {
- return Objects.requireNonNull(PlotSquared.imp()).getDirectory().toPath();
+ @Override @Nonnull public Path getBackupPath() {
+ return Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath();
}
@Override public int getBackupLimit() {
diff --git a/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java
index 39c833579..b16a589fc 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java
@@ -25,7 +25,7 @@
*/
package com.plotsquared.core.backup;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.io.File;
import java.nio.file.Path;
@@ -39,22 +39,22 @@ import java.util.concurrent.CompletableFuture;
*/
public class NullBackupProfile implements BackupProfile {
- @Override @NotNull public CompletableFuture> listBackups() {
+ @Override @Nonnull public CompletableFuture> listBackups() {
return CompletableFuture.completedFuture(Collections.emptyList());
}
@Override public void destroy(){
}
- @Override @NotNull public Path getBackupDirectory() {
+ @Override @Nonnull public Path getBackupDirectory() {
return new File(".").toPath();
}
- @Override @NotNull public CompletableFuture createBackup() {
+ @Override @Nonnull public CompletableFuture createBackup() {
throw new UnsupportedOperationException("Cannot create backup of an unowned plot");
}
- @Override @NotNull public CompletableFuture restoreBackup(@NotNull final Backup backup) {
+ @Override @Nonnull public CompletableFuture restoreBackup(@Nonnull final Backup backup) {
return CompletableFuture.completedFuture(null);
}
diff --git a/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java
index c71057ab5..e70ef4ac6 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java
@@ -25,14 +25,15 @@
*/
package com.plotsquared.core.backup;
+import com.google.inject.Inject;
+import com.google.inject.assistedinject.Assisted;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
-import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.file.Files;
@@ -51,22 +52,30 @@ import java.util.concurrent.CompletableFuture;
* plot, which is used to store and retrieve plot backups
* {@inheritDoc}
*/
-@RequiredArgsConstructor
public class PlayerBackupProfile implements BackupProfile {
private final UUID owner;
private final Plot plot;
private final BackupManager backupManager;
+ private final SchematicHandler schematicHandler;
+
+ @Inject public PlayerBackupProfile(@Assisted @Nonnull final UUID owner, @Assisted @Nonnull final Plot plot,
+ @Nonnull final BackupManager backupManager, @Nonnull final SchematicHandler schematicHandler) {
+ this.owner = owner;
+ this.plot = plot;
+ this.backupManager = backupManager;
+ this.schematicHandler = schematicHandler;
+ }
private volatile List backupCache;
private final Object backupLock = new Object();
- private static boolean isValidFile(@NotNull final Path path) {
+ private static boolean isValidFile(@Nonnull final Path path) {
final String name = path.getFileName().toString();
return name.endsWith(".schem") || name.endsWith(".schematic");
}
- @Override @NotNull public CompletableFuture> listBackups() {
+ @Override @Nonnull public CompletableFuture> listBackups() {
synchronized (this.backupLock) {
if (this.backupCache != null) {
return CompletableFuture.completedFuture(backupCache);
@@ -112,12 +121,12 @@ public class PlayerBackupProfile implements BackupProfile {
});
}
- @NotNull public Path getBackupDirectory() {
+ @Nonnull public Path getBackupDirectory() {
return resolve(resolve(resolve(backupManager.getBackupPath(), Objects.requireNonNull(plot.getArea().toString(), "plot area id")),
Objects.requireNonNull(plot.getId().toDashSeparatedString(), "plot id")), Objects.requireNonNull(owner.toString(), "owner"));
}
- private static Path resolve(@NotNull final Path parent, final String child) {
+ private static Path resolve(@Nonnull final Path parent, final String child) {
Path path = parent;
try {
if (!Files.exists(parent)) {
@@ -133,7 +142,7 @@ public class PlayerBackupProfile implements BackupProfile {
return path;
}
- @Override @NotNull public CompletableFuture createBackup() {
+ @Override @Nonnull public CompletableFuture createBackup() {
final CompletableFuture future = new CompletableFuture<>();
this.listBackups().thenAcceptAsync(backups -> {
synchronized (this.backupLock) {
@@ -141,7 +150,7 @@ public class PlayerBackupProfile implements BackupProfile {
backups.get(backups.size() - 1).delete();
}
final List plots = Collections.singletonList(plot);
- final boolean result = SchematicHandler.manager.exportAll(plots, getBackupDirectory().toFile(),
+ final boolean result = this.schematicHandler.exportAll(plots, getBackupDirectory().toFile(),
"%world%-%id%-" + System.currentTimeMillis(), () ->
future.complete(new Backup(this, System.currentTimeMillis(), null)));
if (!result) {
@@ -153,7 +162,7 @@ public class PlayerBackupProfile implements BackupProfile {
return future;
}
- @Override @NotNull public CompletableFuture restoreBackup(@NotNull final Backup backup) {
+ @Override @Nonnull public CompletableFuture restoreBackup(@Nonnull final Backup backup) {
final CompletableFuture future = new CompletableFuture<>();
if (backup.getFile() == null || !Files.exists(backup.getFile())) {
future.completeExceptionally(new IllegalArgumentException("The specific backup does not exist"));
@@ -161,14 +170,14 @@ public class PlayerBackupProfile implements BackupProfile {
TaskManager.runTaskAsync(() -> {
Schematic schematic = null;
try {
- schematic = SchematicHandler.manager.getSchematic(backup.getFile().toFile());
+ schematic = this.schematicHandler.getSchematic(backup.getFile().toFile());
} catch (SchematicHandler.UnsupportedFormatException e) {
e.printStackTrace();
}
if (schematic == null) {
future.completeExceptionally(new IllegalArgumentException("The backup is non-existent or not in the correct format"));
} else {
- SchematicHandler.manager.paste(schematic, plot, 0, 1, 0, false, new RunnableVal() {
+ this.schematicHandler.paste(schematic, plot, 0, 1, 0, false, new RunnableVal() {
@Override public void run(Boolean value) {
if (value) {
future.complete(null);
diff --git a/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java
index 57cbea1d8..97bae8f1c 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java
@@ -27,17 +27,20 @@ package com.plotsquared.core.backup;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
+import com.plotsquared.core.inject.factory.PlayerBackupProfileFactory;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.TaskManager;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -48,16 +51,18 @@ import java.util.concurrent.TimeUnit;
/**
* {@inheritDoc}
*/
-@RequiredArgsConstructor public class SimpleBackupManager implements BackupManager {
+@RequiredArgsConstructor @Singleton public class SimpleBackupManager implements BackupManager {
@Getter private final Path backupPath;
private final boolean automaticBackup;
@Getter private final int backupLimit;
private final Cache backupProfileCache = CacheBuilder.newBuilder()
.expireAfterAccess(3, TimeUnit.MINUTES).build();
+ private final PlayerBackupProfileFactory playerBackupProfileFactory;
- public SimpleBackupManager() throws Exception {
- this.backupPath = Objects.requireNonNull(PlotSquared.imp()).getDirectory().toPath().resolve("backups");
+ @Inject public SimpleBackupManager(@Nonnull final PlayerBackupProfileFactory playerBackupProfileFactory) throws Exception {
+ this.playerBackupProfileFactory = playerBackupProfileFactory;
+ this.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups");
if (!Files.exists(backupPath)) {
Files.createDirectory(backupPath);
}
@@ -65,12 +70,12 @@ import java.util.concurrent.TimeUnit;
this.backupLimit = Settings.Backup.BACKUP_LIMIT;
}
- @Override @NotNull public BackupProfile getProfile(@NotNull final Plot plot) {
+ @Override @Nonnull public BackupProfile getProfile(@Nonnull final Plot plot) {
if (plot.hasOwner() && !plot.isMerged()) {
try {
- return backupProfileCache.get(new PlotCacheKey(plot), () -> new PlayerBackupProfile(plot.getOwnerAbs(), plot, this));
+ return backupProfileCache.get(new PlotCacheKey(plot), () -> this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot));
} catch (ExecutionException e) {
- final BackupProfile profile = new PlayerBackupProfile(plot.getOwnerAbs(), plot, this);
+ final BackupProfile profile = this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot);
this.backupProfileCache.put(new PlotCacheKey(plot), profile);
return profile;
}
@@ -78,7 +83,7 @@ import java.util.concurrent.TimeUnit;
return new NullBackupProfile();
}
- @Override public void automaticBackup(@Nullable PlotPlayer player, @NotNull final Plot plot, @NotNull Runnable whenDone) {
+ @Override public void automaticBackup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone) {
final BackupProfile profile;
if (!this.shouldAutomaticallyBackup() || (profile = getProfile(plot)) instanceof NullBackupProfile) {
whenDone.run();
diff --git a/Core/src/main/java/com/plotsquared/core/command/Add.java b/Core/src/main/java/com/plotsquared/core/command/Add.java
index 6d86f7532..b1843fffd 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Add.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Add.java
@@ -25,16 +25,18 @@
*/
package com.plotsquared.core.command;
-import com.plotsquared.core.PlotSquared;
+import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
+import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Collections;
@@ -51,8 +53,11 @@ import java.util.concurrent.TimeoutException;
requiredType = RequiredType.PLAYER)
public class Add extends Command {
- public Add() {
+ private final EventDispatcher eventDispatcher;
+
+ @Inject public Add(@Nonnull final EventDispatcher eventDispatcher) {
super(MainCommand.getInstance(), true);
+ this.eventDispatcher = eventDispatcher;
}
@Override
@@ -116,7 +121,7 @@ public class Add extends Command {
}
}
plot.addMember(uuid);
- PlotSquared.get().getEventDispatcher().callMember(player, plot, uuid, true);
+ this.eventDispatcher.callMember(player, plot, uuid, true);
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
}
}, null);
diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java
index 383076f0d..18f71b00f 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Area.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Area.java
@@ -25,13 +25,18 @@
*/
package com.plotsquared.core.command;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
+import com.plotsquared.core.inject.annotations.WorldConfig;
+import com.plotsquared.core.inject.annotations.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;
+import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer;
@@ -40,6 +45,7 @@ import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.message.PlotMessage;
+import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.setup.PlotAreaBuilder;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
@@ -65,11 +71,14 @@ 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 javax.annotation.Nonnull;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -83,6 +92,30 @@ import java.util.Set;
confirmation = true)
public class Area extends SubCommand {
+ private final PlotAreaManager plotAreaManager;
+ private final YamlConfiguration worldConfiguration;
+ private final File worldFile;
+ private final HybridPlotWorldFactory hybridPlotWorldFactory;
+ private final SetupUtils setupUtils;
+ private final WorldUtil worldUtil;
+ private final RegionManager regionManager;
+
+ @Inject public Area(@Nonnull final PlotAreaManager plotAreaManager,
+ @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
+ @WorldFile @Nonnull final File worldFile,
+ @Nonnull final HybridPlotWorldFactory hybridPlotWorldFactory,
+ @Nonnull final SetupUtils setupUtils,
+ @Nonnull final WorldUtil worldUtil,
+ @Nonnull final RegionManager regionManager) {
+ this.plotAreaManager = plotAreaManager;
+ this.worldConfiguration = worldConfiguration;
+ this.worldFile = worldFile;
+ this.hybridPlotWorldFactory = hybridPlotWorldFactory;
+ this.setupUtils = setupUtils;
+ this.worldUtil = worldUtil;
+ this.regionManager = regionManager;
+ }
+
@Override public boolean onCommand(final PlotPlayer> player, String[] args) {
if (args.length == 0) {
Captions.COMMAND_SYNTAX.send(player, getUsage());
@@ -102,7 +135,7 @@ public class Area extends SubCommand {
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NEEDS_NAME);
return false;
}
- final PlotArea existingArea = PlotSquared.get().getPlotArea(player.getLocation().getWorld(), args[1]);
+ final PlotArea existingArea = this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]);
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NAME_TAKEN);
return false;
@@ -124,7 +157,7 @@ public class Area extends SubCommand {
MainUtil.sendMessage(player, Captions.SINGLE_AREA_NOT_SQUARE);
return false;
}
- if (PlotSquared.get().getPlotAreaManager().getPlotAreas(
+ if (this.plotAreaManager.getPlotAreas(
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(), CuboidRegion.makeCuboid(playerSelectedRegion)).length != 0) {
MainUtil.sendMessage(player, Captions.SINGLE_AREA_OVERLAPPING);
}
@@ -137,8 +170,8 @@ public class Area extends SubCommand {
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ()));
// There's only one plot in the area...
final PlotId plotId = new PlotId(1, 1);
- final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorld(), args[1],
- Objects.requireNonNull(PlotSquared.imp()).getDefaultGenerator(), plotId, plotId);
+ final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory.create(player.getLocation().getWorldName(), args[1],
+ Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId);
// Plot size is the same as the region width
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
// We use a schematic generator
@@ -153,7 +186,7 @@ public class Area extends SubCommand {
hybridPlotWorld.PLOT_HEIGHT = hybridPlotWorld.ROAD_HEIGHT = hybridPlotWorld.WALL_HEIGHT = playerSelectionMin.getBlockY();
// No sign plz
hybridPlotWorld.setAllowSigns(false);
- final File parentFile = MainUtil.getFile(PlotSquared.imp().getDirectory(), "schematics" + File.separator +
+ final File parentFile = MainUtil.getFile(PlotSquared.platform().getDirectory(), "schematics" + File.separator +
"GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld.getWorldName() + File.separator +
hybridPlotWorld.getId());
if (!parentFile.exists() && !parentFile.mkdirs()) {
@@ -187,8 +220,8 @@ public class Area extends SubCommand {
// Now the schematic is saved, which is wonderful!
PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld)
- .plotManager(PlotSquared.imp().getPluginName())
- .generatorName(PlotSquared.imp().getPluginName())
+ .plotManager(PlotSquared.platform().getPluginName())
+ .generatorName(PlotSquared.platform().getPluginName())
.maximumId(plotId)
.minimumId(plotId);
Runnable singleRun = () -> {
@@ -198,15 +231,13 @@ 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)) {
+ final String world = this.setupUtils.setupWorld(singleBuilder);
+ if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null);
MainUtil.sendMessage(player, Captions.SINGLE_AREA_CREATED);
} else {
@@ -274,16 +305,16 @@ public class Area extends SubCommand {
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
- Set areas =
- PlotSquared.get().getPlotAreas(area.getWorldName(), region);
+ final Set areas = this.plotAreaManager
+ .getPlotAreasSet(area.getWorldName(), region);
if (!areas.isEmpty()) {
Captions.CLUSTER_INTERSECTION
.send(player, areas.iterator().next().toString());
return false;
}
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area)
- .plotManager(PlotSquared.imp().getPluginName())
- .generatorName(PlotSquared.imp().getPluginName())
+ .plotManager(PlotSquared.platform().getPluginName())
+ .generatorName(PlotSquared.platform().getPluginName())
.minimumId(new PlotId(1, 1))
.maximumId(new PlotId(numX, numZ));
final String path =
@@ -291,21 +322,19 @@ 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)) {
+ final String world = this.setupUtils.setupWorld(builder);
+ if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null);
Captions.SETUP_FINISHED.send(player);
- player.teleport(WorldUtil.IMP.getSpawn(world),
+ player.teleport(this.worldUtil.getSpawn(world),
TeleportCause.COMMAND);
if (area.getTerrain() != PlotAreaTerrainType.ALL) {
- RegionManager.largeRegionTask(world, region,
+ this.regionManager.largeRegionTask(world, region,
new RunnableVal() {
@Override public void run(BlockVector2 value) {
AugmentedUtils
@@ -336,16 +365,16 @@ public class Area extends SubCommand {
} else {
id = null;
}
- PlotAreaBuilder builder = new PlotAreaBuilder();
+ PlotAreaBuilder builder = PlotAreaBuilder.newBuilder();
builder.worldName(split[0]);
- final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id,
- PlotSquared.get().IMP.getDefaultGenerator(), null, null);
- PlotArea other = PlotSquared.get().getPlotArea(pa.getWorldName(), id);
+ final HybridPlotWorld pa = this.hybridPlotWorldFactory.create(builder.worldName(),
+ id, PlotSquared.platform().getDefaultGenerator(), null, null);
+ 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());
return false;
}
- Set areas = PlotSquared.get().getPlotAreas(pa.getWorldName());
+ Set areas = this.plotAreaManager.getPlotAreasSet(pa.getWorldName());
if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next();
pa.setType(area.getType());
@@ -415,25 +444,24 @@ public class Area extends SubCommand {
}
}
if (pa.getType() != PlotAreaType.PARTIAL) {
- if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
+ if (this.worldUtil.isWorld(pa.getWorldName())) {
Captions.SETUP_WORLD_TAKEN.send(player, pa.getWorldName());
return false;
}
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.imp().getPluginName());
- builder.generatorName(PlotSquared.imp().getPluginName());
- String world = SetupUtils.manager.setupWorld(builder);
- if (WorldUtil.IMP.isWorld(world)) {
+ builder.plotManager(PlotSquared.platform().getPluginName());
+ builder.generatorName(PlotSquared.platform().getPluginName());
+ String world = this.setupUtils.setupWorld(builder);
+ if (this.worldUtil.isWorld(world)) {
Captions.SETUP_FINISHED.send(player);
- player.teleport(WorldUtil.IMP.getSpawn(world),
+ player.teleport(this.worldUtil.getSpawn(world),
TeleportCause.COMMAND);
} else {
MainUtil.sendMessage(player,
@@ -441,7 +469,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();
}
@@ -459,16 +487,16 @@ public class Area extends SubCommand {
+ " create [world[:id]] [=]...");
return false;
}
- if (WorldUtil.IMP.isWorld(pa.getWorldName())) {
- if (!player.getLocation().getWorld().equals(pa.getWorldName())) {
- player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
+ if (this.worldUtil.isWorld(pa.getWorldName())) {
+ if (!player.getLocation().getWorldName().equals(pa.getWorldName())) {
+ player.teleport(this.worldUtil.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND);
}
} else {
builder.terrainType(PlotAreaTerrainType.NONE);
builder.plotAreaType(PlotAreaType.NORMAL);
- SetupUtils.manager.setupWorld(builder);
- player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()),
+ this.setupUtils.setupWorld(builder);
+ player.teleport(this.worldUtil.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND);
}
player.setMeta("area_create_area", pa);
@@ -490,7 +518,7 @@ public class Area extends SubCommand {
area = player.getApplicablePlotArea();
break;
case 2:
- area = PlotSquared.get().getPlotAreaByString(args[1]);
+ area = this.plotAreaManager.getPlotAreaByString(args[1]);
break;
default:
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
@@ -552,7 +580,7 @@ public class Area extends SubCommand {
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
return false;
}
- ArrayList areas = new ArrayList<>(PlotSquared.get().getPlotAreas());
+ final List areas = new ArrayList<>(Arrays.asList(this.plotAreaManager.getAllPlotAreas()));
paginate(player, areas, 8, page,
new RunnableVal3() {
@Override public void run(Integer i, PlotArea area, PlotMessage message) {
@@ -612,7 +640,7 @@ public class Area extends SubCommand {
"$4Stop the server and delete: " + area.getWorldName() + "/region");
return false;
}
- RegionManager.largeRegionTask(area.getWorldName(), area.getRegion(),
+ this.regionManager.largeRegionTask(area.getWorldName(), area.getRegion(),
new RunnableVal() {
@Override public void run(BlockVector2 value) {
AugmentedUtils
@@ -635,33 +663,30 @@ public class Area extends SubCommand {
Captions.COMMAND_SYNTAX.send(player, "/plot visit [area]");
return false;
}
- PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]);
+ PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) {
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
return false;
}
Location center;
if (area.getType() != PlotAreaType.PARTIAL) {
- center = WorldUtil.IMP.getSpawn(area.getWorldName());
+ center = this.worldUtil.getSpawn(area.getWorldName());
player.teleport(center, TeleportCause.COMMAND);
} else {
CuboidRegion region = area.getRegion();
- center = new Location(area.getWorldName(), region.getMinimumPoint().getX()
+ center = Location.at(area.getWorldName(), region.getMinimumPoint().getX()
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
- WorldUtil.IMP
- .getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y -> {
- center.setY(1 + y);
- player.teleport(center, TeleportCause.COMMAND);
- });
+ this.worldUtil.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y ->
+ player.teleport(center.withY(1 + y), TeleportCause.COMMAND));
}
return true;
case "delete":
case "remove":
MainUtil.sendMessage(player,
"$1World creation settings may be stored in multiple locations:"
- + "\n$3 - $2Bukkit bukkit.yml" + "\n$3 - $2" + PlotSquared.imp()
+ + "\n$3 - $2Bukkit bukkit.yml" + "\n$3 - $2" + PlotSquared.platform()
.getPluginName() + " settings.yml"
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
+ "\n$1Stop the server and delete it from these locations.");
diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java
index 4c75de3f8..e212d3e58 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Auto.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java
@@ -26,6 +26,7 @@
package com.plotsquared.core.command;
import com.google.common.primitives.Ints;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions;
@@ -40,14 +41,17 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId;
+import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EconHandler;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.AutoClaimFinishTask;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Set;
@@ -61,6 +65,18 @@ import java.util.Set;
usage = "/plot auto [length,width]")
public class Auto extends SubCommand {
+ private final PlotAreaManager plotAreaManager;
+ private final EventDispatcher eventDispatcher;
+ private final EconHandler econHandler;
+
+ @Inject public Auto(@Nonnull final PlotAreaManager plotAreaManager,
+ @Nonnull final EventDispatcher eventDispatcher,
+ @Nullable final EconHandler econHandler) {
+ this.plotAreaManager = plotAreaManager;
+ this.eventDispatcher = eventDispatcher;
+ this.econHandler = econHandler;
+ }
+
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
return id.getNextId(step);
}
@@ -136,7 +152,8 @@ public class Auto extends SubCommand {
player.setMeta(Auto.class.getName(), true);
autoClaimFromDatabase(player, area, start, new RunnableVal() {
@Override public void run(final Plot plot) {
- TaskManager.IMP.sync(new AutoClaimFinishTask(player, plot, area, schematic));
+ TaskManager.getImplementation().sync(new AutoClaimFinishTask(player, plot, area, schematic,
+ PlotSquared.get().getEventDispatcher()));
}
});
}
@@ -157,10 +174,9 @@ public class Auto extends SubCommand {
@Override public boolean onCommand(final PlotPlayer> player, String[] args) {
PlotArea plotarea = player.getApplicablePlotArea();
if (plotarea == null) {
- if (EconHandler.getEconHandler() != null) {
- for (PlotArea area : PlotSquared.get().getPlotAreaManager().getAllPlotAreas()) {
- if (EconHandler.getEconHandler()
- .hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
+ if (this.econHandler != null) {
+ for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
+ if (this.econHandler.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
if (plotarea != null) {
plotarea = null;
break;
@@ -169,8 +185,8 @@ public class Auto extends SubCommand {
}
}
}
- if (PlotSquared.get().getPlotAreaManager().getAllPlotAreas().length == 1) {
- plotarea = PlotSquared.get().getPlotAreaManager().getAllPlotAreas()[0];
+ if (this.plotAreaManager.getAllPlotAreas().length == 1) {
+ plotarea = this.plotAreaManager.getAllPlotAreas()[0];
}
if (plotarea == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
@@ -213,7 +229,7 @@ public class Auto extends SubCommand {
// return false;
}
}
- PlayerAutoPlotEvent event = PlotSquared.get().getEventDispatcher()
+ PlayerAutoPlotEvent event = this.eventDispatcher
.callAuto(player, plotarea, schematic, size_x, size_z);
if (event.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Auto claim");
@@ -253,18 +269,18 @@ public class Auto extends SubCommand {
return true;
}
}
- if (EconHandler.getEconHandler() != null && plotarea.useEconomy()) {
+ if (this.econHandler != null && plotarea.useEconomy()) {
Expression costExp = plotarea.getPrices().get("claim");
double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ?
player.getPlotCount() :
player.getPlotCount(plotarea.getWorldName())));
cost = (size_x * size_z) * cost;
if (cost > 0d) {
- if (!force && EconHandler.getEconHandler().getMoney(player) < cost) {
+ if (!force && this.econHandler.getMoney(player) < cost) {
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
return true;
}
- EconHandler.getEconHandler().withdrawMoney(player, cost);
+ this.econHandler.withdrawMoney(player, cost);
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
}
}
@@ -294,7 +310,7 @@ public class Auto extends SubCommand {
}
ArrayList plotIds = MainUtil.getPlotSelectionIds(start, end);
final PlotId pos1 = plotIds.get(0);
- final PlotAutoMergeEvent mergeEvent = PlotSquared.get().getEventDispatcher()
+ final PlotAutoMergeEvent mergeEvent = this.eventDispatcher
.callAutoMerge(plotarea.getPlotAbs(pos1), plotIds);
if (!force && mergeEvent.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Auto merge");
diff --git a/Core/src/main/java/com/plotsquared/core/command/Backup.java b/Core/src/main/java/com/plotsquared/core/command/Backup.java
index 944eaaf6b..4c16458c6 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Backup.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java
@@ -25,7 +25,8 @@
*/
package com.plotsquared.core.command;
-import com.plotsquared.core.PlotSquared;
+import com.google.inject.Inject;
+import com.plotsquared.core.backup.BackupManager;
import com.plotsquared.core.backup.BackupProfile;
import com.plotsquared.core.backup.NullBackupProfile;
import com.plotsquared.core.backup.PlayerBackupProfile;
@@ -35,6 +36,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
+import javax.annotation.Nonnull;
import java.nio.file.Files;
import java.time.Instant;
@@ -60,8 +62,11 @@ import java.util.stream.Stream;
permission = "plots.backup")
public final class Backup extends Command {
- public Backup() {
+ private final BackupManager backupManager;
+
+ @Inject public Backup(@Nonnull final BackupManager backupManager) {
super(MainCommand.getInstance(), true);
+ this.backupManager = backupManager;
}
private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
@@ -90,8 +95,7 @@ public final class Backup extends Command {
final Plot plot = player.getCurrentPlot();
if (plot != null) {
- final BackupProfile backupProfile =
- Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
+ final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof PlayerBackupProfile) {
final CompletableFuture> backupList =
backupProfile.listBackups();
@@ -135,8 +139,7 @@ public final class Backup extends Command {
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
} else {
- final BackupProfile backupProfile =
- Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
+ final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_OTHER.getTranslated());
@@ -175,8 +178,7 @@ public final class Backup extends Command {
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
} else {
- final BackupProfile backupProfile =
- Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
+ final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_OTHER.getTranslated());
@@ -237,8 +239,7 @@ public final class Backup extends Command {
sendMessage(player, Captions.NOT_A_NUMBER, args[0]);
return;
}
- final BackupProfile backupProfile =
- Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(plot);
+ final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_OTHER.getTranslated());
diff --git a/Core/src/main/java/com/plotsquared/core/command/Buy.java b/Core/src/main/java/com/plotsquared/core/command/Buy.java
index 337801385..f62f24bc2 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Buy.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java
@@ -25,6 +25,7 @@
*/
package com.plotsquared.core.command;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
@@ -34,10 +35,13 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.util.EconHandler;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
+import javax.annotation.Nullable;
+import javax.annotation.Nonnull;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@@ -49,8 +53,14 @@ import java.util.concurrent.CompletableFuture;
requiredType = RequiredType.NONE)
public class Buy extends Command {
- public Buy() {
+ private final EventDispatcher eventDispatcher;
+ private final EconHandler econHandler;
+
+ @Inject public Buy(@Nonnull final EventDispatcher eventDispatcher,
+ @Nullable final EconHandler econHandler) {
super(MainCommand.getInstance(), true);
+ this.eventDispatcher = eventDispatcher;
+ this.econHandler = econHandler;
}
@Override
@@ -58,7 +68,7 @@ public class Buy extends Command {
RunnableVal3 confirm,
final RunnableVal2 whenDone) {
- check(EconHandler.getEconHandler(), Captions.ECON_DISABLED);
+ check(this.econHandler, Captions.ECON_DISABLED);
final Plot plot;
if (args.length != 0) {
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
@@ -82,15 +92,14 @@ public class Buy extends Command {
confirm.run(this, () -> {
Captions.REMOVED_BALANCE.send(player, price);
- EconHandler.getEconHandler().depositMoney(PlotSquared.imp().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
+ this.econHandler.depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
- PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
+ PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
if (owner != null) {
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
}
PlotFlag, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
- PlotFlagRemoveEvent event =
- PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
+ PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plotFlag, plot);
if (event.getEventResult() != Result.DENY) {
plot.removeFlag(event.getFlag());
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Caps.java b/Core/src/main/java/com/plotsquared/core/command/Caps.java
index b56d33dc0..55efd2519 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Caps.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java
@@ -71,7 +71,7 @@ public class Caps extends SubCommand {
}
private > void sendFormatted(final Plot plot,
- final PlotPlayer player, final Class capFlag, final int[] countedEntities,
+ final PlotPlayer> player, final Class capFlag, final int[] countedEntities,
final String name, final int type) {
final int current = countedEntities[type];
final int max = plot.getFlag(capFlag);
diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java
index 2271eaa67..7b51ea6cf 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Claim.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java
@@ -26,6 +26,7 @@
package com.plotsquared.core.command;
import com.google.common.primitives.Ints;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions;
@@ -40,10 +41,13 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.EconHandler;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,18 +62,26 @@ public class Claim extends SubCommand {
private static final Logger logger = LoggerFactory.getLogger("P2/" + Claim.class.getSimpleName());
+ private final EventDispatcher eventDispatcher;
+ private final EconHandler econHandler;
+
+ @Inject public Claim(@Nonnull final EventDispatcher eventDispatcher,
+ @Nullable final EconHandler econHandler) {
+ this.eventDispatcher = eventDispatcher;
+ this.econHandler = econHandler;
+ }
+
@Override public boolean onCommand(final PlotPlayer> player, String[] args) {
String schematic = null;
if (args.length >= 1) {
schematic = args[0];
}
Location location = player.getLocation();
- final Plot plot = location.getPlotAbs();
+ Plot plot = location.getPlotAbs();
if (plot == null) {
return sendMessage(player, Captions.NOT_IN_PLOT);
}
- PlayerClaimPlotEvent event =
- PlotSquared.get().getEventDispatcher().callClaim(player, plot, schematic);
+ final PlayerClaimPlotEvent event = this.eventDispatcher.callClaim(player, plot, schematic);
schematic = event.getSchematic();
if (event.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Claim");
@@ -78,7 +90,7 @@ public class Claim extends SubCommand {
boolean force = event.getEventResult() == Result.FORCE;
int currentPlots = Settings.Limit.GLOBAL ?
player.getPlotCount() :
- player.getPlotCount(location.getWorld());
+ player.getPlotCount(location.getWorldName());
int grants = 0;
if (currentPlots >= player.getAllowedPlots() && !force) {
if (player.hasPersistentMeta("grantedPlots")) {
@@ -109,14 +121,14 @@ public class Claim extends SubCommand {
}
}
}
- if ((EconHandler.getEconHandler() != null) && area.useEconomy() && !force) {
+ if ((this.econHandler != null) && area.useEconomy() && !force) {
Expression costExr = area.getPrices().get("claim");
double cost = costExr.evaluate((double) currentPlots);
if (cost > 0d) {
- if (EconHandler.getEconHandler().getMoney(player) < cost) {
+ if (this.econHandler.getMoney(player) < cost) {
return sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
}
- EconHandler.getEconHandler().withdrawMoney(player, cost);
+ this.econHandler.withdrawMoney(player, cost);
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
}
}
@@ -134,7 +146,7 @@ public class Claim extends SubCommand {
}
plot.setOwnerAbs(player.getUUID());
final String finalSchematic = schematic;
- DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal
*/
- @NotNull @Override public ConfigurationNode[] getSettingNodes() {
+ @Nonnull @Override public ConfigurationNode[] getSettingNodes() {
return new ConfigurationNode[] {
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height",
ConfigurationUtil.INTEGER),
diff --git a/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java
index 8b753b170..108796e45 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java
@@ -25,16 +25,23 @@
*/
package com.plotsquared.core.generator;
+import com.plotsquared.core.configuration.file.YamlConfiguration;
+import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
-import org.jetbrains.annotations.NotNull;
+import com.plotsquared.core.queue.GlobalBlockQueue;
+import com.plotsquared.core.util.EconHandler;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
public abstract class GridPlotWorld extends PlotArea {
public short SIZE;
- public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
- PlotId min, PlotId max) {
- super(worldName, id, generator, min, max);
+ public GridPlotWorld(String worldName, String id, @Nonnull IndependentPlotGenerator generator,
+ PlotId min, PlotId max, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
+ @Nonnull final GlobalBlockQueue blockQueue,
+ @Nullable final EconHandler econHandler) {
+ super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java
index a4f955682..2560981ab 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java
@@ -26,8 +26,10 @@
package com.plotsquared.core.generator;
import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
+import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
@@ -36,12 +38,18 @@ 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 org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HybridGen extends IndependentPlotGenerator {
+ private final HybridPlotWorldFactory hybridPlotWorldFactory;
+
+ @Inject public HybridGen(@Nonnull final HybridPlotWorldFactory hybridPlotWorldFactory) {
+ this.hybridPlotWorldFactory = hybridPlotWorldFactory;
+ }
+
@Override public String getName() {
- return PlotSquared.imp().getPluginName();
+ return PlotSquared.platform().getPluginName();
}
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
@@ -68,7 +76,7 @@ public class HybridGen extends IndependentPlotGenerator {
}
@Override
- public void generateChunk(@NotNull ScopedLocalBlockQueue result, @NotNull PlotArea settings) {
+ public void generateChunk(@Nonnull ScopedLocalBlockQueue result, @Nonnull PlotArea settings) {
Preconditions.checkNotNull(result, "result cannot be null");
Preconditions.checkNotNull(settings, "settings cannot be null");
@@ -221,7 +229,7 @@ public class HybridGen extends IndependentPlotGenerator {
}
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
- return new HybridPlotWorld(world, id, this, min, max);
+ return this.hybridPlotWorldFactory.create(world, id, this, min, max);
}
@Override public void initialize(PlotArea area) {
diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java
index da4fa74b9..e7fd298a0 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java
@@ -34,7 +34,6 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId;
-import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.FileBytes;
@@ -48,6 +47,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.Getter;
+import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
@@ -59,10 +59,13 @@ public class HybridPlotManager extends ClassicPlotManager {
public static boolean REGENERATIVE_CLEAR = true;
@Getter private final HybridPlotWorld hybridPlotWorld;
+ private final RegionManager regionManager;
- public HybridPlotManager(HybridPlotWorld hybridPlotWorld) {
- super(hybridPlotWorld);
+ public HybridPlotManager(@Nonnull final HybridPlotWorld hybridPlotWorld,
+ @Nonnull final RegionManager regionManager) {
+ super(hybridPlotWorld, regionManager);
this.hybridPlotWorld = hybridPlotWorld;
+ this.regionManager = regionManager;
}
@Override public void exportTemplate() throws IOException {
@@ -74,7 +77,7 @@ public class HybridPlotManager extends ClassicPlotManager {
.getWorldName() + File.separator;
try {
File sideRoad =
- MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem");
+ MainUtil.getFile(PlotSquared.platform().getDirectory(), dir + "sideroad.schem");
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
+ "__TEMP_DIR__" + File.separator;
if (sideRoad.exists()) {
@@ -82,12 +85,12 @@ public class HybridPlotManager extends ClassicPlotManager {
Files.readAllBytes(sideRoad.toPath())));
}
File intersection =
- MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "intersection.schem");
+ MainUtil.getFile(PlotSquared.platform().getDirectory(), dir + "intersection.schem");
if (intersection.exists()) {
files.add(new FileBytes(newDir + "intersection.schem",
Files.readAllBytes(intersection.toPath())));
}
- File plot = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "plot.schem");
+ File plot = MainUtil.getFile(PlotSquared.platform().getDirectory(), dir + "plot.schem");
if (plot.exists()) {
files.add(new FileBytes(newDir + "plot.schem", Files.readAllBytes(plot.toPath())));
}
@@ -103,9 +106,8 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x + 1, id.y);
Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id);
- Location pos1 =
- new Location(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
- Location pos2 = new Location(hybridPlotWorld.getWorldName(), bot.getX(),
+ Location pos1 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
+ Location pos2 = Location.at(hybridPlotWorld.getWorldName(), bot.getX(),
Math.min(getWorldHeight(), 255), top.getZ() + 1);
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@@ -165,9 +167,8 @@ public class HybridPlotManager extends ClassicPlotManager {
PlotId id2 = new PlotId(id.x, id.y + 1);
Location bot = getPlotBottomLocAbs(id2);
Location top = getPlotTopLocAbs(id);
- Location pos1 =
- new Location(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
- Location pos2 = new Location(hybridPlotWorld.getWorldName(), top.getX() + 1,
+ Location pos1 = Location.at(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
+ Location pos2 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1,
Math.min(getWorldHeight(), 255), bot.getZ());
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@@ -183,10 +184,8 @@ public class HybridPlotManager extends ClassicPlotManager {
super.createRoadSouthEast(plot);
PlotId id = plot.getId();
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
- Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1);
- Location pos2 = getPlotBottomLocAbs(id2);
- pos1.setY(0);
- pos2.setY(Math.min(getWorldHeight(), 255));
+ Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
+ Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
createSchemAbs(queue, pos1, pos2, true);
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
@@ -203,9 +202,9 @@ public class HybridPlotManager extends ClassicPlotManager {
*
*/
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
- if (RegionManager.manager.notifyClear(this)) {
+ if (this.regionManager.notifyClear(this)) {
//If this returns false, the clear didn't work
- if (RegionManager.manager.handleClear(plot, whenDone, this)) {
+ if (this.regionManager.handleClear(plot, whenDone, this)) {
return true;
}
}
@@ -241,18 +240,18 @@ public class HybridPlotManager extends ClassicPlotManager {
// Set the biome
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
// These two locations are for each component (e.g. bedrock, main block, floor, air)
- Location bot = new Location(world, value[2], 0, value[3]);
- Location top = new Location(world, value[4], 1, value[5]);
+ Location bot = Location.at(world, value[2], 0, value[3]);
+ Location top = Location.at(world, value[4], 1, value[5]);
queue.setCuboid(bot, top, bedrock);
// Each component has a different layer
- bot.setY(1);
- top.setY(hybridPlotWorld.PLOT_HEIGHT);
+ bot = bot.withY(1);
+ top = top.withY(hybridPlotWorld.PLOT_HEIGHT);
queue.setCuboid(bot, top, filling);
- bot.setY(hybridPlotWorld.PLOT_HEIGHT);
- top.setY(hybridPlotWorld.PLOT_HEIGHT + 1);
+ bot = bot.withY(hybridPlotWorld.PLOT_HEIGHT);
+ top = top.withY(hybridPlotWorld.PLOT_HEIGHT + 1);
queue.setCuboid(bot, top, plotfloor);
- bot.setY(hybridPlotWorld.PLOT_HEIGHT + 1);
- top.setY(getWorldHeight());
+ bot = bot.withY(hybridPlotWorld.PLOT_HEIGHT + 1);
+ top = top.withY(getWorldHeight());
queue.setCuboid(bot, top, air);
// And finally set the schematic, the y value is unimportant for this function
pastePlotSchematic(queue, bot, top);
@@ -260,7 +259,7 @@ public class HybridPlotManager extends ClassicPlotManager {
}, () -> {
queue.enqueue();
// And notify whatever called this when plot clearing is done
- GlobalBlockQueue.IMP.addEmptyTask(whenDone);
+ PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(whenDone);
}, 10);
return true;
}
diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java
index af6c56768..a4a0d3a28 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java
@@ -25,17 +25,23 @@
*/
package com.plotsquared.core.generator;
+import com.google.inject.assistedinject.Assisted;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.Settings;
+import com.plotsquared.core.configuration.file.YamlConfiguration;
+import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.schematic.Schematic;
+import com.plotsquared.core.queue.GlobalBlockQueue;
+import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
+import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.SchematicHandler;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompoundTagBuilder;
@@ -50,10 +56,12 @@ import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import lombok.Getter;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.inject.Inject;
import java.io.File;
import java.lang.reflect.Field;
import java.util.HashMap;
@@ -74,9 +82,22 @@ 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) {
- super(worldName, id, generator, min, max);
+ private final RegionManager regionManager;
+ private final SchematicHandler schematicHandler;
+
+ @Inject public HybridPlotWorld(@Assisted("world") final String worldName,
+ @Nullable @Assisted("id") final String id,
+ @Assisted @Nonnull final IndependentPlotGenerator generator,
+ @Nullable @Assisted("min") final PlotId min,
+ @Nullable @Assisted("max") final PlotId max,
+ @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
+ @Nonnull final RegionManager regionManager,
+ @Nonnull final SchematicHandler schematicHandler,
+ @Nonnull final GlobalBlockQueue blockQueue,
+ @Nullable final EconHandler econHandler) {
+ super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
+ this.regionManager = regionManager;
+ this.schematicHandler = schematicHandler;
}
public static byte wrap(byte data, int start) {
@@ -126,19 +147,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
return BlockTransformExtent.transform(id, transform);
}
- @NotNull @Override protected PlotManager createManager() {
- return new HybridPlotManager(this);
+ @Nonnull @Override protected PlotManager createManager() {
+ return new HybridPlotManager(this, this.regionManager);
}
- public Location getSignLocation(Plot plot) {
+ public Location getSignLocation(@Nonnull Plot plot) {
plot = plot.getBasePlot(false);
- Location bot = plot.getBottomAbs();
+ final Location bot = plot.getBottomAbs();
if (SIGN_LOCATION == null) {
- bot.setY(ROAD_HEIGHT + 1);
- return bot.add(-1, 0, -2);
+ return bot.withY(ROAD_HEIGHT + 1).add(-1, 0, -2);
} else {
- bot.setY(0);
- return bot.add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
+ return bot.withY(0).add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
}
}
@@ -187,7 +206,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
}
- @Override public boolean isCompatible(PlotArea plotArea) {
+ @Override public boolean isCompatible(@Nonnull final PlotArea plotArea) {
if (!(plotArea instanceof SquarePlotWorld)) {
return false;
}
@@ -200,9 +219,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
// Try to determine root. This means that plot areas can have separate schematic
// directories
- if (!(root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" +
+ if (!(root = MainUtil.getFile(PlotSquared.platform().getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" +
this.getWorldName() + "/" + this.getId())).exists()) {
- root = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
+ root = MainUtil.getFile(PlotSquared.platform().getDirectory(),
"schematics/GEN_ROAD_SCHEMATIC/" + this.getWorldName());
}
@@ -215,9 +234,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
File schematic3File = new File(root, "plot.schem");
if (!schematic3File.exists())
schematic3File = new File(root, "plot.schematic");
- Schematic schematic1 = SchematicHandler.manager.getSchematic(schematic1File);
- Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File);
- Schematic schematic3 = SchematicHandler.manager.getSchematic(schematic3File);
+ Schematic schematic1 = this.schematicHandler.getSchematic(schematic1File);
+ Schematic schematic2 = this.schematicHandler.getSchematic(schematic2File);
+ Schematic schematic3 = this.schematicHandler.getSchematic(schematic3File);
int shift = this.ROAD_WIDTH / 2;
int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1;
diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java
index ed2a23016..30586db05 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java
@@ -25,6 +25,7 @@
*/
package com.plotsquared.core.generator;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.PlotFlagAddEvent;
@@ -40,6 +41,7 @@ import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
+import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.queue.ChunkBlockQueue;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
@@ -63,6 +65,7 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
import java.io.File;
import java.util.ArrayDeque;
@@ -76,7 +79,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-public abstract class HybridUtils {
+public class HybridUtils {
private static final Logger logger = LoggerFactory.getLogger("P2/" + HybridUtils.class.getSimpleName());
@@ -87,9 +90,27 @@ public abstract class HybridUtils {
public static PlotArea area;
public static boolean UPDATE = false;
- public static boolean regeneratePlotWalls(final PlotArea area) {
+ private final PlotAreaManager plotAreaManager;
+ private final ChunkManager chunkManager;
+ private final GlobalBlockQueue blockQueue;
+ private final WorldUtil worldUtil;
+ private final RegionManager regionManager;
+ private final SchematicHandler schematicHandler;
+
+ @Inject public HybridUtils(@Nonnull final PlotAreaManager plotAreaManager,
+ @Nonnull final ChunkManager chunkManager, @Nonnull final GlobalBlockQueue blockQueue,
+ @Nonnull final WorldUtil worldUtil, @Nonnull final RegionManager regionManager, @Nonnull final SchematicHandler schematicHandler) {
+ this.plotAreaManager = plotAreaManager;
+ this.chunkManager = chunkManager;
+ this.blockQueue = blockQueue;
+ this.worldUtil = worldUtil;
+ this.regionManager = regionManager;
+ this.schematicHandler = schematicHandler;
+ }
+
+ public void regeneratePlotWalls(final PlotArea area) {
PlotManager plotManager = area.getPlotManager();
- return plotManager.regenerateAllPlotWalls();
+ plotManager.regenerateAllPlotWalls();
}
public void analyzeRegion(final String world, final CuboidRegion region,
@@ -107,7 +128,7 @@ public abstract class HybridUtils {
*
*/
TaskManager.runTaskAsync(() -> {
- final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
+ final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
final BlockVector3 bot = region.getMinimumPoint();
final BlockVector3 top = region.getMaximumPoint();
@@ -124,7 +145,7 @@ public abstract class HybridUtils {
final int width = tx - bx + 1;
final int length = tz - bz + 1;
- PlotArea area = PlotSquared.get().getPlotArea(world, null);
+ final PlotArea area = this.plotAreaManager.getPlotArea(world, null);
if (!(area instanceof HybridPlotWorld)) {
return;
@@ -231,8 +252,8 @@ public abstract class HybridUtils {
});
System.gc();
MainUtil.initCache();
- Location botLoc = new Location(world, bot.getX(), bot.getY(), bot.getZ());
- Location topLoc = new Location(world, top.getX(), top.getY(), top.getZ());
+ Location botLoc = Location.at(world, bot.getX(), bot.getY(), bot.getZ());
+ Location topLoc = Location.at(world, top.getX(), top.getY(), top.getZ());
ChunkManager.chunkTask(botLoc, topLoc, new RunnableVal() {
@Override public void run(int[] value) {
int X = value[0];
@@ -361,7 +382,7 @@ public abstract class HybridUtils {
for (int z = z1; z <= z2; z++) {
BlockState block = queue.getBlock(x, y, z);
boolean same =
- Arrays.stream(blocks).anyMatch(p -> WorldUtil.IMP.isBlockSame(block, p));
+ Arrays.stream(blocks).anyMatch(p -> this.worldUtil.isBlockSame(block, p));
if (!same) {
count++;
}
@@ -388,7 +409,7 @@ public abstract class HybridUtils {
return false;
}
HybridUtils.UPDATE = true;
- Set regions = RegionManager.manager.getChunkChunks(area.getWorldName());
+ Set regions = this.regionManager.getChunkChunks(area.getWorldName());
return scheduleRoadUpdate(area, regions, extend, new HashSet<>());
}
@@ -420,7 +441,7 @@ public abstract class HybridUtils {
if (!regenedRoad && Settings.DEBUG) {
logger.info("[P2] Failed to regenerate roads");
}
- ChunkManager.manager.unloadChunk(area.getWorldName(), chunk, true);
+ chunkManager.unloadChunk(area.getWorldName(), chunk, true);
}
if (Settings.DEBUG) {
logger.info("[P2] Cancelled road task");
@@ -457,7 +478,7 @@ public abstract class HybridUtils {
}
}
if (!chunks.isEmpty()) {
- TaskManager.IMP.sync(new RunnableVal() {
+ TaskManager.getImplementation().sync(new RunnableVal() {
@Override public void run(Object value) {
long start = System.currentTimeMillis();
Iterator iterator = chunks.iterator();
@@ -485,13 +506,12 @@ public abstract class HybridUtils {
int sz = loc.getZ() << 5;
for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) {
- ChunkManager.manager
- .unloadChunk(area.getWorldName(), BlockVector2.at(x, z),
+ chunkManager.unloadChunk(area.getWorldName(), BlockVector2.at(x, z),
true);
}
}
}
- GlobalBlockQueue.IMP.addEmptyTask(() -> TaskManager.runTaskLater(task, 20));
+ blockQueue.addEmptyTask(() -> TaskManager.runTaskLater(task, 20));
});
}
}
@@ -501,7 +521,7 @@ public abstract class HybridUtils {
public boolean setupRoadSchematic(Plot plot) {
final String world = plot.getWorldName();
- final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
+ final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
Location top = plot.getTopAbs();
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
@@ -525,13 +545,12 @@ public abstract class HybridUtils {
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea()
.toString() + File.separator;
- SchematicHandler.manager.getCompoundTag(world, sideRoad, new RunnableVal() {
+ this.schematicHandler.getCompoundTag(world, sideRoad, new RunnableVal() {
@Override public void run(CompoundTag value) {
- SchematicHandler.manager.save(value, dir + "sideroad.schem");
- SchematicHandler.manager
- .getCompoundTag(world, intersection, new RunnableVal() {
+ schematicHandler.save(value, dir + "sideroad.schem");
+ schematicHandler.getCompoundTag(world, intersection, new RunnableVal() {
@Override public void run(CompoundTag value) {
- SchematicHandler.manager.save(value, dir + "intersection.schem");
+ schematicHandler.save(value, dir + "intersection.schem");
plotworld.ROAD_SCHEMATIC_ENABLED = true;
try {
plotworld.setupSchematics();
@@ -589,9 +608,9 @@ public abstract class HybridUtils {
z -= plotWorld.ROAD_OFFSET_Z;
final int finalX = x;
final int finalZ = z;
- LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(plotWorld.getWorldName(), false);
+ LocalBlockQueue queue = this.blockQueue.getNewQueue(plotWorld.getWorldName(), false);
if (id1 == null || id2 == null || id1 != id2) {
- ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
+ this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
if (id1 != null) {
Plot p1 = area.getPlotAbs(id1);
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
diff --git a/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java b/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java
index 324f6d8d4..c42e54546 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java
@@ -31,7 +31,6 @@ import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.plotsquared.core.setup.PlotAreaBuilder;
-import com.plotsquared.core.setup.SetupProcess;
/**
* This class allows for implementation independent world generation.
@@ -104,7 +103,7 @@ public abstract class IndependentPlotGenerator {
* @return
*/
public GeneratorWrapper specify(String world) {
- return (GeneratorWrapper) PlotSquared.get().IMP.wrapPlotGenerator(world, this);
+ return (GeneratorWrapper) PlotSquared.platform().wrapPlotGenerator(world, this);
}
@Override public String toString() {
diff --git a/Core/src/main/java/com/plotsquared/core/generator/SingleWorldGenerator.java b/Core/src/main/java/com/plotsquared/core/generator/SingleWorldGenerator.java
index eb2037def..7e2f164d3 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/SingleWorldGenerator.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/SingleWorldGenerator.java
@@ -25,23 +25,32 @@
*/
package com.plotsquared.core.generator;
-import com.plotsquared.core.PlotSquared;
+import com.google.inject.Inject;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
+import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockTypes;
+import javax.annotation.Nonnull;
public class SingleWorldGenerator extends IndependentPlotGenerator {
- private Location bedrock1 = new Location(null, 0, 0, 0);
- private Location bedrock2 = new Location(null, 15, 0, 15);
- private Location dirt1 = new Location(null, 0, 1, 0);
- private Location dirt2 = new Location(null, 15, 2, 15);
- private Location grass1 = new Location(null, 0, 3, 0);
- private Location grass2 = new Location(null, 15, 3, 15);
+
+ private static final Location bedrock1 = Location.at("", 0, 0, 0);
+ private static final Location bedrock2 = Location.at("", 15, 0, 15);
+ private static final Location dirt1 = Location.at("", 0, 1, 0);
+ private static final Location dirt2 = Location.at("", 15, 2, 15);
+ private static final Location grass1 = Location.at("", 0, 3, 0);
+ private static final Location grass2 = Location.at("", 15, 3, 15);
+
+ private final PlotAreaManager plotAreaManager;
+
+ @Inject public SingleWorldGenerator(@Nonnull final PlotAreaManager plotAreaManager) {
+ this.plotAreaManager = plotAreaManager;
+ }
@Override public String getName() {
return "PlotSquared:single";
@@ -63,10 +72,10 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
}
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
- return ((SinglePlotAreaManager) PlotSquared.get().getPlotAreaManager()).getArea();
+ return ((SinglePlotAreaManager) this.plotAreaManager).getArea();
}
@Override public void initialize(PlotArea area) {
-
}
+
}
diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java
index 1da8d0ed3..27e093f1b 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java
@@ -35,6 +35,7 @@ import com.plotsquared.core.util.RegionManager;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
import java.util.Iterator;
import java.util.Set;
@@ -47,10 +48,12 @@ public abstract class SquarePlotManager extends GridPlotManager {
private static final Logger logger = LoggerFactory.getLogger("P2/" + SquarePlotManager.class.getSimpleName());
private final SquarePlotWorld squarePlotWorld;
+ private final RegionManager regionManager;
- public SquarePlotManager(SquarePlotWorld squarePlotWorld) {
+ public SquarePlotManager(@Nonnull final SquarePlotWorld squarePlotWorld, @Nonnull final RegionManager regionManager) {
super(squarePlotWorld);
this.squarePlotWorld = squarePlotWorld;
+ this.regionManager = regionManager;
}
@Override public boolean clearPlot(final Plot plot, final Runnable whenDone) {
@@ -64,11 +67,9 @@ public abstract class SquarePlotManager extends GridPlotManager {
Iterator iterator = regions.iterator();
CuboidRegion region = iterator.next();
iterator.remove();
- Location pos1 = new Location(plot.getWorldName(), region.getMinimumPoint().getX(),
- region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
- Location pos2 = new Location(plot.getWorldName(), region.getMaximumPoint().getX(),
- region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
- RegionManager.manager.regenerateRegion(pos1, pos2, false, this);
+ final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint());
+ final Location pos2 = Location.at(plot.getWorldName(), region.getMaximumPoint());
+ regionManager.regenerateRegion(pos1, pos2, false, this);
}
};
run.run();
@@ -82,7 +83,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - (int) Math.floor(squarePlotWorld.ROAD_WIDTH / 2) - 1;
- return new Location(squarePlotWorld.getWorldName(), x, Math.min(getWorldHeight(), 255), z);
+ return Location.at(squarePlotWorld.getWorldName(), x, Math.min(getWorldHeight(), 255), z);
}
@Override public PlotId getPlotIdAbs(int x, int y, int z) {
@@ -247,7 +248,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
.floor(squarePlotWorld.ROAD_WIDTH / 2);
- return new Location(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(),
- z);
+ return Location.at(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java
index 53d00089b..7215f94c6 100644
--- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java
+++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java
@@ -27,8 +27,13 @@ package com.plotsquared.core.generator;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.Settings;
+import com.plotsquared.core.configuration.file.YamlConfiguration;
+import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.PlotId;
-import org.jetbrains.annotations.NotNull;
+import com.plotsquared.core.queue.GlobalBlockQueue;
+import com.plotsquared.core.util.EconHandler;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,9 +46,15 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
public int ROAD_OFFSET_X = 0;
public int ROAD_OFFSET_Z = 0;
- public SquarePlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
- PlotId min, PlotId max) {
- super(worldName, id, generator, min, max);
+ public SquarePlotWorld(final String worldName,
+ @Nullable final String id,
+ @Nonnull final IndependentPlotGenerator generator,
+ @Nullable final PlotId min,
+ @Nullable final PlotId max,
+ @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
+ @Nonnull final GlobalBlockQueue blockQueue,
+ @Nullable final EconHandler econHandler) {
+ super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
}
@Override public void loadConfiguration(ConfigurationSection config) {
diff --git a/Core/src/test/java/com/plotsquared/core/plot/object/LocationTest.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/BackgroundPipeline.java
similarity index 69%
rename from Core/src/test/java/com/plotsquared/core/plot/object/LocationTest.java
rename to Core/src/main/java/com/plotsquared/core/inject/annotations/BackgroundPipeline.java
index cef1b4c94..60c6f475e 100644
--- a/Core/src/test/java/com/plotsquared/core/plot/object/LocationTest.java
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/BackgroundPipeline.java
@@ -23,25 +23,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.plotsquared.core.plot.object;
+package com.plotsquared.core.inject.annotations;
-import com.plotsquared.core.location.Location;
-import org.junit.Test;
+import com.google.inject.BindingAnnotation;
-import java.util.logging.Logger;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
-public class LocationTest {
-
- private static final Logger logger = Logger.getLogger(LocationTest.class.getName());
-
- @Test public void cloning() {
- String world = "plotworld";
- Location location1 = new Location(world, 0, 0, 0);
- logger.info(location1.toString());
- Location clone = location1.clone();
- world = "normal";
- logger.info(clone.toString());
- //location1.getBlockVector3();
-
- }
+@Target({ElementType.PARAMETER, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+public @interface BackgroundPipeline {
}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/annotations/ConfigFile.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/ConfigFile.java
new file mode 100644
index 000000000..6a8f950f8
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/ConfigFile.java
@@ -0,0 +1,39 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.annotations;
+
+import com.google.inject.BindingAnnotation;
+
+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)
+@BindingAnnotation
+public @interface ConfigFile {
+}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/annotations/ConsoleActor.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/ConsoleActor.java
new file mode 100644
index 000000000..41213cc4f
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/ConsoleActor.java
@@ -0,0 +1,39 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.annotations;
+
+import com.google.inject.BindingAnnotation;
+
+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)
+@BindingAnnotation
+public @interface ConsoleActor {
+}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/annotations/DefaultGenerator.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/DefaultGenerator.java
new file mode 100644
index 000000000..26060efd6
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/DefaultGenerator.java
@@ -0,0 +1,39 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.annotations;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.PARAMETER, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+public @interface DefaultGenerator {
+}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/annotations/ImpromptuPipeline.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/ImpromptuPipeline.java
new file mode 100644
index 000000000..76caa547e
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/ImpromptuPipeline.java
@@ -0,0 +1,39 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.annotations;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.PARAMETER, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+public @interface ImpromptuPipeline {
+}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/annotations/WorldConfig.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/WorldConfig.java
new file mode 100644
index 000000000..f7aeb5d54
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/WorldConfig.java
@@ -0,0 +1,39 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.annotations;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.PARAMETER, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+public @interface WorldConfig {
+}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/annotations/WorldFile.java b/Core/src/main/java/com/plotsquared/core/inject/annotations/WorldFile.java
new file mode 100644
index 000000000..4a6518a08
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/annotations/WorldFile.java
@@ -0,0 +1,39 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.annotations;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.PARAMETER, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+public @interface WorldFile {
+}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/factory/HybridPlotWorldFactory.java b/Core/src/main/java/com/plotsquared/core/inject/factory/HybridPlotWorldFactory.java
new file mode 100644
index 000000000..53c446949
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/factory/HybridPlotWorldFactory.java
@@ -0,0 +1,43 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.factory;
+
+import com.google.inject.assistedinject.Assisted;
+import com.plotsquared.core.generator.HybridPlotWorld;
+import com.plotsquared.core.generator.IndependentPlotGenerator;
+import com.plotsquared.core.plot.PlotId;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public interface HybridPlotWorldFactory {
+
+ @Nonnull HybridPlotWorld create(@Nonnull @Assisted("world") String worldName,
+ @Nullable @Assisted("id") String id,
+ @Nonnull IndependentPlotGenerator plotGenerator,
+ @Nullable @Assisted("min") PlotId min,
+ @Nullable @Assisted("max") PlotId max);
+
+}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitHybridUtils.java b/Core/src/main/java/com/plotsquared/core/inject/factory/PlayerBackupProfileFactory.java
similarity index 80%
rename from Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitHybridUtils.java
rename to Core/src/main/java/com/plotsquared/core/inject/factory/PlayerBackupProfileFactory.java
index 2cf4a3b8b..512a6256f 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitHybridUtils.java
+++ b/Core/src/main/java/com/plotsquared/core/inject/factory/PlayerBackupProfileFactory.java
@@ -23,11 +23,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.plotsquared.bukkit.generator;
+package com.plotsquared.core.inject.factory;
-import com.plotsquared.core.generator.HybridUtils;
+import com.plotsquared.core.backup.PlayerBackupProfile;
+import com.plotsquared.core.plot.Plot;
+import javax.annotation.Nonnull;
-public class BukkitHybridUtils extends HybridUtils {
+import java.util.UUID;
+public interface PlayerBackupProfileFactory {
+
+ @Nonnull PlayerBackupProfile create(@Nonnull UUID uuid, @Nonnull Plot plot);
}
diff --git a/Core/src/main/java/com/plotsquared/core/inject/modules/PlotSquaredModule.java b/Core/src/main/java/com/plotsquared/core/inject/modules/PlotSquaredModule.java
new file mode 100644
index 000000000..2103602ff
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/inject/modules/PlotSquaredModule.java
@@ -0,0 +1,57 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+package com.plotsquared.core.inject.modules;
+
+import com.google.inject.AbstractModule;
+import com.plotsquared.core.PlotSquared;
+import com.plotsquared.core.configuration.file.YamlConfiguration;
+import com.plotsquared.core.inject.annotations.BackgroundPipeline;
+import com.plotsquared.core.inject.annotations.ConfigFile;
+import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
+import com.plotsquared.core.inject.annotations.WorldConfig;
+import com.plotsquared.core.inject.annotations.WorldFile;
+import com.plotsquared.core.listener.PlotListener;
+import com.plotsquared.core.util.EventDispatcher;
+import com.plotsquared.core.uuid.UUIDPipeline;
+import com.sk89q.worldedit.WorldEdit;
+
+import java.io.File;
+
+public class PlotSquaredModule extends AbstractModule {
+
+ @Override protected void configure() {
+ final PlotSquared plotSquared = PlotSquared.get();
+ bind(YamlConfiguration.class).annotatedWith(WorldConfig.class).toInstance(plotSquared.getWorldConfiguration());
+ bind(File.class).annotatedWith(WorldFile.class).toInstance(plotSquared.getWorldsFile());
+ bind(File.class).annotatedWith(ConfigFile.class).toInstance(plotSquared.getConfigFile());
+ bind(PlotListener.class).toInstance(plotSquared.getPlotListener());
+ bind(UUIDPipeline.class).annotatedWith(ImpromptuPipeline.class).toInstance(plotSquared.getImpromptuUUIDPipeline());
+ bind(UUIDPipeline.class).annotatedWith(BackgroundPipeline.class).toInstance(plotSquared.getBackgroundUUIDPipeline());
+ bind(WorldEdit.class).toInstance(WorldEdit.getInstance());
+ bind(EventDispatcher.class).toInstance(plotSquared.getEventDispatcher());
+ }
+
+}
diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java
index 361a71b28..f01253053 100644
--- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java
+++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java
@@ -55,16 +55,17 @@ import com.plotsquared.core.plot.flag.implementations.TimeFlag;
import com.plotsquared.core.plot.flag.implementations.TitlesFlag;
import com.plotsquared.core.plot.flag.implementations.WeatherFlag;
import com.plotsquared.core.plot.flag.types.TimedFlag;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan;
-import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
+import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Iterator;
@@ -73,10 +74,16 @@ import java.util.UUID;
public class PlotListener {
- private static final HashMap feedRunnable = new HashMap<>();
- private static final HashMap healRunnable = new HashMap<>();
+ private final HashMap feedRunnable = new HashMap<>();
+ private final HashMap healRunnable = new HashMap<>();
- public static void startRunnable() {
+ private final EventDispatcher eventDispatcher;
+
+ public PlotListener(@Nullable final EventDispatcher eventDispatcher) {
+ this.eventDispatcher = eventDispatcher;
+ }
+
+ public void startRunnable() {
TaskManager.runTaskRepeat(() -> {
if (!healRunnable.isEmpty()) {
for (Iterator> iterator =
@@ -86,15 +93,14 @@ public class PlotListener {
++value.count;
if (value.count == value.interval) {
value.count = 0;
- PlotPlayer player = WorldUtil.IMP.wrapPlayer(entry.getKey());
+ PlotPlayer> player = PlotPlayer.wrap(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
- double level = WorldUtil.IMP.getHealth(player);
+ double level = PlotSquared.platform().getWorldUtil().getHealth(player);
if (level != value.max) {
- WorldUtil.IMP
- .setHealth(player, Math.min(level + value.amount, value.max));
+ PlotSquared.platform().getWorldUtil().setHealth(player, Math.min(level + value.amount, value.max));
}
}
}
@@ -107,15 +113,14 @@ public class PlotListener {
++value.count;
if (value.count == value.interval) {
value.count = 0;
- PlotPlayer player = WorldUtil.IMP.wrapPlayer(entry.getKey());
+ PlotPlayer> player = PlotSquared.platform().getWorldUtil().wrapPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
- int level = WorldUtil.IMP.getFoodLevel(player);
+ int level = PlotSquared.platform().getWorldUtil().getFoodLevel(player);
if (level != value.max) {
- WorldUtil.IMP
- .setFoodLevel(player, Math.min(level + value.amount, value.max));
+ PlotSquared.platform().getWorldUtil().setFoodLevel(player, Math.min(level + value.amount, value.max));
}
}
}
@@ -123,7 +128,7 @@ public class PlotListener {
}, 20);
}
- public static boolean plotEntry(final PlotPlayer> player, final Plot plot) {
+ public boolean plotEntry(final PlotPlayer> player, final Plot plot) {
if (plot.isDenied(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.entry.denied")) {
return false;
@@ -136,7 +141,7 @@ public class PlotListener {
ExpireManager.IMP.handleEntry(player, plot);
}
player.setMeta(PlotPlayer.META_LAST_PLOT, plot);
- PlotSquared.get().getEventDispatcher().callEntry(player, plot);
+ this.eventDispatcher.callEntry(player, plot);
if (plot.hasOwner()) {
// This will inherit values from PlotArea
final TitlesFlag.TitlesFlagValue titleFlag = plot.getFlag(TitlesFlag.class);
@@ -160,7 +165,7 @@ public class PlotListener {
if (plot.getFlag(NotifyEnterFlag.class)) {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : plot.getOwners()) {
- final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
+ final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
if (owner != null && !owner.getUUID().equals(player.getUUID())) {
MainUtil.sendMessage(owner, Captions.NOTIFY_ENTER.getTranslated()
.replace("%player", player.getName())
@@ -215,7 +220,7 @@ public class PlotListener {
PlotFlag, ?> plotFlag =
GlobalFlagContainer.getInstance().getFlag(TimeFlag.class);
PlotFlagRemoveEvent event =
- PlotSquared.get().getEventDispatcher().callFlagRemove(plotFlag, plot);
+ this.eventDispatcher.callFlagRemove(plotFlag, plot);
if (event.getEventResult() != Result.DENY) {
plot.removeFlag(event.getFlag());
}
@@ -293,9 +298,9 @@ public class PlotListener {
return true;
}
- public static boolean plotExit(final PlotPlayer> player, Plot plot) {
+ public boolean plotExit(final PlotPlayer> player, Plot plot) {
Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
- PlotSquared.get().getEventDispatcher().callLeave(player, plot);
+ this.eventDispatcher.callLeave(player, plot);
if (plot.hasOwner()) {
PlotArea pw = plot.getArea();
if (pw == null) {
@@ -336,7 +341,7 @@ public class PlotListener {
if (plot.getFlag(NotifyLeaveFlag.class)) {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : plot.getOwners()) {
- final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
+ final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
MainUtil.sendMessage(owner, Captions.NOTIFY_LEAVE.getTranslated()
.replace("%player", player.getName())
@@ -383,7 +388,7 @@ public class PlotListener {
return true;
}
- public static void logout(UUID uuid) {
+ public void logout(UUID uuid) {
feedRunnable.remove(uuid);
healRunnable.remove(uuid);
}
diff --git a/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java b/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java
index 3e52f8a95..fafaa9b1b 100644
--- a/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java
+++ b/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java
@@ -44,6 +44,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.util.HashMap;
@@ -57,17 +58,19 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
private final Set mask;
private final String world;
private final int max;
+ private final WorldUtil worldUtil;
+
int Ecount = 0;
boolean Eblocked = false;
private int count;
private Extent parent;
private Map tileEntityCount = new HashMap<>();
- public ProcessedWEExtent(String world, Set mask, int max, Extent child,
- Extent parent) {
+ public ProcessedWEExtent(String world, Set mask, int max, Extent child, Extent parent, @Nonnull final WorldUtil worldUtil) {
super(child);
this.mask = mask;
this.world = world;
+ this.worldUtil = worldUtil;
if (max == -1) {
max = Integer.MAX_VALUE;
}
@@ -94,10 +97,10 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
public > boolean setBlock(BlockVector3 location, T block)
throws WorldEditException {
- final boolean isTile = WorldUtil.IMP.getTileEntityTypes().contains(block.getBlockType());
+ final boolean isTile = this.worldUtil.getTileEntityTypes().contains(block.getBlockType());
if (isTile) {
final Integer[] tileEntityCount = this.tileEntityCount.computeIfAbsent(getChunkKey(location),
- key -> new Integer[] {WorldUtil.IMP.getTileEntityCount(world,
+ key -> new Integer[] {this.worldUtil.getTileEntityCount(world,
BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4))});
if (tileEntityCount[0] >= Settings.Chunk_Processor.MAX_TILES) {
return false;
diff --git a/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java b/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java
index c9d883f55..4ae1c5c1f 100644
--- a/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java
+++ b/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java
@@ -25,14 +25,16 @@
*/
package com.plotsquared.core.listener;
-import com.plotsquared.core.PlotSquared;
+import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
+import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.WEManager;
+import com.plotsquared.core.util.WorldUtil;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
@@ -43,10 +45,19 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World;
+import javax.annotation.Nonnull;
import java.util.Set;
public class WESubscriber {
+
+ private final PlotAreaManager plotAreaManager;
+ private final WorldUtil worldUtil;
+
+ @Inject public WESubscriber(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final WorldUtil worldUtil) {
+ this.plotAreaManager = plotAreaManager;
+ this.worldUtil = worldUtil;
+ }
@Subscribe(priority = Priority.VERY_EARLY) public void onEditSession(EditSessionEvent event) {
if (!Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
@@ -66,9 +77,8 @@ public class WESubscriber {
if (plotPlayer == null) {
Player player = (Player) actor;
Location location = player.getLocation();
- com.plotsquared.core.location.Location pLoc =
- new com.plotsquared.core.location.Location(player.getWorld().getName(),
- location.getBlockX(), location.getBlockX(), location.getBlockZ());
+ com.plotsquared.core.location.Location pLoc = com.plotsquared.core.location.Location.at(player.getWorld().getName(),
+ location.toVector().toBlockPoint());
Plot plot = pLoc.getPlot();
if (plot == null) {
event.setExtent(new NullExtent());
@@ -83,19 +93,19 @@ public class WESubscriber {
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
MainUtil.sendMessage(plotPlayer, Captions.WORLDEDIT_BYPASS);
}
- if (PlotSquared.get().hasPlotArea(world)) {
+ if (this.plotAreaManager.hasPlotArea(world)) {
event.setExtent(new NullExtent());
}
return;
}
}
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
- if (PlotSquared.get().hasPlotArea(world)) {
+ if (this.plotAreaManager.hasPlotArea(world)) {
event.setExtent(
new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(),
- event.getExtent()));
+ event.getExtent(), this.worldUtil));
}
- } else if (PlotSquared.get().hasPlotArea(world)) {
+ } else if (this.plotAreaManager.hasPlotArea(world)) {
event.setExtent(new WEExtent(mask, event.getExtent()));
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/location/Location.java b/Core/src/main/java/com/plotsquared/core/location/Location.java
index 08db98a19..53db29ed7 100644
--- a/Core/src/main/java/com/plotsquared/core/location/Location.java
+++ b/Core/src/main/java/com/plotsquared/core/location/Location.java
@@ -25,101 +25,225 @@
*/
package com.plotsquared.core.location;
+import com.google.common.base.Preconditions;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
-import com.plotsquared.core.plot.PlotManager;
-import com.plotsquared.core.util.MathMan;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
-import lombok.Setter;
-import org.jetbrains.annotations.NotNull;
import org.khelekore.prtree.MBR;
import org.khelekore.prtree.SimpleMBR;
-public class Location implements Cloneable, Comparable {
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
- private int x;
- private int y;
- private int z;
- @Getter @Setter private float yaw;
- @Getter @Setter private float pitch;
- @Getter @Setter private String world;
- @Getter private BlockVector3 blockVector3;
+/**
+ * An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
+ */
+@EqualsAndHashCode @SuppressWarnings("unused")
+public final class Location implements Comparable {
- public Location(String world, int x, int y, int z, float yaw, float pitch) {
- this.world = world;
- this.x = x;
- this.y = y;
- this.z = z;
+ @Getter private final float yaw;
+ @Getter private final float pitch;
+ @Getter private final BlockVector3 blockVector3;
+ private final World> world;
+
+ private Location(@Nonnull final World> world, @Nonnull final BlockVector3 blockVector3,
+ final float yaw, final float pitch) {
+ this.world = Preconditions.checkNotNull(world, "World may not be null");
+ this.blockVector3 = Preconditions.checkNotNull(blockVector3, "Vector may not be null");
this.yaw = yaw;
this.pitch = pitch;
- this.blockVector3 = BlockVector3.at(x, y, z);
}
- public Location(String world, int x, int y, int z) {
- this(world, x, y, z, 0f, 0f);
- }
-
- public int getX() {
- return this.x;
- }
-
- public void setX(int x) {
- this.x = x;
- this.blockVector3 = BlockVector3.at(x, y, z);
- }
-
- public int getY() {
- return this.y;
- }
-
- public void setY(int y) {
- this.y = y;
- this.blockVector3 = BlockVector3.at(x, y, z);
- }
-
- public int getZ() {
- return this.z;
- }
-
- public void setZ(int z) {
- this.z = z;
- this.blockVector3 = BlockVector3.at(x, y, z);
- }
-
- public void setBlockVector3(BlockVector3 blockVector3) {
- this.blockVector3 = blockVector3;
- this.x = blockVector3.getX();
- this.y = blockVector3.getY();
- this.z = blockVector3.getZ();
- }
-
- @Override public Location clone() {
- try {
- return (Location) super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(); //can't happen
+ private Location(@Nonnull final String worldName, @Nonnull final BlockVector3 blockVector3,
+ final float yaw, final float pitch) {
+ Preconditions.checkNotNull(worldName, "World name may not be null");
+ if (worldName.isEmpty()) {
+ this.world = World.nullWorld();
+ } else {
+ this.world = PlotSquared.platform().getPlatformWorld(worldName);
}
+ this.blockVector3 = Preconditions.checkNotNull(blockVector3, "Vector may not be null");
+ this.yaw = yaw;
+ this.pitch = pitch;
}
/**
- * Return a copy of the location. This will pass {@link #equals(Object)}
- * but will have a different identity.
+ * Construct a new location
*
- * @return Copy of the location
+ * @param world World
+ * @param blockVector3 (x,y,z) vector
+ * @param yaw yaw
+ * @param pitch pitch
+ * @return New location
*/
- @NotNull public Location copy() {
- return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch);
+ @Nonnull public static Location at(@Nonnull final String world,
+ @Nonnull final BlockVector3 blockVector3, final float yaw, final float pitch) {
+ return new Location(world, blockVector3, yaw, pitch);
}
- public PlotArea getPlotArea() {
- return PlotSquared.get().getPlotAreaAbs(this);
+ /**
+ * Construct a new location with yaw and pitch equal to 0
+ *
+ * @param world World
+ * @param blockVector3 (x,y,z) vector
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final String world,
+ @Nonnull final BlockVector3 blockVector3) {
+ return at(world, blockVector3, 0f, 0f);
}
- public Plot getOwnedPlot() {
- PlotArea area = getPlotArea();
+ /**
+ * Construct a new location
+ *
+ * @param world World
+ * @param x X coordinate
+ * @param y Y coordinate
+ * @param z Z coordinate
+ * @param yaw Yaw
+ * @param pitch Pitch
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final String world, final int x, final int y,
+ final int z, final float yaw, final float pitch) {
+ return at(world, BlockVector3.at(x, y, z), yaw, pitch);
+ }
+
+ /**
+ * Construct a new location with yaw and pitch equal to 0
+ *
+ * @param world World
+ * @param x X coordinate
+ * @param y Y coordinate
+ * @param z Z coordinate
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final String world, final int x, final int y,
+ final int z) {
+ return at(world, BlockVector3.at(x, y, z));
+ }
+
+ /**
+ * Construct a new location
+ *
+ * @param world World
+ * @param blockVector3 (x,y,z) vector
+ * @param yaw yaw
+ * @param pitch pitch
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final World> world,
+ @Nonnull final BlockVector3 blockVector3, final float yaw, final float pitch) {
+ return new Location(world, blockVector3, yaw, pitch);
+ }
+
+ /**
+ * Construct a new location with yaw and pitch equal to 0
+ *
+ * @param world World
+ * @param blockVector3 (x,y,z) vector
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final World> world,
+ @Nonnull final BlockVector3 blockVector3) {
+ return at(world, blockVector3, 0f, 0f);
+ }
+
+ /**
+ * Construct a new location
+ *
+ * @param world World
+ * @param x X coordinate
+ * @param y Y coordinate
+ * @param z Z coordinate
+ * @param yaw Yaw
+ * @param pitch Pitch
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final World> world, final int x, final int y,
+ final int z, final float yaw, final float pitch) {
+ return at(world, BlockVector3.at(x, y, z), yaw, pitch);
+ }
+
+ /**
+ * Construct a new location with yaw and pitch equal to 0
+ *
+ * @param world World
+ * @param x X coordinate
+ * @param y Y coordinate
+ * @param z Z coordinate
+ * @return New location
+ */
+ @Nonnull public static Location at(@Nonnull final World> world, final int x, final int y,
+ final int z) {
+ return at(world, BlockVector3.at(x, y, z));
+ }
+
+ /**
+ * Get the world object
+ *
+ * @return World object
+ */
+ @Nonnull public World> getWorld() {
+ return this.world;
+ }
+
+ /**
+ * Get the name of the world this location is in
+ *
+ * @return World name
+ */
+ @Nonnull public String getWorldName() {
+ return this.world.getName();
+ }
+
+ /**
+ * Get the X coordinate
+ *
+ * @return X coordinate
+ */
+ public int getX() {
+ return this.blockVector3.getBlockX();
+ }
+
+ /**
+ * Get the Y coordinate
+ *
+ * @return Y coordinate
+ */
+ public int getY() {
+ return this.blockVector3.getY();
+ }
+
+ /**
+ * Get the Z coordinate
+ *
+ * @return Z coordinate
+ */
+ public int getZ() {
+ return this.blockVector3.getZ();
+ }
+
+ /**
+ * Get the {@link PlotArea}, if any, that contains this location
+ *
+ * @return Plot area containing the location, or {@code null}
+ */
+ @Nullable public PlotArea getPlotArea() {
+ return PlotSquared.get().getPlotAreaManager().getPlotArea(this);
+ }
+
+ /**
+ * Get the owned {@link Plot}, if any, that contains this location
+ *
+ * @return Plot containing the location, or {@code null}
+ */
+ @Nullable public Plot getOwnedPlot() {
+ final PlotArea area = this.getPlotArea();
if (area != null) {
return area.getOwnedPlot(this);
} else {
@@ -127,8 +251,13 @@ public class Location implements Cloneable, Comparable {
}
}
- public Plot getOwnedPlotAbs() {
- PlotArea area = getPlotArea();
+ /**
+ * Get the (absolute) owned {@link Plot}, if any, that contains this location
+ *
+ * @return (Absolute) plot containing the location, or {@code null}
+ */
+ @Nullable public Plot getOwnedPlotAbs() {
+ final PlotArea area = this.getPlotArea();
if (area != null) {
return area.getOwnedPlotAbs(this);
} else {
@@ -136,36 +265,42 @@ public class Location implements Cloneable, Comparable {
}
}
+ /**
+ * Check whether or not the location belongs to a plot area
+ *
+ * @return {@code true} if the location belongs to a plot area, else {@code false}
+ */
public boolean isPlotArea() {
- return getPlotArea() != null;
+ return this.getPlotArea() != null;
}
+ /**
+ * Check whether or not the location belongs to a plot road
+ *
+ * @return {@code true} if the location belongs to a plot road, else {@code false}
+ */
public boolean isPlotRoad() {
- PlotArea area = getPlotArea();
+ final PlotArea area = this.getPlotArea();
return area != null && area.getPlotAbs(this) == null;
}
/**
* Checks if anyone owns a plot at the current location.
*
- * @return true if the location is a road, not a plot area, or if the plot is unclaimed.
+ * @return {@code true} if the location is a road, not a plot area, or if the plot is unclaimed.
*/
public boolean isUnownedPlotArea() {
- PlotArea area = getPlotArea();
+ final PlotArea area = this.getPlotArea();
return area != null && area.getOwnedPlotAbs(this) == null;
}
- public PlotManager getPlotManager() {
- PlotArea pa = getPlotArea();
- if (pa != null) {
- return pa.getPlotManager();
- } else {
- return null;
- }
- }
-
- public Plot getPlotAbs() {
- PlotArea area = getPlotArea();
+ /**
+ * Get the absolute {@link Plot}, if any, that contains this location
+ *
+ * @return (Absolute) plot containing the location, or {code null}
+ */
+ @Nullable public Plot getPlotAbs() {
+ final PlotArea area = this.getPlotArea();
if (area != null) {
return area.getPlotAbs(this);
} else {
@@ -173,8 +308,13 @@ public class Location implements Cloneable, Comparable {
}
}
- public Plot getPlot() {
- PlotArea area = getPlotArea();
+ /**
+ * Get the {@link Plot}, if any, that contains this location
+ *
+ * @return plot containing the location, or {code null}
+ */
+ @Nullable public Plot getPlot() {
+ final PlotArea area = this.getPlotArea();
if (area != null) {
return area.getPlot(this);
} else {
@@ -182,89 +322,133 @@ public class Location implements Cloneable, Comparable {
}
}
- public BlockVector2 getBlockVector2() {
- return BlockVector2.at(this.x >> 4, this.z >> 4);
+ /**
+ * Get the coordinates of the chunk that contains this location
+ *
+ * @return Chunk coordinates
+ */
+ @Nonnull public BlockVector2 getChunkLocation() {
+ return BlockVector2.at(this.getX() >> 4, this.getZ() >> 4);
}
- public Location add(int x, int y, int z) {
- this.x += x;
- this.y += y;
- this.z += z;
- this.blockVector3 = BlockVector3.at(this.x, this.y, this.z);
- return this;
+ /**
+ * Return a new location offset by the given coordinates
+ *
+ * @param x X offset
+ * @param y Y offset
+ * @param z Z offset
+ * @return New location
+ */
+ @Nonnull public Location add(final int x, final int y, final int z) {
+ return new Location(this.world, this.blockVector3.add(x, y, z), this.yaw, this.pitch);
}
- public double getEuclideanDistanceSquared(Location l2) {
+ /**
+ * Return a new location using the given X coordinate
+ *
+ * @param x New X coordinate
+ * @return New location
+ */
+ @Nonnull public Location withX(final int x) {
+ return new Location(this.world, this.blockVector3.withX(x), this.yaw, this.pitch);
+ }
+
+ /**
+ * Return a new location using the given Y coordinate
+ *
+ * @param y New Y coordinate
+ * @return New location
+ */
+ @Nonnull public Location withY(final int y) {
+ return new Location(this.world, this.blockVector3.withY(y), this.yaw, this.pitch);
+ }
+
+ /**
+ * Return a new location using the given Z coordinate
+ *
+ * @param z New Z coordinate
+ * @return New location
+ */
+ @Nonnull public Location withZ(final int z) {
+ return new Location(this.world, this.blockVector3.withZ(z), this.yaw, this.pitch);
+ }
+
+ /**
+ * Return a new location using the given yaw
+ *
+ * @param yaw New yaw
+ * @return New location
+ */
+ @Nonnull public Location withYaw(final float yaw) {
+ return new Location(this.world, this.blockVector3, yaw, this.pitch);
+ }
+
+ /**
+ * Return a new location using the given pitch
+ *
+ * @param pitch New pitch
+ * @return New location
+ */
+ @Nonnull public Location withPitch(final float pitch) {
+ return new Location(this.world, this.blockVector3, this.yaw, pitch);
+ }
+
+ /**
+ * Return a new location using the given world
+ *
+ * @param world New world
+ * @return New location
+ */
+ @Nonnull public Location withWorld(@Nonnull final String world) {
+ return new Location(world, this.blockVector3, this.yaw, this.pitch);
+ }
+
+ public double getEuclideanDistanceSquared(@Nonnull final Location l2) {
double x = getX() - l2.getX();
double y = getY() - l2.getY();
double z = getZ() - l2.getZ();
return x * x + y * y + z * z;
}
- public double getEuclideanDistance(Location l2) {
+ public double getEuclideanDistance(@Nonnull final Location l2) {
return Math.sqrt(getEuclideanDistanceSquared(l2));
}
- public boolean isInSphere(Location origin, int radius) {
- return getEuclideanDistanceSquared(origin) < radius * radius;
+ /**
+ * Return a new location offset by (-) the given coordinates
+ *
+ * @param x X offset
+ * @param y Y offset
+ * @param z Z offset
+ * @return New location
+ */
+ @Nonnull public Location subtract(int x, int y, int z) {
+ return this.add(-x, -y, -z);
}
- @Override public int hashCode() {
- return MathMan.pair((short) this.x, (short) this.z) * 17 + this.y;
+ /**
+ * Get a minimum bounding rectangle that contains this location only
+ *
+ * @return Minimum bounding rectangle
+ */
+ @Nonnull public MBR toMBR() {
+ return new SimpleMBR(this.getX(), this.getX(), this.getY(), this.getY(), this.getZ(),
+ this.getZ());
}
- public boolean isInAABB(Location min, Location max) {
- return this.x >= min.getX() && this.x <= max.getX() && this.y >= min.getY() && this.y <= max
- .getY() && this.z >= min.getX() && this.z < max.getZ();
- }
-
- public void lookTowards(int x, int y) {
- double l = this.x - x;
- double c = Math.sqrt(l * l + 0.0);
- if (Math.asin(0 / c) / Math.PI * 180 > 90) {
- setYaw((float) (180 - -Math.asin(l / c) / Math.PI * 180));
- } else {
- setYaw((float) (-Math.asin(l / c) / Math.PI * 180));
- }
- }
-
- public Location subtract(int x, int y, int z) {
- this.x -= x;
- this.y -= y;
- this.z -= z;
- this.blockVector3 = BlockVector3.at(this.x, this.y, this.z);
- return this;
- }
-
- public MBR toMBR() {
- return new SimpleMBR(this.getX(), this.getX(), this.getY(), this.getY(), this.getZ(), this.getZ());
- }
-
- @Override public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (!(o instanceof Location)) {
- return false;
- }
- Location l = (Location) o;
- return this.x == l.getX() && this.y == l.getY() && this.z == l.getZ() && this.world
- .equals(l.getWorld()) && this.yaw == l.getYaw() && this.pitch == l.getPitch();
- }
-
- @Override public int compareTo(Location o) {
- if (this.x == o.getX() && this.y == o.getY() || this.z == o.getZ()) {
+ @Override public int compareTo(@Nonnull final Location o) {
+ if (this.getX() == o.getX() && this.getY() == o.getY() || this.getZ() == o.getZ()) {
return 0;
}
- if (this.x < o.getX() && this.y < o.getY() && this.z < o.getZ()) {
+ if (this.getX() < o.getX() && this.getY() < o.getY() && this.getZ() < o.getZ()) {
return -1;
}
return 1;
}
@Override public String toString() {
- return "\"plotsquaredlocation\":{\"x\":" + this.x + ",\"y\":" + this.y + ",\"z\":" + this.z
- + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\"" + this.world
- + "\"}";
+ return "\"plotsquaredlocation\":{\"x\":" + this.getX() + ",\"y\":" + this.getY() + ",\"z\":"
+ + this.getZ() + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\""
+ + this.world + "\"}";
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/location/PlotLoc.java b/Core/src/main/java/com/plotsquared/core/location/PlotLoc.java
index 6181f9fad..8301f23a7 100644
--- a/Core/src/main/java/com/plotsquared/core/location/PlotLoc.java
+++ b/Core/src/main/java/com/plotsquared/core/location/PlotLoc.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.location;
import com.plotsquared.core.util.StringMan;
import lombok.AllArgsConstructor;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nullable;
//todo better description needed
diff --git a/Core/src/main/java/com/plotsquared/core/location/World.java b/Core/src/main/java/com/plotsquared/core/location/World.java
new file mode 100644
index 000000000..2e4eb6c52
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/location/World.java
@@ -0,0 +1,84 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * 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 .
+ */
+
+package com.plotsquared.core.location;
+
+import javax.annotation.Nonnull;
+
+/**
+ * PlotSquared representation of a platform world
+ *
+ * @param Platform world type
+ */
+public interface World {
+
+ /**
+ * Get the platform world represented by this world
+ *
+ * @return Platform world
+ */
+ @Nonnull T getPlatformWorld();
+
+ /**
+ * Get the name of the world
+ *
+ * @return World name
+ */
+ @Nonnull String getName();
+
+ /**
+ * Get a {@link NullWorld} implementation
+ *
+ * @return NullWorld instance
+ */
+ static NullWorld nullWorld() {
+ return new NullWorld<>();
+ }
+
+ class NullWorld implements World {
+
+ private NullWorld() {
+ }
+
+ @Nonnull @Override public T getPlatformWorld() {
+ throw new UnsupportedOperationException("Cannot get platform world from NullWorld");
+ }
+
+ @Override public @Nonnull String getName() {
+ return "";
+ }
+
+ @Override public boolean equals(final Object obj) {
+ return obj instanceof NullWorld;
+ }
+
+ @Override public int hashCode() {
+ return "null".hashCode();
+ }
+
+ }
+
+}
diff --git a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java
index 410b20925..c6efe33cd 100644
--- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java
+++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java
@@ -25,19 +25,25 @@
*/
package com.plotsquared.core.player;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.RequiredType;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.TeleportCause;
+import com.plotsquared.core.inject.annotations.ConsoleActor;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotWeather;
+import com.plotsquared.core.plot.world.PlotAreaManager;
+import com.plotsquared.core.util.EconHandler;
+import com.plotsquared.core.util.EventDispatcher;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,37 +54,50 @@ public class ConsolePlayer extends PlotPlayer {
private static final Logger logger = LoggerFactory.getLogger("P2/" + ConsolePlayer.class.getSimpleName());
private static ConsolePlayer instance;
- private ConsolePlayer() {
- PlotArea area = PlotSquared.get().getFirstPlotArea();
+ private final Actor actor;
+
+ @Inject private ConsolePlayer(@Nonnull final PlotAreaManager plotAreaManager,
+ @Nonnull final EventDispatcher eventDispatcher,
+ @ConsoleActor @Nonnull final Actor actor,
+ @Nullable final EconHandler econHandler) {
+ super(plotAreaManager, eventDispatcher, econHandler);
+ this.actor = actor;
+ final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
+ final PlotArea area;
+ if (areas.length > 0) {
+ area = areas[0];
+ } else {
+ area = null;
+ }
Location location;
if (area != null) {
CuboidRegion region = area.getRegion();
- location = new Location(area.getWorldName(),
+ location = Location.at(area.getWorldName(),
region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
} else {
- location = new Location("world", 0, 0, 0);
+ location = Location.at("", 0, 0, 0);
}
setMeta("location", location);
}
public static ConsolePlayer getConsole() {
if (instance == null) {
- instance = new ConsolePlayer();
+ instance = PlotSquared.platform().getInjector().getInstance(ConsolePlayer.class);
instance.teleport(instance.getLocation());
}
return instance;
}
@Override public Actor toActor() {
- return PlotSquared.get().IMP.getConsole();
+ return this.actor;
}
@Override public Actor getPlatformPlayer() {
return this.toActor();
}
- @Override public boolean canTeleport(@NotNull Location location) {
+ @Override public boolean canTeleport(@Nonnull Location location) {
return true;
}
@@ -86,7 +105,7 @@ public class ConsolePlayer extends PlotPlayer {
public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) {
}
- @NotNull @Override public Location getLocation() {
+ @Nonnull @Override public Location getLocation() {
return this.getMeta("location");
}
@@ -94,7 +113,7 @@ public class ConsolePlayer extends PlotPlayer {
return getLocation();
}
- @NotNull @Override public UUID getUUID() {
+ @Nonnull @Override public UUID getUUID() {
return DBFunc.EVERYONE;
}
@@ -144,14 +163,14 @@ public class ConsolePlayer extends PlotPlayer {
return RequiredType.CONSOLE;
}
- @Override public void setWeather(@NotNull PlotWeather weather) {
+ @Override public void setWeather(@Nonnull PlotWeather weather) {
}
- @Override public @NotNull GameMode getGameMode() {
+ @Override public @Nonnull GameMode getGameMode() {
return GameModes.SPECTATOR;
}
- @Override public void setGameMode(@NotNull GameMode gameMode) {
+ @Override public void setGameMode(@Nonnull GameMode gameMode) {
}
@Override public void setTime(long time) {
@@ -164,7 +183,7 @@ public class ConsolePlayer extends PlotPlayer {
@Override public void setFlight(boolean fly) {
}
- @Override public void playMusic(@NotNull Location location, @NotNull ItemType id) {
+ @Override public void playMusic(@Nonnull Location location, @Nonnull ItemType id) {
}
@Override public void kick(String message) {
diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
index a1d178469..7b4c8f530 100644
--- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
+++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
@@ -46,14 +46,16 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.util.EconHandler;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
+import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.item.ItemType;
-import lombok.NonNull;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,7 +70,6 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
/**
* The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}.
@@ -91,7 +92,17 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
private ConcurrentHashMap meta;
private int hash;
- public static PlotPlayer from(@NonNull final T object) {
+ private final PlotAreaManager plotAreaManager;
+ private final EventDispatcher eventDispatcher;
+ private final EconHandler econHandler;
+
+ public PlotPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher, @Nullable final EconHandler econHandler) {
+ this.plotAreaManager = plotAreaManager;
+ this.eventDispatcher = eventDispatcher;
+ this.econHandler = econHandler;
+ }
+
+ public static PlotPlayer from(@Nonnull final T object) {
if (!converters.containsKey(object.getClass())) {
throw new IllegalArgumentException(String
.format("There is no registered PlotPlayer converter for type %s",
@@ -100,7 +111,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
return converters.get(object.getClass()).convert(object);
}
- public static void registerConverter(@NonNull final Class clazz,
+ public static void registerConverter(@Nonnull final Class clazz,
final PlotPlayerConverter converter) {
converters.put(clazz, converter);
}
@@ -109,7 +120,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
return Collections.unmodifiableCollection(debugModeEnabled);
}
- public static Collection> getDebugModePlayersInPlot(@NotNull final Plot plot) {
+ public static Collection> getDebugModePlayersInPlot(@Nonnull final Plot plot) {
if (debugModeEnabled.isEmpty()) {
return Collections.emptyList();
}
@@ -133,7 +144,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
* @return Wrapped player
*/
public static PlotPlayer> wrap(Object player) {
- return PlotSquared.get().IMP.wrapPlayer(player);
+ return PlotSquared.platform().wrapPlayer(player);
}
public abstract Actor toActor();
@@ -269,11 +280,11 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
*/
public int getPlotCount() {
if (!Settings.Limit.GLOBAL) {
- return getPlotCount(getLocation().getWorld());
+ return getPlotCount(getLocation().getWorldName());
}
final AtomicInteger count = new AtomicInteger(0);
final UUID uuid = getUUID();
- PlotSquared.get().forEachPlotArea(value -> {
+ this.plotAreaManager.forEachPlotArea(value -> {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
for (Plot plot : value.getPlotsAbs(uuid)) {
if (!DoneFlag.isDone(plot)) {
@@ -289,10 +300,10 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
public int getClusterCount() {
if (!Settings.Limit.GLOBAL) {
- return getClusterCount(getLocation().getWorld());
+ return getClusterCount(getLocation().getWorldName());
}
final AtomicInteger count = new AtomicInteger(0);
- PlotSquared.get().forEachPlotArea(value -> {
+ this.plotAreaManager.forEachPlotArea(value -> {
for (PlotCluster cluster : value.getClusters()) {
if (cluster.isOwner(getUUID())) {
count.incrementAndGet();
@@ -311,7 +322,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
public int getPlotCount(String world) {
UUID uuid = getUUID();
int count = 0;
- for (PlotArea area : PlotSquared.get().getPlotAreas(world)) {
+ for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
count +=
area.getPlotsAbs(uuid).stream().filter(plot -> !DoneFlag.isDone(plot)).count();
@@ -325,7 +336,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
public int getClusterCount(String world) {
UUID uuid = getUUID();
int count = 0;
- for (PlotArea area : PlotSquared.get().getPlotAreas(world)) {
+ for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) {
for (PlotCluster cluster : area.getClusters()) {
if (cluster.isOwner(getUUID())) {
count++;
@@ -343,20 +354,20 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
* @see #getPlotCount() for the number of plots
*/
public Set getPlots() {
- return PlotSquared.get().getPlots(this);
+ return PlotQuery.newQuery().ownedBy(this).asSet();
}
/**
* Return the PlotArea this player is currently in, or null.
*
- * @return
+ * @return Plot area the player is currently in, or {@code null}
*/
- public PlotArea getPlotAreaAbs() {
- return PlotSquared.get().getPlotAreaAbs(getLocation());
+ @Nullable public PlotArea getPlotAreaAbs() {
+ return this.plotAreaManager.getPlotArea(getLocation());
}
public PlotArea getApplicablePlotArea() {
- return PlotSquared.get().getApplicablePlotArea(getLocation());
+ return this.plotAreaManager.getApplicablePlotArea(getLocation());
}
@Override public RequiredType getSuperCaller() {
@@ -368,10 +379,10 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
*
* @return The location
*/
- @NotNull public Location getLocation() {
+ @Nonnull public Location getLocation() {
Location location = getMeta("location");
if (location != null) {
- return location.copy(); // Always return a copy of the location
+ return location;
}
return getLocationFull();
}
@@ -395,9 +406,9 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
*
* @return UUID
*/
- @Override @NotNull public abstract UUID getUUID();
+ @Override @Nonnull public abstract UUID getUUID();
- public boolean canTeleport(@NotNull final Location location) {
+ public boolean canTeleport(@Nonnull final Location location) {
Preconditions.checkNotNull(location, "Specified location cannot be null");
final Location current = getLocationFull();
teleport(location);
@@ -489,21 +500,21 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
*
* @param weather the weather visible to the player
*/
- public abstract void setWeather(@NotNull PlotWeather weather);
+ public abstract void setWeather(@Nonnull PlotWeather weather);
/**
* Get this player's gamemode.
*
* @return the gamemode of the player.
*/
- public abstract @NotNull GameMode getGameMode();
+ public abstract @Nonnull GameMode getGameMode();
/**
* Set this player's gameMode.
*
* @param gameMode the gamemode to set
*/
- public abstract void setGameMode(@NotNull GameMode gameMode);
+ public abstract void setGameMode(@Nonnull GameMode gameMode);
/**
* Set this player's local time (ticks).
@@ -532,7 +543,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
* @param location where to play the music
* @param id the record item id
*/
- public abstract void playMusic(@NotNull Location location, @NotNull ItemType id);
+ public abstract void playMusic(@Nonnull Location location, @Nonnull ItemType id);
/**
* Check if this player is banned.
@@ -579,7 +590,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
removePersistentMeta("quitLoc");
}
if (plot != null) {
- PlotSquared.get().getEventDispatcher().callLeave(this, plot);
+ this.eventDispatcher.callLeave(this, plot);
}
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
for (Plot owned : getPlots()) {
@@ -592,8 +603,8 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(getUUID(), System.currentTimeMillis());
}
- PlotSquared.imp().getPlayerManager().removePlayer(this);
- PlotSquared.get().IMP.unregister(this);
+ PlotSquared.platform().getPlayerManager().removePlayer(this);
+ PlotSquared.platform().unregister(this);
debugModeEnabled.remove(this);
}
@@ -617,7 +628,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
*/
public int getPlayerClusterCount() {
final AtomicInteger count = new AtomicInteger();
- PlotSquared.get().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
+ this.plotAreaManager.forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
return count.get();
}
@@ -628,9 +639,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
* @return a {@code Set} of plots this player owns in the provided world
*/
public Set getPlots(String world) {
- UUID uuid = getUUID();
- return PlotSquared.get().getPlots(world).stream().filter(plot -> plot.isOwner(uuid))
- .collect(Collectors.toCollection(HashSet::new));
+ return PlotQuery.newQuery().inWorld(world).ownedBy(getUUID()).asSet();
}
public void populatePersistentMetaMap() {
@@ -650,7 +659,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
if (!Settings.Teleport.ON_LOGIN) {
return;
}
- PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
+ PlotAreaManager manager = PlotPlayer.this.plotAreaManager;
if (!(manager instanceof SinglePlotAreaManager)) {
return;
@@ -678,7 +687,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
return;
}
- final Location location = new Location(plot.getWorldName(), x, y, z);
+ final Location location = Location.at(plot.getWorldName(), x, y, z);
if (plot.isLoaded()) {
TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin", true)) {
@@ -760,23 +769,24 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer
* The amount of money this Player has.
*/
public double getMoney() {
- return EconHandler.getEconHandler() == null ? 0 : EconHandler.getEconHandler().getMoney(this);
+ return this.econHandler == null ? 0 : this.econHandler.getMoney(this);
}
public void withdraw(double amount) {
- if (EconHandler.getEconHandler() != null) {
- EconHandler.getEconHandler().withdrawMoney(this, amount);
+ if (this.econHandler != null) {
+ this.econHandler.withdrawMoney(this, amount);
}
}
public void deposit(double amount) {
- if (EconHandler.getEconHandler() != null) {
- EconHandler.getEconHandler().depositMoney(this, amount);
+ if (this.econHandler != null) {
+ this.econHandler.depositMoney(this, amount);
}
}
@FunctionalInterface
public interface PlotPlayerConverter {
- PlotPlayer convert(BaseObject object);
+ PlotPlayer> convert(BaseObject object);
}
+
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java b/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java
index b5a6250ab..f467c595f 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java
@@ -38,8 +38,9 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import lombok.NonNull;
+
import lombok.RequiredArgsConstructor;
+import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Map;
@@ -81,28 +82,28 @@ public final class BlockBucket implements ConfigurationSerializable {
this.input = new StringBuilder();
}
- public static BlockBucket withSingle(@NonNull final BlockState block) {
+ public static BlockBucket withSingle(@Nonnull final BlockState block) {
final BlockBucket blockBucket = new BlockBucket();
blockBucket.addBlock(block, 100);
return blockBucket;
}
- public static BlockBucket deserialize(@NonNull final Map map) {
+ public static BlockBucket deserialize(@Nonnull final Map map) {
if (!map.containsKey("blocks")) {
return null;
}
return ConfigurationUtil.BLOCK_BUCKET.parseString(map.get("blocks").toString());
}
- public void addBlock(@NonNull final BlockState block) {
+ public void addBlock(@Nonnull final BlockState block) {
this.addBlock(block, -1);
}
- public void addBlock(@NonNull final BlockState block, final int chance) {
+ public void addBlock(@Nonnull final BlockState block, final int chance) {
addBlock(block, (double) chance);
}
- private void addBlock(@NonNull final BlockState block, double chance) {
+ private void addBlock(@Nonnull final BlockState block, double chance) {
if (chance == -1)
chance = 1;
String prefix = input.length() == 0 ? "" : ",";
diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java
index f0bd35552..70f39aa08 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java
@@ -27,6 +27,7 @@ package com.plotsquared.core.plot;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationUtil;
@@ -38,6 +39,7 @@ import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.generator.SquarePlotWorld;
+import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Direction;
@@ -55,6 +57,7 @@ import com.plotsquared.core.plot.flag.implementations.KeepFlag;
import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions;
@@ -63,6 +66,7 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
+import com.plotsquared.core.uuid.UUIDPipeline;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
@@ -71,8 +75,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.Getter;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -126,7 +130,17 @@ public class Plot {
private static Set connected_cache;
private static Set regions_cache;
- @NotNull private final PlotId id;
+ @Nonnull private final PlotId id;
+
+ // These will be injected
+ @Inject private EventDispatcher eventDispatcher;
+ @Inject private PlotListener plotListener;
+ @Inject private RegionManager regionManager;
+ @Inject private GlobalBlockQueue blockQueue;
+ @Inject private WorldUtil worldUtil;
+ @Inject private SchematicHandler schematicHandler;
+ @Inject @ImpromptuPipeline private UUIDPipeline impromptuPipeline;
+
/**
* Plot flag container
*/
@@ -197,7 +211,7 @@ public class Plot {
* @param owner the plot owner
* @see Plot#getPlot(Location) for existing plots
*/
- public Plot(PlotArea area, @NotNull PlotId id, UUID owner) {
+ public Plot(final PlotArea area, @Nonnull final PlotId id, final UUID owner) {
this(area, id, owner, 0);
}
@@ -209,7 +223,7 @@ public class Plot {
* @param id the plot id
* @see Plot#getPlot(Location) for existing plots
*/
- public Plot(@NotNull PlotArea area, @NotNull PlotId id) {
+ public Plot(@Nonnull final PlotArea area, @Nonnull final PlotId id) {
this(area, id, null, 0);
}
@@ -224,12 +238,13 @@ public class Plot {
* @param temp Represents whatever the database manager needs it to
* @see Plot#getPlot(Location) for existing plots
*/
- public Plot(PlotArea area, @NotNull PlotId id, UUID owner, int temp) {
+ public Plot(final PlotArea area, @Nonnull final PlotId id, final UUID owner, final int temp) {
this.area = area;
this.id = id;
this.owner = owner;
this.temp = temp;
this.flagContainer.setParentContainer(area.getFlagContainer());
+ PlotSquared.platform().getInjector().injectMembers(this);
}
/**
@@ -242,7 +257,7 @@ public class Plot {
* @param merged an array giving merged plots
* @see Plot#getPlot(Location) for existing plots
*/
- public Plot(@NotNull PlotId id, UUID owner, HashSet trusted, HashSet members,
+ public Plot(@Nonnull PlotId id, UUID owner, HashSet trusted, HashSet members,
HashSet denied, String alias, BlockLoc position, Collection> flags,
PlotArea area, boolean[] merged, long timestamp, int temp) {
this.id = id;
@@ -265,6 +280,7 @@ public class Plot {
}
}
}
+ PlotSquared.platform().getInjector().injectMembers(this);
}
/**
@@ -282,13 +298,13 @@ public class Plot {
return defaultArea.getPlotAbs(id);
}
} else if (split.length == 3) {
- PlotArea pa = PlotSquared.get().getPlotArea(split[0], null);
+ PlotArea pa = PlotSquared.get().getPlotAreaManager().getPlotArea(split[0], null);
if (pa != null) {
PlotId id = PlotId.fromString(split[1] + ';' + split[2]);
return pa.getPlotAbs(id);
}
} else if (split.length == 4) {
- PlotArea pa = PlotSquared.get().getPlotArea(split[0], split[1]);
+ PlotArea pa = PlotSquared.get().getPlotAreaManager().getPlotArea(split[0], split[1]);
if (pa != null) {
PlotId id = PlotId.fromString(split[1] + ';' + split[2]);
return pa.getPlotAbs(id);
@@ -405,7 +421,7 @@ public class Plot {
*/
public List> getPlayersInPlot() {
final List> players = new ArrayList<>();
- for (final PlotPlayer> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
+ for (final PlotPlayer> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
if (this.equals(player.getCurrentPlot())) {
players.add(player);
}
@@ -428,7 +444,7 @@ public class Plot {
* @param uuid the player uuid
* @return if the provided uuid is the owner of the plot
*/
- public boolean isOwner(@NotNull UUID uuid) {
+ public boolean isOwner(@Nonnull UUID uuid) {
if (uuid.equals(this.getOwner())) {
return true;
}
@@ -557,7 +573,7 @@ public class Plot {
*
* @return the PlotId for this plot
*/
- @NotNull public PlotId getId() {
+ @Nonnull public PlotId getId() {
return this.id;
}
@@ -929,7 +945,7 @@ public class Plot {
if (isDelete) {
this.removeSign();
}
- PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
+ PlotUnlinkEvent event = this.eventDispatcher
.callUnlink(getArea(), this, true, !isDelete,
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR);
if (event.getEventResult() != Result.DENY) {
@@ -942,7 +958,7 @@ public class Plot {
Runnable run = () -> {
for (CuboidRegion region : regions) {
Location[] corners = MainUtil.getCorners(getWorldName(), region);
- RegionManager.manager.clearAllEntities(corners[0], corners[1]);
+ regionManager.clearAllEntities(corners[0], corners[1]);
}
TaskManager.runTask(whenDone);
};
@@ -953,14 +969,13 @@ public class Plot {
manager.claimPlot(current);
}
}
- GlobalBlockQueue.IMP.addEmptyTask(run);
+ blockQueue.addEmptyTask(run);
return;
}
Plot current = queue.poll();
if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
try {
- RegionManager.manager
- .regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
+ regionManager.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
this);
} catch (UnsupportedOperationException exception) {
MainUtil.sendMessage(null,
@@ -997,7 +1012,7 @@ public class Plot {
return;
}
CuboidRegion region = regions.poll();
- RegionManager.manager.setBiome(region, extendBiome, biome, getWorldName(), this);
+ regionManager.setBiome(region, extendBiome, biome, getWorldName(), this);
}
};
run.run();
@@ -1049,7 +1064,7 @@ public class Plot {
current.setMerged(merged);
}
if (createSign) {
- GlobalBlockQueue.IMP.addEmptyTask(() -> {
+ blockQueue.addEmptyTask(() -> {
TaskManager.runTaskAsync(() -> {
for (Plot current : plots) {
current.setSign(MainUtil.getName(current.getOwnerAbs()));
@@ -1068,7 +1083,7 @@ public class Plot {
*
* @param name name
*/
- public void setSign(@NotNull String name) {
+ public void setSign(@Nonnull String name) {
if (!isLoaded()) {
return;
}
@@ -1084,14 +1099,13 @@ public class Plot {
"%plr%", name),
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
"%plr%", name)};
- WorldUtil.IMP
- .setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
+ this.worldUtil.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
lines);
}
}
public boolean isLoaded() {
- return WorldUtil.IMP.isWorld(getWorldName());
+ return this.worldUtil.isWorld(getWorldName());
}
/**
@@ -1262,7 +1276,7 @@ public class Plot {
public int[] countEntities() {
int[] count = new int[6];
for (Plot current : this.getConnectedPlots()) {
- int[] result = RegionManager.manager.countEntities(current);
+ int[] result = this.regionManager.countEntities(current);
count[CAP_ENTITY] += result[CAP_ENTITY];
count[CAP_ANIMAL] += result[CAP_ANIMAL];
count[CAP_MONSTER] += result[CAP_MONSTER];
@@ -1329,12 +1343,12 @@ public class Plot {
for (Plot current : getConnectedPlots()) {
List> players = current.getPlayersInPlot();
for (PlotPlayer> pp : players) {
- PlotListener.plotExit(pp, current);
+ this.plotListener.plotExit(pp, current);
}
if (Settings.Backup.DELETE_ON_UNCLAIM) {
// Destroy all backups when the plot is unclaimed
- Objects.requireNonNull(PlotSquared.imp()).getBackupManager().getProfile(current)
+ Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(current)
.destroy();
}
@@ -1343,7 +1357,7 @@ public class Plot {
current.setOwnerAbs(null);
current.settings = null;
for (PlotPlayer pp : players) {
- PlotListener.plotEntry(pp, current);
+ this.plotListener.plotEntry(pp, current);
}
}
return true;
@@ -1363,20 +1377,18 @@ public class Plot {
Location[] corners = getCorners();
Location top = corners[0];
Location bot = corners[1];
- Location location =
- new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
+ Location location = Location.at(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
if (!isLoaded()) {
result.accept(location);
return;
}
- WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
+ this.worldUtil.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
int height = y;
if (area.allowSigns()) {
height = Math.max(y, getManager().getSignLoc(this).getY());
}
- location.setY(1 + height);
- result.accept(location);
+ result.accept(location.withY(1 + height));
});
}
@@ -1387,19 +1399,16 @@ public class Plot {
Location[] corners = getCorners();
Location top = corners[0];
Location bot = corners[1];
- Location location =
- new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
- MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
+ Location location = Location.at(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
+ MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
if (!isLoaded()) {
return location;
}
- int y = WorldUtil.IMP
- .getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
+ int y = this.worldUtil.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
if (area.allowSigns()) {
y = Math.max(y, getManager().getSignLoc(this).getY());
}
- location.setY(1 + y);
- return location;
+ return location.withY(1 + y);
}
/**
@@ -1411,11 +1420,11 @@ public class Plot {
+ largest.getMinimumPoint().getX();
int z = largest.getMinimumPoint().getZ() - 1;
PlotManager manager = getManager();
- int y = isLoaded() ? WorldUtil.IMP.getHighestBlockSynchronous(getWorldName(), x, z) : 62;
+ int y = isLoaded() ? this.worldUtil.getHighestBlockSynchronous(getWorldName(), x, z) : 62;
if (area.allowSigns() && (y <= 0 || y >= 255)) {
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
}
- return new Location(getWorldName(), x, y + 1, z);
+ return Location.at(getWorldName(), x, y + 1, z);
}
public void getSide(Consumer result) {
@@ -1425,19 +1434,19 @@ public class Plot {
int z = largest.getMinimumPoint().getZ() - 1;
PlotManager manager = getManager();
if (isLoaded()) {
- WorldUtil.IMP.getHighestBlock(getWorldName(), x, z, y -> {
+ this.worldUtil.getHighestBlock(getWorldName(), x, z, y -> {
int height = y;
if (area.allowSigns() && (y <= 0 || y >= 255)) {
height = Math.max(y, manager.getSignLoc(this).getY() - 1);
}
- result.accept(new Location(getWorldName(), x, height + 1, z));
+ result.accept(Location.at(getWorldName(), x, height + 1, z));
});
} else {
int y = 62;
if (area.allowSigns()) {
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
}
- result.accept(new Location(getWorldName(), x, y + 1, z));
+ result.accept(Location.at(getWorldName(), x, y + 1, z));
}
}
@@ -1450,15 +1459,14 @@ public class Plot {
return this.getDefaultHomeSynchronous(true);
} else {
Location bottom = this.getBottomAbs();
- Location location = new Location(bottom.getWorld(), bottom.getX() + home.getX(),
+ Location location = Location.at(bottom.getWorldName(), bottom.getX() + home.getX(),
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
home.getPitch());
if (!isLoaded()) {
return location;
}
- if (!WorldUtil.IMP.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
- location.setY(Math.max(1 + WorldUtil.IMP
- .getHighestBlockSynchronous(this.getWorldName(), location.getX(),
+ if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
+ location = location.withY(Math.max(1 + this.worldUtil.getHighestBlockSynchronous(this.getWorldName(), location.getX(),
location.getZ()), bottom.getY()));
}
return location;
@@ -1474,21 +1482,17 @@ public class Plot {
this.getDefaultHome(result);
} else {
Location bottom = this.getBottomAbs();
- Location location = new Location(bottom.getWorld(), bottom.getX() + home.getX(),
+ Location location = Location.at(bottom.getWorldName(), bottom.getX() + home.getX(),
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
home.getPitch());
if (!isLoaded()) {
result.accept(location);
return;
}
- WorldUtil.IMP.getBlock(location, block -> {
+ this.worldUtil.getBlock(location, block -> {
if (!block.getBlockType().getMaterial().isAir()) {
- WorldUtil.IMP
- .getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
- y -> {
- location.setY(Math.max(1 + y, bottom.getY()));
- result.accept(location);
- });
+ this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
+ y -> result.accept(location.withY(Math.max(1 + y, bottom.getY()))));
} else {
result.accept(location);
}
@@ -1546,10 +1550,10 @@ public class Plot {
}
int y = loc.getY() < 1 ?
(isLoaded() ?
- WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 :
+ this.worldUtil.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 :
63) :
loc.getY();
- return new Location(plot.getWorldName(), x, y, z);
+ return Location.at(plot.getWorldName(), x, y, z);
}
// Side
return plot.getSideSynchronous();
@@ -1576,13 +1580,13 @@ public class Plot {
}
if (loc.getY() < 1) {
if (isLoaded()) {
- WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z,
- y -> result.accept(new Location(plot.getWorldName(), x, y + 1, z)));
+ this.worldUtil.getHighestBlock(plot.getWorldName(), x, z,
+ y -> result.accept(Location.at(plot.getWorldName(), x, y + 1, z)));
} else {
- result.accept(new Location(plot.getWorldName(), x, 63, z));
+ result.accept(Location.at(plot.getWorldName(), x, 63, z));
}
} else {
- result.accept(new Location(plot.getWorldName(), x, loc.getY(), z));
+ result.accept(Location.at(plot.getWorldName(), x, loc.getY(), z));
}
return;
}
@@ -1679,7 +1683,7 @@ public class Plot {
* This should not need to be called
*/
public void refreshChunks() {
- LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
+ LocalBlockQueue queue = this.blockQueue.getNewQueue(getWorldName(), false);
HashSet chunks = new HashSet<>();
for (CuboidRegion region : Plot.this.getRegions()) {
for (int x = region.getMinimumPoint().getX() >> 4;
@@ -1703,7 +1707,7 @@ public class Plot {
return;
}
Location location = manager.getSignLoc(this);
- LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
+ LocalBlockQueue queue = this.blockQueue.getNewQueue(getWorldName(), false);
queue.setBlock(location.getX(), location.getY(), location.getZ(),
BlockTypes.AIR.getDefaultState());
queue.flush();
@@ -1717,7 +1721,7 @@ public class Plot {
this.setSign("unknown");
return;
}
- PlotSquared.get().getImpromptuUUIDPipeline().getSingle(this.getOwnerAbs(), (username, sign) ->
+ this.impromptuPipeline.getSingle(this.getOwnerAbs(), (username, sign) ->
this.setSign(username));
}
@@ -1733,14 +1737,14 @@ public class Plot {
return this.create(this.owner, true);
}
- public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic) {
+ public boolean claim(@Nonnull final PlotPlayer player, boolean teleport, String schematic) {
if (!canClaim(player)) {
return false;
}
return claim(player, teleport, schematic, true);
}
- public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic,
+ public boolean claim(@Nonnull final PlotPlayer player, boolean teleport, String schematic,
boolean updateDB) {
if (updateDB) {
@@ -1764,18 +1768,18 @@ public class Plot {
Schematic sch;
try {
if (schematic == null || schematic.isEmpty()) {
- sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
+ sch = schematicHandler.getSchematic(plotworld.getSchematicFile());
} else {
- sch = SchematicHandler.manager.getSchematic(schematic);
+ sch = schematicHandler.getSchematic(schematic);
if (sch == null) {
- sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
+ sch = schematicHandler.getSchematic(plotworld.getSchematicFile());
}
}
} catch (SchematicHandler.UnsupportedFormatException e) {
e.printStackTrace();
return true;
}
- SchematicHandler.manager.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP,
+ schematicHandler.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP,
new RunnableVal() {
@Override public void run(Boolean value) {
if (value) {
@@ -1800,7 +1804,7 @@ public class Plot {
* @param notify notify
* @return true if plot was created successfully
*/
- public boolean create(@NotNull UUID uuid, final boolean notify) {
+ public boolean create(@Nonnull UUID uuid, final boolean notify) {
this.setOwnerAbs(uuid);
Plot existing = this.area.getOwnedPlotAbs(this.id);
if (existing != null) {
@@ -1822,8 +1826,8 @@ public class Plot {
DBFunc.createPlotAndSettings(this, () -> {
PlotArea plotworld = Plot.this.area;
if (notify && plotworld.isAutoMerge()) {
- PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
- PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
+ PlotPlayer player = this.worldUtil.wrapPlayer(uuid);
+ PlotMergeEvent event = this.eventDispatcher
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
if (event.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
@@ -1855,8 +1859,8 @@ public class Plot {
* Retrieve the biome of the plot.
*/
public void getBiome(Consumer result) {
- this.getCenter(location -> WorldUtil.IMP
- .getBiome(location.getWorld(), location.getX(), location.getZ(), result));
+ this.getCenter(location -> this.worldUtil
+ .getBiome(location.getWorldName(), location.getX(), location.getZ(), result));
}
/**
@@ -1864,8 +1868,8 @@ public class Plot {
*/
@Deprecated public BiomeType getBiomeSynchronous() {
final Location location = this.getCenterSynchronous();
- return WorldUtil.IMP
- .getBiomeSynchronous(location.getWorld(), location.getX(), location.getZ());
+ return this.worldUtil
+ .getBiomeSynchronous(location.getWorldName(), location.getX(), location.getZ());
}
//TODO Better documentation needed.
@@ -1874,9 +1878,7 @@ public class Plot {
* Returns the top location for the plot.
*/
public Location getTopAbs() {
- Location top = getManager().getPlotTopLocAbs(this.id);
- top.setWorld(getWorldName());
- return top;
+ return this.getManager().getPlotTopLocAbs(this.id).withWorld(this.getWorldName());
}
//TODO Better documentation needed.
@@ -1885,9 +1887,7 @@ public class Plot {
* Returns the bottom location for the plot.
*/
public Location getBottomAbs() {
- Location location = getManager().getPlotBottomLocAbs(this.id);
- location.setWorld(getWorldName());
- return location;
+ return this.getManager().getPlotBottomLocAbs(this.id).withWorld(this.getWorldName());
}
/**
@@ -1962,10 +1962,10 @@ public class Plot {
return top;
}
if (this.getMerged(Direction.SOUTH)) {
- top.setZ(this.getRelative(Direction.SOUTH).getBottomAbs().getZ() - 1);
+ top = top.withZ(this.getRelative(Direction.SOUTH).getBottomAbs().getZ() - 1);
}
if (this.getMerged(Direction.EAST)) {
- top.setX(this.getRelative(Direction.EAST).getBottomAbs().getX() - 1);
+ top = top.withX(this.getRelative(Direction.EAST).getBottomAbs().getX() - 1);
}
return top;
}
@@ -1983,10 +1983,10 @@ public class Plot {
return bot;
}
if (this.getMerged(Direction.NORTH)) {
- bot.setZ(this.getRelative(Direction.NORTH).getTopAbs().getZ() + 1);
+ bot = bot.withZ(this.getRelative(Direction.NORTH).getTopAbs().getZ() + 1);
}
if (this.getMerged(Direction.WEST)) {
- bot.setX(this.getRelative(Direction.WEST).getTopAbs().getX() + 1);
+ bot = bot.withX(this.getRelative(Direction.WEST).getTopAbs().getX() + 1);
}
return bot;
}
@@ -2016,9 +2016,9 @@ public class Plot {
Plot other = this.getRelative(Direction.EAST);
Location bot = other.getBottomAbs();
Location top = this.getTopAbs();
- Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
- Location pos2 = new Location(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
- RegionManager.manager.regenerateRegion(pos1, pos2, true, null);
+ Location pos1 = Location.at(this.getWorldName(), top.getX(), 0, bot.getZ());
+ Location pos2 = Location.at(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
+ this.regionManager.regenerateRegion(pos1, pos2, true, null);
} else if (this.area.getTerrain()
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.area.getPlotManager().removeRoadEast(this);
@@ -2172,7 +2172,7 @@ public class Plot {
* Export the plot as a schematic to the configured output directory.
*/
public void export(final RunnableVal whenDone) {
- SchematicHandler.manager.getCompoundTag(this, new RunnableVal() {
+ this.schematicHandler.getCompoundTag(this, new RunnableVal() {
@Override public void run(final CompoundTag value) {
if (value == null) {
if (whenDone != null) {
@@ -2183,7 +2183,7 @@ public class Plot {
TaskManager.runTaskAsync(() -> {
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil
.getName(Plot.this.getOwnerAbs());
- boolean result = SchematicHandler.manager.save(value,
+ boolean result = schematicHandler.save(value,
Settings.Paths.SCHEMATICS + File.separator + name + ".schem");
if (whenDone != null) {
whenDone.value = result;
@@ -2201,9 +2201,9 @@ public class Plot {
* @param whenDone value will be null if uploading fails
*/
public void upload(final RunnableVal whenDone) {
- SchematicHandler.manager.getCompoundTag(this, new RunnableVal() {
+ this.schematicHandler.getCompoundTag(this, new RunnableVal() {
@Override public void run(CompoundTag value) {
- SchematicHandler.manager.upload(value, null, null, whenDone);
+ schematicHandler.upload(value, null, null, whenDone);
}
});
}
@@ -2217,7 +2217,7 @@ public class Plot {
* @see WorldUtil
*/
public void uploadWorld(RunnableVal whenDone) {
- WorldUtil.IMP.upload(this, null, null, whenDone);
+ this.worldUtil.upload(this, null, null, whenDone);
}
@Override public boolean equals(Object obj) {
@@ -2363,7 +2363,7 @@ public class Plot {
*
* @param player the claiming player
*/
- public boolean canClaim(@NotNull PlotPlayer player) {
+ public boolean canClaim(@Nonnull PlotPlayer player) {
PlotCluster cluster = this.getCluster();
if (cluster != null) {
if (!cluster.isAdded(player.getUUID()) && !Permissions
@@ -2388,9 +2388,9 @@ public class Plot {
Plot other = this.getRelative(Direction.SOUTH);
Location bot = other.getBottomAbs();
Location top = this.getTopAbs();
- Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
- Location pos2 = new Location(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
- RegionManager.manager.regenerateRegion(pos1, pos2, true, null);
+ Location pos1 = Location.at(this.getWorldName(), bot.getX(), 0, top.getZ());
+ Location pos2 = Location.at(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
+ this.regionManager.regenerateRegion(pos1, pos2, true, null);
} else if (this.area.getTerrain()
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.getManager().removeRoadSouth(this);
@@ -2564,11 +2564,9 @@ public class Plot {
if (this.area.getType() != PlotAreaType.NORMAL
&& this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
Plot other = this.getRelative(1, 1);
- Location pos1 = this.getTopAbs().add(1, 0, 1);
- Location pos2 = other.getBottomAbs().subtract(1, 0, 1);
- pos1.setY(0);
- pos2.setY(MAX_HEIGHT);
- RegionManager.manager.regenerateRegion(pos1, pos2, true, null);
+ Location pos1 = this.getTopAbs().add(1, 0, 1).withY(0);
+ Location pos2 = other.getBottomAbs().subtract(1, 0, 1).withY(MAX_HEIGHT);
+ this.regionManager.regenerateRegion(pos1, pos2, true, null);
} else if (this.area.getTerrain()
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.area.getPlotManager().removeRoadSouthEast(this);
@@ -2749,7 +2747,7 @@ public class Plot {
*
* @return
*/
- @NotNull public Set getRegions() {
+ @Nonnull public Set getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
return regions_cache;
}
@@ -2908,13 +2906,13 @@ public class Plot {
public void reEnter() {
TaskManager.runTaskLater(() -> {
for (PlotPlayer> pp : Plot.this.getPlayersInPlot()) {
- PlotListener.plotExit(pp, Plot.this);
- PlotListener.plotEntry(pp, Plot.this);
+ this.plotListener.plotExit(pp, Plot.this);
+ this.plotListener.plotEntry(pp, Plot.this);
}
}, 1);
}
- public void debug(@NotNull final String message) {
+ public void debug(@Nonnull final String message) {
try {
final Collection> players = PlotPlayer.getDebugModePlayersInPlot(this);
if (players.isEmpty()) {
@@ -2952,7 +2950,7 @@ public class Plot {
int x = (int) MathMan.inverseRound(coords[0]);
int z = (int) MathMan.inverseRound(coords[1]);
if (type != 4) {
- locs.add(new Location(this.getWorldName(), x, 0, z));
+ locs.add(Location.at(this.getWorldName(), x, 0, z));
}
}
return locs;
@@ -2979,7 +2977,7 @@ public class Plot {
Consumer resultConsumer) {
Plot plot = this.getBasePlot(false);
Result result =
- PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot)
+ this.eventDispatcher.callTeleport(player, player.getLocation(), plot)
.getEventResult();
if (result == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
@@ -3026,11 +3024,11 @@ public class Plot {
return false;
}
if (!isMerged()) {
- return PlotSquared.imp().getPlayerManager()
+ return PlotSquared.platform().getPlayerManager()
.getPlayerIfExists(Objects.requireNonNull(this.getOwnerAbs())) != null;
}
for (final Plot current : getConnectedPlots()) {
- if (current.hasOwner() && PlotSquared.imp().getPlayerManager()
+ if (current.hasOwner() && PlotSquared.platform().getPlayerManager()
.getPlayerIfExists(Objects.requireNonNull(current.getOwnerAbs())) != null) {
return true;
}
@@ -3049,7 +3047,7 @@ public class Plot {
*/
public boolean setComponent(String component, Pattern blocks) {
PlotComponentSetEvent event =
- PlotSquared.get().getEventDispatcher().callComponentSet(this, component, blocks);
+ this.eventDispatcher.callComponentSet(this, component, blocks);
component = event.getComponent();
blocks = event.getPattern();
return this.getManager().setComponent(this.getId(), component, blocks);
@@ -3216,11 +3214,9 @@ public class Plot {
Location[] corners = MainUtil.getCorners(getWorldName(), region);
Location pos1 = corners[0];
Location pos2 = corners[1];
- Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
- Location pos4 = pos2.clone().add(offsetX, 0, offsetZ);
- pos3.setWorld(destination.getWorldName());
- pos4.setWorld(destination.getWorldName());
- RegionManager.manager.swap(pos1, pos2, pos3, pos4, this);
+ Location pos3 = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
+ Location pos4 = pos2.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
+ regionManager.swap(pos1, pos2, pos3, pos4, this);
}
}
}.run();
@@ -3250,9 +3246,8 @@ public class Plot {
Location[] corners = MainUtil.getCorners(getWorldName(), region);
final Location pos1 = corners[0];
final Location pos2 = corners[1];
- Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
- newPos.setWorld(destination.getWorldName());
- RegionManager.manager.copyRegion(pos1, pos2, newPos, task);
+ Location newPos = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
+ regionManager.copyRegion(pos1, pos2, newPos, task);
}
}.run();
}
@@ -3345,9 +3340,8 @@ public class Plot {
Location[] corners = MainUtil.getCorners(getWorldName(), region);
Location pos1 = corners[0];
Location pos2 = corners[1];
- Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
- newPos.setWorld(destination.getWorldName());
- RegionManager.manager.copyRegion(pos1, pos2, newPos, this);
+ Location newPos = pos1 .add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
+ regionManager.copyRegion(pos1, pos2, newPos, this);
}
};
run.run();
diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
index 25230ab89..9ad26c0aa 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
@@ -35,8 +35,10 @@ 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.inject.annotations.WorldConfig;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc;
@@ -64,8 +66,8 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,13 +92,13 @@ public abstract class PlotArea {
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotArea.class.getSimpleName());
protected final ConcurrentHashMap plots = new ConcurrentHashMap<>();
- @Getter @NotNull private final String worldName;
+ @Getter @Nonnull private final String worldName;
@Getter private final String id;
- @Getter @NotNull private final PlotManager plotManager;
+ @Getter @Nonnull private final PlotManager plotManager;
@Getter private final int worldHash;
private final PlotId min;
private final PlotId max;
- @Getter @NotNull private final IndependentPlotGenerator generator;
+ @Getter @Nonnull private final IndependentPlotGenerator generator;
@Getter private int maxPlotMembers = 128;
@Getter private boolean autoMerge = false;
@Setter private boolean allowSigns = true;
@@ -137,13 +139,21 @@ public abstract class PlotArea {
@Getter private final FlagContainer roadFlagContainer =
new FlagContainer(GlobalFlagContainer.getInstance());
- public PlotArea(@NotNull final String worldName, @Nullable final String id,
- @NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
- @Nullable final PlotId max) {
+ private final YamlConfiguration worldConfiguration;
+ private final GlobalBlockQueue globalBlockQueue;
+ private final EconHandler econHandler;
+
+ public PlotArea(@Nonnull final String worldName, @Nullable final String id,
+ @Nonnull IndependentPlotGenerator generator, @Nullable final PlotId min,
+ @Nullable final PlotId max,
+ @WorldConfig @Nullable final YamlConfiguration worldConfiguration,
+ @Nonnull final GlobalBlockQueue blockQueue,
+ @Nullable final EconHandler econHandler) {
this.worldName = worldName;
this.id = id;
this.plotManager = createManager();
this.generator = generator;
+ this.globalBlockQueue = blockQueue;
if (min == null || max == null) {
if (min != max) {
throw new IllegalArgumentException(
@@ -156,12 +166,14 @@ public abstract class PlotArea {
this.max = max;
}
this.worldHash = worldName.hashCode();
+ this.worldConfiguration = worldConfiguration;
+ this.econHandler = econHandler;
}
- @NotNull protected abstract PlotManager createManager();
+ @Nonnull protected abstract PlotManager createManager();
public LocalBlockQueue getQueue(final boolean autoQueue) {
- return GlobalBlockQueue.IMP.getNewQueue(worldName, autoQueue);
+ return this.globalBlockQueue.getNewQueue(worldName, autoQueue);
}
/**
@@ -238,8 +250,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(@Nonnull 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
@@ -280,7 +292,7 @@ public abstract class PlotArea {
this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim");
this.schematics = new ArrayList<>(config.getStringList("schematic.schematics"));
this.schematics.replaceAll(String::toLowerCase);
- this.useEconomy = config.getBoolean("economy.use") && EconHandler.getEconHandler() != null;
+ this.useEconomy = config.getBoolean("economy.use") && this.econHandler != null;
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
if (this.useEconomy) {
this.prices = new HashMap<>();
@@ -481,7 +493,7 @@ public abstract class PlotArea {
}
}
- @NotNull @Override public String toString() {
+ @Nonnull @Override public String toString() {
if (this.getId() == null) {
return this.getWorldName();
} else {
@@ -509,7 +521,7 @@ public abstract class PlotArea {
* @param location the location
* @return the {@code Plot} or null if none exists
*/
- @Nullable public Plot getPlotAbs(@NotNull final Location location) {
+ @Nullable public Plot getPlotAbs(@Nonnull final Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@@ -524,7 +536,7 @@ public abstract class PlotArea {
* @param location the location
* @return base Plot
*/
- @Nullable public Plot getPlot(@NotNull final Location location) {
+ @Nullable public Plot getPlot(@Nonnull final Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@@ -539,7 +551,7 @@ public abstract class PlotArea {
* @param location the location
* @return the base plot or null
*/
- @Nullable public Plot getOwnedPlot(@NotNull final Location location) {
+ @Nullable public Plot getOwnedPlot(@Nonnull final Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@@ -555,7 +567,7 @@ public abstract class PlotArea {
* @param location the location
* @return Plot or null
*/
- @Nullable public Plot getOwnedPlotAbs(@NotNull final Location location) {
+ @Nullable public Plot getOwnedPlotAbs(@Nonnull final Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
if (pid == null) {
@@ -570,11 +582,11 @@ public abstract class PlotArea {
* @param id the {@code PlotId}
* @return the plot or null
*/
- @Nullable public Plot getOwnedPlotAbs(@NotNull final PlotId id) {
+ @Nullable public Plot getOwnedPlotAbs(@Nonnull final PlotId id) {
return this.plots.get(id);
}
- @Nullable public Plot getOwnedPlot(@NotNull final PlotId id) {
+ @Nullable public Plot getOwnedPlot(@Nonnull final PlotId id) {
Plot plot = this.plots.get(id);
return plot == null ? null : plot.getBasePlot(false);
}
@@ -583,17 +595,17 @@ public abstract class PlotArea {
return this.getType() != PlotAreaType.PARTIAL || RegionUtil.contains(getRegionAbs(), x, z);
}
- public boolean contains(@NotNull final PlotId id) {
+ public boolean contains(@Nonnull final PlotId id) {
return this.min == null || (id.x >= this.min.x && id.x <= this.max.x && id.y >= this.min.y
&& id.y <= this.max.y);
}
- public boolean contains(@NotNull final Location location) {
- return StringMan.isEqual(location.getWorld(), this.getWorldName()) && (
+ public boolean contains(@Nonnull final Location location) {
+ return StringMan.isEqual(location.getWorldName(), this.getWorldName()) && (
getRegionAbs() == null || this.region.contains(location.getBlockVector3()));
}
- @NotNull public Set getPlotsAbs(final UUID uuid) {
+ @Nonnull public Set getPlotsAbs(final UUID uuid) {
if (uuid == null) {
return Collections.emptySet();
}
@@ -606,7 +618,7 @@ public abstract class PlotArea {
return myPlots;
}
- @NotNull public Set getPlots(@NotNull final UUID uuid) {
+ @Nonnull public Set getPlots(@Nonnull final UUID uuid) {
return getPlots().stream().filter(plot -> plot.isBasePlot() && plot.isOwner(uuid))
.collect(ImmutableSet.toImmutableSet());
}
@@ -620,7 +632,7 @@ public abstract class PlotArea {
return this.plots.values();
}
- public int getPlotCount(@NotNull final UUID uuid) {
+ public int getPlotCount(@Nonnull final UUID uuid) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
return (int) getPlotsAbs(uuid).stream().filter(plot -> !DoneFlag.isDone(plot)).count();
}
@@ -632,21 +644,21 @@ public abstract class PlotArea {
*
* @deprecated Use {@link #getPlots(UUID)}
*/
- @Deprecated public Set getPlots(@NotNull final PlotPlayer player) {
+ @Deprecated public Set getPlots(@Nonnull final PlotPlayer player) {
return getPlots(player.getUUID());
}
- public boolean hasPlot(@NotNull final UUID uuid) {
+ public boolean hasPlot(@Nonnull final UUID uuid) {
return this.plots.entrySet().stream().anyMatch(entry -> entry.getValue().isOwner(uuid));
}
//todo check if this method is needed in this class
- public int getPlotCount(@Nullable final PlotPlayer player) {
+ public int getPlotCount(@Nullable final PlotPlayer> player) {
return player != null ? getPlotCount(player.getUUID()) : 0;
}
- @Nullable public Plot getPlotAbs(@NotNull final PlotId id) {
+ @Nullable public Plot getPlotAbs(@Nonnull final PlotId id) {
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
@@ -658,7 +670,7 @@ public abstract class PlotArea {
return plot;
}
- @Nullable public Plot getPlot(@NotNull final PlotId id) {
+ @Nullable public Plot getPlot(@Nonnull final PlotId id) {
final Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
if (this.min != null && (id.x < this.min.x || id.x > this.max.x || id.y < this.min.y
@@ -679,7 +691,7 @@ public abstract class PlotArea {
return this.plots.size();
}
- @Nullable public PlotCluster getCluster(@NotNull final Location location) {
+ @Nullable public PlotCluster getCluster(@Nonnull final Location location) {
final Plot plot = getPlot(location);
if (plot == null) {
return null;
@@ -688,8 +700,8 @@ public abstract class PlotArea {
}
@Nullable
- public PlotCluster getFirstIntersectingCluster(@NotNull final PlotId pos1,
- @NotNull final PlotId pos2) {
+ public PlotCluster getFirstIntersectingCluster(@Nonnull final PlotId pos1,
+ @Nonnull final PlotId pos2) {
if (this.clusters == null) {
return null;
}
@@ -701,7 +713,7 @@ public abstract class PlotArea {
return null;
}
- @Nullable PlotCluster getCluster(@NotNull final PlotId id) {
+ @Nullable PlotCluster getCluster(@Nonnull final PlotId id) {
return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
}
@@ -710,14 +722,14 @@ public abstract class PlotArea {
*
* For persistent metadata use the flag system
*/
- public void setMeta(@NotNull final String key, @Nullable final Object value) {
+ public void setMeta(@Nonnull final String key, @Nullable final Object value) {
if (this.meta == null) {
this.meta = new ConcurrentHashMap<>();
}
this.meta.put(key, value);
}
- @NotNull public T getMeta(@NotNull final String key, @NotNull final T def) {
+ @Nonnull public T getMeta(@Nonnull final String key, @Nonnull final T def) {
final Object v = getMeta(key);
return v == null ? def : (T) v;
}
@@ -727,14 +739,14 @@ public abstract class PlotArea {
*
* For persistent metadata use the flag system
*/
- @Nullable public Object getMeta(@NotNull final String key) {
+ @Nullable public Object getMeta(@Nonnull final String key) {
if (this.meta != null) {
return this.meta.get(key);
}
return null;
}
- @SuppressWarnings("unused") @NotNull public Set getBasePlots() {
+ @SuppressWarnings("unused") @Nonnull public Set getBasePlots() {
final HashSet myPlots = new HashSet<>(getPlots());
myPlots.removeIf(plot -> !plot.isBasePlot());
return myPlots;
@@ -767,15 +779,15 @@ public abstract class PlotArea {
* @deprecated Use {@link #getPlotsMap()}
*/
//todo eventually remove
- @Deprecated @NotNull public Map getPlotsRaw() {
+ @Deprecated @Nonnull public Map getPlotsRaw() {
return ImmutableMap.copyOf(plots);
}
- @NotNull public Set> getPlotEntries() {
+ @Nonnull public Set> getPlotEntries() {
return this.plots.entrySet();
}
- public boolean addPlot(@NotNull final Plot plot) {
+ public boolean addPlot(@Nonnull final Plot plot) {
for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta(PlotPlayer.META_LAST_PLOT, plot);
}
@@ -813,7 +825,7 @@ public abstract class PlotArea {
return null;
}
- public boolean addPlotIfAbsent(@NotNull final Plot plot) {
+ public boolean addPlotIfAbsent(@Nonnull final Plot plot) {
if (this.plots.putIfAbsent(plot.getId(), plot) == null) {
for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta(PlotPlayer.META_LAST_PLOT, plot);
@@ -823,7 +835,7 @@ public abstract class PlotArea {
return false;
}
- public boolean addPlotAbs(@NotNull final Plot plot) {
+ public boolean addPlotAbs(@Nonnull final Plot plot) {
return this.plots.put(plot.getId(), plot) == null;
}
@@ -868,14 +880,14 @@ public abstract class PlotArea {
*
* @param key Meta data key
*/
- public void deleteMeta(@NotNull final String key) {
+ public void deleteMeta(@Nonnull final String key) {
if (this.meta != null) {
this.meta.remove(key);
}
}
- public boolean canClaim(@Nullable final PlotPlayer player, @NotNull final PlotId pos1,
- @NotNull final PlotId pos2) {
+ public boolean canClaim(@Nullable final PlotPlayer player, @Nonnull final PlotId pos1,
+ @Nonnull final PlotId pos2) {
if (pos1.x == pos2.x && pos1.y == pos2.y) {
if (getOwnedPlot(pos1) != null) {
return false;
@@ -901,11 +913,11 @@ public abstract class PlotArea {
return true;
}
- public boolean removePlot(@NotNull final PlotId id) {
+ public boolean removePlot(@Nonnull final PlotId id) {
return this.plots.remove(id) != null;
}
- public boolean mergePlots(@NotNull final List plotIds, final boolean removeRoads) {
+ public boolean mergePlots(@Nonnull final List plotIds, final boolean removeRoads) {
if (plotIds.size() < 2) {
return false;
}
@@ -978,7 +990,7 @@ public abstract class PlotArea {
* @param pos2 second corner of selection
* @return the plots in the selection which are owned
*/
- public Set getPlotSelectionOwned(@NotNull final PlotId pos1, @NotNull final PlotId pos2) {
+ public Set getPlotSelectionOwned(@Nonnull final PlotId pos1, @Nonnull final PlotId pos2) {
final int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
final Set result = new HashSet<>();
if (size < 16 || size < getPlotCount()) {
@@ -1040,7 +1052,7 @@ public abstract class PlotArea {
* @param schematic the schematic to look for.
* @return true if the schematic exists, false otherwise.
*/
- public boolean hasSchematic(@NotNull String schematic) {
+ public boolean hasSchematic(@Nonnull String schematic) {
return getSchematics().contains(schematic.toLowerCase());
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotCluster.java b/Core/src/main/java/com/plotsquared/core/plot/PlotCluster.java
index c9de0e90c..ea7484129 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotCluster.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotCluster.java
@@ -31,6 +31,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
+import javax.annotation.Nonnull;
import java.util.HashSet;
import java.util.UUID;
@@ -151,17 +152,17 @@ public class PlotCluster {
+ this.pos2.y;
}
- public void getHome(Consumer result) {
- BlockLoc home = this.settings.getPosition();
- Consumer locationConsumer = toReturn -> {
+ public void getHome(@Nonnull final Consumer result) {
+ final BlockLoc home = this.settings.getPosition();
+ Consumer locationConsumer = toReturn ->
MainUtil.getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(),
max -> {
if (max > toReturn.getY()) {
- toReturn.setY(1 + max);
+ result.accept(toReturn.withY(1 + max));
+ } else {
+ result.accept(toReturn);
}
- result.accept(toReturn);
- });
- };
+ });
if (home.getY() == 0) {
// default pos
Plot center = getCenterPlot();
@@ -170,7 +171,7 @@ public class PlotCluster {
if (toReturn.getY() == 0) {
PlotManager manager = this.area.getPlotManager();
Location locationSign = manager.getSignLoc(center);
- toReturn.setY(locationSign.getY());
+ toReturn = toReturn.withY(locationSign.getY());
}
locationConsumer.accept(toReturn);
});
diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java
index 41016da1f..3327c1473 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java
@@ -26,8 +26,8 @@
package com.plotsquared.core.plot;
import com.plotsquared.core.location.Direction;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
public class PlotId {
@@ -53,14 +53,14 @@ public class PlotId {
* @return the PlotId representation of the arguement
* @throws IllegalArgumentException if the string does not contain a valid PlotId
*/
- @NotNull public static PlotId fromString(@NotNull String string) {
+ @Nonnull public static PlotId fromString(@Nonnull String string) {
PlotId plot = fromStringOrNull(string);
if (plot == null)
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
return plot;
}
- @Nullable public static PlotId fromStringOrNull(@NotNull String string) {
+ @Nullable public static PlotId fromStringOrNull(@Nonnull String string) {
String[] parts = string.split("[;,.]");
if (parts.length < 2) {
return null;
diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java
index 814aba558..a810093b0 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java
@@ -27,7 +27,8 @@ package com.plotsquared.core.plot;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.InventoryUtil;
-import lombok.NonNull;
+
+import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,35 +42,31 @@ public class PlotInventory {
private final PlotItemStack[] items;
private String title;
private boolean open = false;
+ private final InventoryUtil inventoryUtil;
- public PlotInventory(PlotPlayer> player) {
- this.size = 4;
- this.title = null;
- this.player = player;
- this.items = InventoryUtil.manager.getItems(player);
- }
-
- public PlotInventory(PlotPlayer> player, int size, String name) {
+ public PlotInventory(@Nonnull final InventoryUtil inventoryUtil,
+ PlotPlayer> player, int size, String name) {
this.size = size;
this.title = name == null ? "" : name;
this.player = player;
this.items = new PlotItemStack[size * 9];
+ this.inventoryUtil = inventoryUtil;
}
- public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer> plotPlayer) {
+ public static boolean hasPlotInventoryOpen(@Nonnull final PlotPlayer> plotPlayer) {
return getOpenPlotInventory(plotPlayer) != null;
}
- public static PlotInventory getOpenPlotInventory(@NonNull final PlotPlayer> plotPlayer) {
+ public static PlotInventory getOpenPlotInventory(@Nonnull final PlotPlayer> plotPlayer) {
return plotPlayer.getMeta(META_KEY, null);
}
- public static void setPlotInventoryOpen(@NonNull final PlotPlayer> plotPlayer,
- @NonNull final PlotInventory plotInventory) {
+ public static void setPlotInventoryOpen(@Nonnull final PlotPlayer> plotPlayer,
+ @Nonnull final PlotInventory plotInventory) {
plotPlayer.setMeta(META_KEY, plotInventory);
}
- public static void removePlotInventoryOpen(@NonNull final PlotPlayer>plotPlayer) {
+ public static void removePlotInventoryOpen(@Nonnull final PlotPlayer>plotPlayer) {
plotPlayer.deleteMeta(META_KEY);
}
@@ -84,7 +81,7 @@ public class PlotInventory {
if (!hasPlotInventoryOpen(player)) {
this.open = true;
setPlotInventoryOpen(player, this);
- InventoryUtil.manager.open(this);
+ this.inventoryUtil.open(this);
}
}
@@ -93,13 +90,13 @@ public class PlotInventory {
return;
}
removePlotInventoryOpen(player);
- InventoryUtil.manager.close(this);
+ this.inventoryUtil.close(this);
this.open = false;
}
public void setItem(int index, PlotItemStack item) {
this.items[index] = item;
- InventoryUtil.manager.setItem(this, index, item);
+ this.inventoryUtil.setItem(this, index, item);
}
public PlotItemStack getItem(int index) {
diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java b/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java
index ed7b854c2..76f9d4c9f 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java
@@ -28,8 +28,8 @@ package com.plotsquared.core.plot;
import com.plotsquared.core.location.Location;
import com.sk89q.worldedit.regions.CuboidRegion;
import lombok.EqualsAndHashCode;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Collection;
@@ -46,7 +46,7 @@ public abstract class PlotWorld {
*
* @param world World name
*/
- protected PlotWorld(@NotNull final String world) {
+ protected PlotWorld(@Nonnull final String world) {
this.world = world;
}
@@ -57,14 +57,14 @@ public abstract class PlotWorld {
* @param location Location
* @return Containing plot area, or null
*/
- @Nullable public abstract PlotArea getArea(@NotNull final Location location);
+ @Nullable public abstract PlotArea getArea(@Nonnull final Location location);
/**
* Get all plot areas in the world
*
* @return All plot areas in the world
*/
- @NotNull public abstract Collection getAreas();
+ @Nonnull public abstract Collection getAreas();
/**
* Get all plot areas in a specified region
@@ -72,15 +72,15 @@ public abstract class PlotWorld {
* @param region Region
* @return All areas in the region
*/
- @NotNull public abstract Collection getAreasInRegion(
- @NotNull final CuboidRegion region);
+ @Nonnull public abstract Collection getAreasInRegion(
+ @Nonnull final CuboidRegion region);
/**
* Register a new area in the world
*
* @param area Plot area
*/
- public void addArea(@NotNull final PlotArea area) {
+ public void addArea(@Nonnull final PlotArea area) {
throw new UnsupportedOperationException("This world type does not allow adding new areas");
}
@@ -89,7 +89,7 @@ public abstract class PlotWorld {
*
* @param area Plot area
*/
- public void removeArea(@NotNull final PlotArea area) {
+ public void removeArea(@Nonnull final PlotArea area) {
throw new UnsupportedOperationException("This world type does not allow removing areas");
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java
index b697db52c..e805ff87a 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java
@@ -31,7 +31,6 @@ import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result;
-import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
@@ -42,12 +41,16 @@ import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
import com.plotsquared.core.plot.message.PlotMessage;
+import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil;
+import com.plotsquared.core.util.StringMan;
+import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
import java.util.ArrayDeque;
import java.util.ArrayList;
@@ -67,17 +70,20 @@ public class ExpireManager {
public static ExpireManager IMP;
private final ConcurrentHashMap dates_cache;
private final ConcurrentHashMap account_age_cache;
+ private final EventDispatcher eventDispatcher;
private volatile HashSet plotsToDelete;
private ArrayDeque tasks;
+
/**
* 0 = stopped, 1 = stopping, 2 = running
*/
private int running;
- public ExpireManager() {
- tasks = new ArrayDeque<>();
- dates_cache = new ConcurrentHashMap<>();
- account_age_cache = new ConcurrentHashMap<>();
+ public ExpireManager(@Nonnull final EventDispatcher eventDispatcher) {
+ this.tasks = new ArrayDeque<>();
+ this.dates_cache = new ConcurrentHashMap<>();
+ this.account_age_cache = new ConcurrentHashMap<>();
+ this.eventDispatcher = eventDispatcher;
}
public void addTask(ExpiryTask task) {
@@ -296,7 +302,7 @@ public class ExpireManager {
}
this.running = 2;
final ConcurrentLinkedDeque plots =
- new ConcurrentLinkedDeque<>(PlotSquared.get().getPlots());
+ new ConcurrentLinkedDeque<>(PlotQuery.newQuery().allPlots().asList());
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
final Runnable task = this;
@@ -320,7 +326,7 @@ public class ExpireManager {
}
for (ExpiryTask expiryTask : expired) {
if (!expiryTask.needsAnalysis()) {
- expiredTask.run(newPlot, () -> TaskManager.IMP.taskLaterAsync(task, 1),
+ expiredTask.run(newPlot, () -> TaskManager.getImplementation().taskLaterAsync(task, 1),
expiryTask.requiresConfirmation());
return;
}
@@ -331,7 +337,7 @@ public class ExpireManager {
passesComplexity(changed, expired, new RunnableVal() {
@Override public void run(Boolean confirmation) {
expiredTask.run(newPlot,
- () -> TaskManager.IMP.taskLaterAsync(task, 1),
+ () -> TaskManager.getImplementation().taskLaterAsync(task, 1),
confirmation);
}
}, () -> {
@@ -349,7 +355,7 @@ public class ExpireManager {
}
};
final Runnable doAnalysis =
- () -> HybridUtils.manager.analyzePlot(newPlot, handleAnalysis);
+ () -> PlotSquared.platform().getHybridUtils().analyzePlot(newPlot, handleAnalysis);
PlotAnalysis analysis = newPlot.getComplexity(null);
if (analysis != null) {
@@ -357,7 +363,7 @@ public class ExpireManager {
@Override public void run(Boolean value) {
doAnalysis.run();
}
- }, () -> TaskManager.IMP.taskLaterAsync(task, 1));
+ }, () -> TaskManager.getImplementation().taskLaterAsync(task, 1));
} else {
doAnalysis.run();
}
@@ -402,7 +408,7 @@ public class ExpireManager {
public void deleteWithMessage(Plot plot, Runnable whenDone) {
if (plot.isMerged()) {
- PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
+ PlotUnlinkEvent event = this.eventDispatcher
.callUnlink(plot.getArea(), plot, true, false,
PlotUnlinkEvent.REASON.EXPIRE_DELETE);
if (event.getEventResult() != Result.DENY) {
@@ -410,13 +416,13 @@ public class ExpireManager {
}
}
for (UUID helper : plot.getTrusted()) {
- PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(helper);
+ PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
if (player != null) {
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
}
}
for (UUID helper : plot.getMembers()) {
- PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(helper);
+ PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
if (player != null) {
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
}
@@ -425,12 +431,12 @@ public class ExpireManager {
}
public long getAge(UUID uuid) {
- if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid) != null) {
+ if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid) != null) {
return 0;
}
Long last = this.dates_cache.get(uuid);
if (last == null) {
- OfflinePlotPlayer opp = PlotSquared.imp().getPlayerManager().getOfflinePlayer(uuid);
+ OfflinePlotPlayer opp = PlotSquared.platform().getPlayerManager().getOfflinePlayer(uuid);
if (opp != null && (last = opp.getLastPlayed()) != 0) {
this.dates_cache.put(uuid, last);
} else {
@@ -445,7 +451,7 @@ public class ExpireManager {
public long getAge(Plot plot) {
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
- || PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
+ || PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
return 0;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpiryTask.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpiryTask.java
index a7cd1b86b..022a3dc93 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpiryTask.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpiryTask.java
@@ -25,25 +25,31 @@
*/
package com.plotsquared.core.plot.expiration;
-import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
-import com.plotsquared.core.plot.PlotFilter;
+import com.plotsquared.core.plot.world.PlotAreaManager;
+import com.plotsquared.core.util.query.PlotQuery;
+import javax.annotation.Nonnull;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class ExpiryTask {
+
private final Settings.Auto_Clear settings;
+ private final PlotAreaManager plotAreaManager;
private long cutoffThreshold = Long.MIN_VALUE;
-
- public ExpiryTask(Settings.Auto_Clear settings) {
+
+ public ExpiryTask(final Settings.Auto_Clear settings, @Nonnull final PlotAreaManager plotAreaManager) {
this.settings = settings;
+ this.plotAreaManager = plotAreaManager;
}
public Settings.Auto_Clear getSettings() {
@@ -119,11 +125,13 @@ public class ExpiryTask {
}
public Set getPlotsToCheck() {
- return PlotSquared.get().getPlots(new PlotFilter() {
- @Override public boolean allowsArea(PlotArea area) {
- return ExpiryTask.this.allowsArea(area);
+ final Collection areas = new LinkedList<>();
+ for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) {
+ if (this.allowsArea(plotArea)) {
+ areas.add(plotArea);
}
- });
+ }
+ return PlotQuery.newQuery().inAreas(areas).asSet();
}
public boolean applies(long diff) {
diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java
index 0cfa1e1d9..49a202fcb 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java
@@ -31,6 +31,7 @@ import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.util.MathMan;
+import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import org.slf4j.Logger;
@@ -84,7 +85,7 @@ public class PlotAnalysis {
}
public static void analyzePlot(Plot plot, RunnableVal whenDone) {
- HybridUtils.manager.analyzePlot(plot, whenDone);
+ PlotSquared.platform().getInjector().getInstance(HybridUtils.class).analyzePlot(plot, whenDone);
}
/**
@@ -109,7 +110,7 @@ public class PlotAnalysis {
return;
}
running = true;
- final ArrayList plots = new ArrayList<>(PlotSquared.get().getPlots());
+ final List plots = PlotQuery.newQuery().allPlots().asList();
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
Iterator iterator = plots.iterator();
@@ -450,7 +451,7 @@ public class PlotAnalysis {
logger.info("[P2] Saving calibration");
}
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
- Settings.save(PlotSquared.get().worldsFile);
+ Settings.save(PlotSquared.get().getWorldsFile());
running = false;
for (Plot plot : plots) {
plot.removeRunning();
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java
index 871cf48c7..b93d912c1 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java
@@ -29,10 +29,10 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import lombok.EqualsAndHashCode;
import lombok.Setter;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
@@ -285,7 +285,7 @@ import java.util.Map;
* @param plotFlagUpdateHandler The update handler which will react to changes.
* @see PlotFlagUpdateType Plot flag update types
*/
- public void subscribe(@NotNull final PlotFlagUpdateHandler plotFlagUpdateHandler) {
+ public void subscribe(@Nonnull final PlotFlagUpdateHandler plotFlagUpdateHandler) {
this.updateSubscribers.add(plotFlagUpdateHandler);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java
index af3306b25..1007726df 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java
@@ -29,7 +29,7 @@ import com.google.common.base.Preconditions;
import com.plotsquared.core.configuration.Caption;
import com.plotsquared.core.configuration.Captions;
import lombok.EqualsAndHashCode;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Collections;
@@ -55,8 +55,8 @@ import java.util.Collections;
* @param flagCategory The flag category
* @param flagDescription A caption describing the flag functionality
*/
- protected PlotFlag(@NotNull final T value, @NotNull final Caption flagCategory,
- @NotNull final Caption flagDescription) {
+ protected PlotFlag(@Nonnull final T value, @Nonnull final Caption flagCategory,
+ @Nonnull final Caption flagDescription) {
this.value = Preconditions.checkNotNull(value, "flag value may not be null");
this.flagCategory =
Preconditions.checkNotNull(flagCategory, "flag category may not be null");
@@ -82,7 +82,7 @@ import java.util.Collections;
*
* @return Non-nullable flag value
*/
- @NotNull public final T getValue() {
+ @Nonnull public final T getValue() {
return this.value;
}
@@ -95,7 +95,7 @@ import java.util.Collections;
* @return Parsed value, if valid.
* @throws FlagParseException If the value could not be parsed.
*/
- public abstract F parse(@NotNull final String input) throws FlagParseException;
+ public abstract F parse(@Nonnull final String input) throws FlagParseException;
/**
* Merge this flag's value with another value and return an instance
@@ -104,7 +104,7 @@ import java.util.Collections;
* @param newValue New flag value.
* @return Flag containing parsed flag value.
*/
- public abstract F merge(@NotNull final T newValue);
+ public abstract F merge(@Nonnull final T newValue);
/**
* Returns a string representation of the flag instance, that when
@@ -154,7 +154,7 @@ import java.util.Collections;
*/
public abstract String getExample();
- protected abstract F flagOf(@NotNull T value);
+ protected abstract F flagOf(@Nonnull T value);
/**
* Create a new instance of the flag using a provided
@@ -163,7 +163,7 @@ import java.util.Collections;
* @param value The flag value
* @return The created flag instance
*/
- public final F createFlagInstance(@NotNull final T value) {
+ public final F createFlagInstance(@Nonnull final T value) {
return flagOf(Preconditions.checkNotNull(value));
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnalysisFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnalysisFlag.java
index 133f56df9..173d8caf2 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnalysisFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnalysisFlag.java
@@ -29,7 +29,7 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.InternalFlag;
import com.plotsquared.core.plot.flag.types.ListFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
@@ -40,7 +40,7 @@ public class AnalysisFlag extends ListFlag implements Int
super(valueList, Captions.NONE, Captions.NONE);
}
- @Override public AnalysisFlag parse(@NotNull String input) throws FlagParseException {
+ @Override public AnalysisFlag parse(@Nonnull String input) throws FlagParseException {
final String[] split = input.split(",");
final List numbers = new ArrayList<>();
for (final String element : split) {
@@ -53,7 +53,7 @@ public class AnalysisFlag extends ListFlag implements Int
return "";
}
- @Override protected AnalysisFlag flagOf(@NotNull List value) {
+ @Override protected AnalysisFlag flagOf(@Nonnull List value) {
return new AnalysisFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalAttackFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalAttackFlag.java
index 1ae0abc12..8eb750aa7 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalAttackFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalAttackFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class AnimalAttackFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class AnimalAttackFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_ANIMAL_ATTACK);
}
- @Override protected AnimalAttackFlag flagOf(@NotNull Boolean value) {
+ @Override protected AnimalAttackFlag flagOf(@Nonnull Boolean value) {
return value ? ANIMAL_ATTACK_TRUE : ANIMAL_ATTACK_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalCapFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalCapFlag.java
index 228ea94aa..78bdf65b2 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalCapFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalCapFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.NonNegativeIntegerFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class AnimalCapFlag extends NonNegativeIntegerFlag {
public static final AnimalCapFlag ANIMAL_CAP_UNLIMITED = new AnimalCapFlag(Integer.MAX_VALUE);
@@ -36,7 +36,7 @@ public class AnimalCapFlag extends NonNegativeIntegerFlag {
super(value, Captions.FLAG_DESCRIPTION_ANIMAL_CAP);
}
- @Override protected AnimalCapFlag flagOf(@NotNull Integer value) {
+ @Override protected AnimalCapFlag flagOf(@Nonnull Integer value) {
return new AnimalCapFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalInteractFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalInteractFlag.java
index f19a479d3..00c854f88 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalInteractFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/AnimalInteractFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class AnimalInteractFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class AnimalInteractFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_ANIMAL_INTERACT);
}
- @Override protected AnimalInteractFlag flagOf(@NotNull Boolean value) {
+ @Override protected AnimalInteractFlag flagOf(@Nonnull Boolean value) {
return value ? ANIMAL_INTERACT_TRUE : ANIMAL_INTERACT_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockBurnFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockBurnFlag.java
index ac50b91b3..202513067 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockBurnFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockBurnFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class BlockBurnFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class BlockBurnFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_BLOCK_BURN);
}
- @Override protected BlockBurnFlag flagOf(@NotNull Boolean value) {
+ @Override protected BlockBurnFlag flagOf(@Nonnull Boolean value) {
return value ? BLOCK_BURN_TRUE : BLOCK_BURN_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockIgnitionFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockIgnitionFlag.java
index 4a2b7e205..add18aebf 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockIgnitionFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockIgnitionFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class BlockIgnitionFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class BlockIgnitionFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_BLOCK_IGNITION);
}
- @Override protected BlockIgnitionFlag flagOf(@NotNull Boolean value) {
+ @Override protected BlockIgnitionFlag flagOf(@Nonnull Boolean value) {
return value ? BLOCK_IGNITION_TRUE : BLOCK_IGNITION_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockedCmdsFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockedCmdsFlag.java
index d5b3eeca6..1bcdb39c2 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockedCmdsFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BlockedCmdsFlag.java
@@ -28,7 +28,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.types.ListFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
@@ -44,7 +44,7 @@ public class BlockedCmdsFlag extends ListFlag {
Captions.FLAG_DESCRIPTION_BLOCKED_CMDS);
}
- @Override public BlockedCmdsFlag parse(@NotNull String input) throws FlagParseException {
+ @Override public BlockedCmdsFlag parse(@Nonnull String input) throws FlagParseException {
return flagOf(Arrays.asList(input.split(",")));
}
@@ -52,7 +52,7 @@ public class BlockedCmdsFlag extends ListFlag {
return "gamemode survival, spawn";
}
- @Override protected BlockedCmdsFlag flagOf(@NotNull List value) {
+ @Override protected BlockedCmdsFlag flagOf(@Nonnull List value) {
return new BlockedCmdsFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BreakFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BreakFlag.java
index 5acf7d489..c005efe5f 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BreakFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/BreakFlag.java
@@ -28,7 +28,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BlockTypeListFlag;
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
@@ -41,7 +41,7 @@ public class BreakFlag extends BlockTypeListFlag {
super(blockTypeList, Captions.FLAG_DESCRIPTION_BREAK);
}
- @Override protected BreakFlag flagOf(@NotNull List value) {
+ @Override protected BreakFlag flagOf(@Nonnull List value) {
return new BreakFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ChatFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ChatFlag.java
index 81da5294a..8975375b0 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ChatFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ChatFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class ChatFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class ChatFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_CHAT);
}
- @Override protected ChatFlag flagOf(@NotNull Boolean value) {
+ @Override protected ChatFlag flagOf(@Nonnull Boolean value) {
return value ? CHAT_FLAG_TRUE : CHAT_FLAG_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CoralDryFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CoralDryFlag.java
index 84e98f9d6..da501eb6c 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CoralDryFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CoralDryFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class CoralDryFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class CoralDryFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_CORAL_DRY);
}
- @Override protected CoralDryFlag flagOf(@NotNull Boolean value) {
+ @Override protected CoralDryFlag flagOf(@Nonnull Boolean value) {
return value ? CORAL_DRY_TRUE : CORAL_DRY_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyExitFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyExitFlag.java
index 17fe9f0e8..107cc360d 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyExitFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyExitFlag.java
@@ -27,7 +27,8 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+
+import javax.annotation.Nonnull;
public class DenyExitFlag extends BooleanFlag {
@@ -38,7 +39,7 @@ public class DenyExitFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_DENY_EXIT);
}
- @Override protected DenyExitFlag flagOf(@NotNull Boolean value) {
+ @Override protected DenyExitFlag flagOf(@Nonnull Boolean value) {
return value ? DENY_EXIT_FLAG_TRUE : DENY_EXIT_FLAG_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java
index ba923c396..e02a1b0e8 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java
@@ -30,8 +30,8 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collection;
@@ -46,7 +46,7 @@ public class DenyTeleportFlag extends PlotFlag {
public static final DescriptionFlag DESCRIPTION_FLAG_EMPTY = new DescriptionFlag("");
- protected DescriptionFlag(@NotNull String value) {
+ protected DescriptionFlag(@Nonnull String value) {
super(value, Captions.FLAG_CATEGORY_STRING, Captions.FLAG_DESCRIPTION_DESCRIPTION);
}
- @Override public DescriptionFlag parse(@NotNull String input) {
+ @Override public DescriptionFlag parse(@Nonnull String input) {
return flagOf(input);
}
- @Override public DescriptionFlag merge(@NotNull String newValue) {
+ @Override public DescriptionFlag merge(@Nonnull String newValue) {
return flagOf(this.getValue() + " " + newValue);
}
@@ -53,7 +53,7 @@ public class DescriptionFlag extends PlotFlag {
return "&6This is my plot!";
}
- @Override protected DescriptionFlag flagOf(@NotNull String value) {
+ @Override protected DescriptionFlag flagOf(@Nonnull String value) {
return new DescriptionFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DeviceInteractFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DeviceInteractFlag.java
index f43e1e27a..981c4bfe4 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DeviceInteractFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DeviceInteractFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class DeviceInteractFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class DeviceInteractFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_DEVICE_INTERACT);
}
- @Override protected DeviceInteractFlag flagOf(@NotNull Boolean value) {
+ @Override protected DeviceInteractFlag flagOf(@Nonnull Boolean value) {
return value ? DEVICE_INTERACT_TRUE : DEVICE_INTERACT_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DisablePhysicsFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DisablePhysicsFlag.java
index f1d952260..a0578b1fe 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DisablePhysicsFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DisablePhysicsFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class DisablePhysicsFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class DisablePhysicsFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_DISABLE_PHYSICS);
}
- @Override protected DisablePhysicsFlag flagOf(@NotNull Boolean value) {
+ @Override protected DisablePhysicsFlag flagOf(@Nonnull Boolean value) {
return value ? DISABLE_PHYSICS_TRUE : DISABLE_PHYSICS_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DoneFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DoneFlag.java
index 390ae4ba7..be94170fe 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DoneFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DoneFlag.java
@@ -29,7 +29,7 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.InternalFlag;
import com.plotsquared.core.plot.flag.PlotFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class DoneFlag extends PlotFlag implements InternalFlag {
@@ -38,7 +38,7 @@ public class DoneFlag extends PlotFlag implements InternalFlag
*
* @param value Flag value
*/
- public DoneFlag(@NotNull String value) {
+ public DoneFlag(@Nonnull String value) {
super(value, Captions.NONE, Captions.NONE);
}
@@ -46,11 +46,11 @@ public class DoneFlag extends PlotFlag implements InternalFlag
return !plot.getFlag(DoneFlag.class).isEmpty();
}
- @Override public DoneFlag parse(@NotNull String input) {
+ @Override public DoneFlag parse(@Nonnull String input) {
return flagOf(input);
}
- @Override public DoneFlag merge(@NotNull String newValue) {
+ @Override public DoneFlag merge(@Nonnull String newValue) {
return flagOf(newValue);
}
@@ -62,7 +62,7 @@ public class DoneFlag extends PlotFlag implements InternalFlag
return "";
}
- @Override protected DoneFlag flagOf(@NotNull String value) {
+ @Override protected DoneFlag flagOf(@Nonnull String value) {
return new DoneFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DropProtectionFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DropProtectionFlag.java
index a210af66e..785d29b6e 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DropProtectionFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DropProtectionFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class DropProtectionFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class DropProtectionFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_DROP_PROTECTION);
}
- @Override protected DropProtectionFlag flagOf(@NotNull Boolean value) {
+ @Override protected DropProtectionFlag flagOf(@Nonnull Boolean value) {
return value ? DROP_PROTECTION_TRUE : DROP_PROTECTION_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/EntityCapFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/EntityCapFlag.java
index e20e2dded..13b7b4d21 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/EntityCapFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/EntityCapFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.NonNegativeIntegerFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class EntityCapFlag extends NonNegativeIntegerFlag {
public static final EntityCapFlag ENTITY_CAP_UNLIMITED = new EntityCapFlag(Integer.MAX_VALUE);
@@ -36,7 +36,7 @@ public class EntityCapFlag extends NonNegativeIntegerFlag {
super(value, Captions.FLAG_DESCRIPTION_ENTITY_CAP);
}
- @Override protected EntityCapFlag flagOf(@NotNull Integer value) {
+ @Override protected EntityCapFlag flagOf(@Nonnull Integer value) {
return new EntityCapFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ExplosionFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ExplosionFlag.java
index 0f1f04a54..ed611d57d 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ExplosionFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ExplosionFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class ExplosionFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class ExplosionFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_EXPLOSION);
}
- @Override protected ExplosionFlag flagOf(@NotNull Boolean value) {
+ @Override protected ExplosionFlag flagOf(@Nonnull Boolean value) {
return value ? EXPLOSION_TRUE : EXPLOSION_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FarewellFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FarewellFlag.java
index 625f41cb8..1231d64a4 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FarewellFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FarewellFlag.java
@@ -27,21 +27,21 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.PlotFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class FarewellFlag extends PlotFlag {
public static final FarewellFlag FAREWELL_FLAG_EMPTY = new FarewellFlag("");
- protected FarewellFlag(@NotNull String value) {
+ protected FarewellFlag(@Nonnull String value) {
super(value, Captions.FLAG_CATEGORY_STRING, Captions.FLAG_DESCRIPTION_FAREWELL);
}
- @Override public FarewellFlag parse(@NotNull String input) {
+ @Override public FarewellFlag parse(@Nonnull String input) {
return flagOf(input);
}
- @Override public FarewellFlag merge(@NotNull String newValue) {
+ @Override public FarewellFlag merge(@Nonnull String newValue) {
return flagOf(this.getValue() + " " + newValue);
}
@@ -53,7 +53,7 @@ public class FarewellFlag extends PlotFlag {
return "&cBye :(";
}
- @Override protected FarewellFlag flagOf(@NotNull String value) {
+ @Override protected FarewellFlag flagOf(@Nonnull String value) {
return new FarewellFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FeedFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FeedFlag.java
index 11a0cac4a..05164b8d2 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FeedFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FeedFlag.java
@@ -28,12 +28,12 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.types.TimedFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class FeedFlag extends TimedFlag {
public static final FeedFlag FEED_NOTHING = new FeedFlag(new Timed<>(0, 0));
- public FeedFlag(@NotNull Timed value) {
+ public FeedFlag(@Nonnull Timed value) {
super(value, 1, Captions.FLAG_DESCRIPTION_FEED);
}
@@ -58,7 +58,7 @@ public class FeedFlag extends TimedFlag {
return "10 5";
}
- @Override protected FeedFlag flagOf(@NotNull Timed value) {
+ @Override protected FeedFlag flagOf(@Nonnull Timed value) {
return new FeedFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FlyFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FlyFlag.java
index ffe72a7b4..478e17858 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FlyFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/FlyFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.PlotFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
@@ -42,7 +42,7 @@ public class FlyFlag extends PlotFlag {
super(value, Captions.FLAG_CATEGORY_BOOLEAN, Captions.FLAG_DESCRIPTION_FLIGHT);
}
- @Override public FlyFlag parse(@NotNull final String input) {
+ @Override public FlyFlag parse(@Nonnull final String input) {
switch (input.toLowerCase()) {
case "true":
case "enabled":
@@ -57,7 +57,7 @@ public class FlyFlag extends PlotFlag {
}
}
- @Override public FlyFlag merge(@NotNull final FlyStatus newValue) {
+ @Override public FlyFlag merge(@Nonnull final FlyStatus newValue) {
if (newValue == FlyStatus.ENABLED || this.getValue() == FlyStatus.ENABLED) {
return FLIGHT_FLAG_ENABLED;
}
@@ -72,7 +72,7 @@ public class FlyFlag extends PlotFlag {
return "true";
}
- @Override protected FlyFlag flagOf(@NotNull final FlyStatus value) {
+ @Override protected FlyFlag flagOf(@Nonnull final FlyStatus value) {
switch (value) {
case ENABLED:
return FLIGHT_FLAG_ENABLED;
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ForcefieldFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ForcefieldFlag.java
index f8c985238..98136a7b3 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ForcefieldFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ForcefieldFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class ForcefieldFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class ForcefieldFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_FORCEFIELD);
}
- @Override protected ForcefieldFlag flagOf(@NotNull Boolean value) {
+ @Override protected ForcefieldFlag flagOf(@Nonnull Boolean value) {
return value ? FORCEFIELD_TRUE : FORCEFIELD_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GamemodeFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GamemodeFlag.java
index 60fdb4a0a..4c6b60020 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GamemodeFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GamemodeFlag.java
@@ -30,7 +30,7 @@ import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class GamemodeFlag extends PlotFlag {
@@ -52,11 +52,11 @@ public class GamemodeFlag extends PlotFlag {
*
* @param value Flag value
*/
- protected GamemodeFlag(@NotNull GameMode value) {
+ protected GamemodeFlag(@Nonnull GameMode value) {
super(value, Captions.FLAG_CATEGORY_GAMEMODE, Captions.FLAG_DESCRIPTION_GAMEMODE);
}
- @Override public GamemodeFlag parse(@NotNull String input) throws FlagParseException {
+ @Override public GamemodeFlag parse(@Nonnull String input) throws FlagParseException {
switch (input) {
case "creative":
case "c":
@@ -79,7 +79,7 @@ public class GamemodeFlag extends PlotFlag {
}
}
- @Override public GamemodeFlag merge(@NotNull GameMode newValue) {
+ @Override public GamemodeFlag merge(@Nonnull GameMode newValue) {
return flagOf(newValue);
}
@@ -91,7 +91,7 @@ public class GamemodeFlag extends PlotFlag {
return "survival";
}
- @Override protected GamemodeFlag flagOf(@NotNull GameMode value) {
+ @Override protected GamemodeFlag flagOf(@Nonnull GameMode value) {
switch (value.getId()) {
case "creative":
return GAMEMODE_FLAG_CREATIVE;
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GrassGrowFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GrassGrowFlag.java
index 7cb823667..ad63de5ee 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GrassGrowFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GrassGrowFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class GrassGrowFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class GrassGrowFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_GRASS_GROW);
}
- @Override protected GrassGrowFlag flagOf(@NotNull Boolean value) {
+ @Override protected GrassGrowFlag flagOf(@Nonnull Boolean value) {
return value ? GRASS_GROW_TRUE : GRASS_GROW_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GreetingFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GreetingFlag.java
index 0097defa8..3c6cc0163 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GreetingFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GreetingFlag.java
@@ -27,21 +27,21 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.PlotFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class GreetingFlag extends PlotFlag {
public static final GreetingFlag GREETING_FLAG_EMPTY = new GreetingFlag("");
- protected GreetingFlag(@NotNull String value) {
+ protected GreetingFlag(@Nonnull String value) {
super(value, Captions.FLAG_CATEGORY_STRING, Captions.FLAG_DESCRIPTION_GREETING);
}
- @Override public GreetingFlag parse(@NotNull String input) {
+ @Override public GreetingFlag parse(@Nonnull String input) {
return flagOf(input);
}
- @Override public GreetingFlag merge(@NotNull String newValue) {
+ @Override public GreetingFlag merge(@Nonnull String newValue) {
return flagOf(this.getValue() + " " + newValue);
}
@@ -53,7 +53,7 @@ public class GreetingFlag extends PlotFlag {
return "&6Welcome to my plot!";
}
- @Override protected GreetingFlag flagOf(@NotNull String value) {
+ @Override protected GreetingFlag flagOf(@Nonnull String value) {
return new GreetingFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GuestGamemodeFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GuestGamemodeFlag.java
index 8b320200e..090b056ea 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GuestGamemodeFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/GuestGamemodeFlag.java
@@ -30,7 +30,7 @@ import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class GuestGamemodeFlag extends PlotFlag {
@@ -50,11 +50,11 @@ public class GuestGamemodeFlag extends PlotFlag {
*
* @param value Flag value
*/
- protected GuestGamemodeFlag(@NotNull GameMode value) {
+ protected GuestGamemodeFlag(@Nonnull GameMode value) {
super(value, Captions.FLAG_CATEGORY_GAMEMODE, Captions.FLAG_DESCRIPTION_GUEST_GAMEMODE);
}
- @Override public GuestGamemodeFlag parse(@NotNull String input) throws FlagParseException {
+ @Override public GuestGamemodeFlag parse(@Nonnull String input) throws FlagParseException {
switch (input) {
case "creative":
case "c":
@@ -77,7 +77,7 @@ public class GuestGamemodeFlag extends PlotFlag {
}
}
- @Override public GuestGamemodeFlag merge(@NotNull GameMode newValue) {
+ @Override public GuestGamemodeFlag merge(@Nonnull GameMode newValue) {
return flagOf(newValue);
}
@@ -89,7 +89,7 @@ public class GuestGamemodeFlag extends PlotFlag {
return "survival";
}
- @Override protected GuestGamemodeFlag flagOf(@NotNull GameMode value) {
+ @Override protected GuestGamemodeFlag flagOf(@Nonnull GameMode value) {
switch (value.getId()) {
case "creative":
return GUEST_GAMEMODE_FLAG_CREATIVE;
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingBreakFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingBreakFlag.java
index f7a07a28a..ca7f1fb37 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingBreakFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingBreakFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HangingBreakFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class HangingBreakFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_HANGING_BREAK);
}
- @Override protected HangingBreakFlag flagOf(@NotNull Boolean value) {
+ @Override protected HangingBreakFlag flagOf(@Nonnull Boolean value) {
return value ? HANGING_BREAK_TRUE : HANGING_BREAK_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingPlaceFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingPlaceFlag.java
index 14923a319..eb3441ee1 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingPlaceFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HangingPlaceFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HangingPlaceFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class HangingPlaceFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_HANGING_PLACE);
}
- @Override protected HangingPlaceFlag flagOf(@NotNull Boolean value) {
+ @Override protected HangingPlaceFlag flagOf(@Nonnull Boolean value) {
return value ? HANGING_PLACE_TRUE : HANGING_PLACE_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java
index 90e5fbabb..e683b82a6 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java
@@ -28,12 +28,12 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.types.TimedFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HealFlag extends TimedFlag {
public static final HealFlag HEAL_NOTHING = new HealFlag(new Timed<>(0, 0));
- protected HealFlag(@NotNull Timed value) {
+ protected HealFlag(@Nonnull Timed value) {
super(value, 1, Captions.FLAG_DESCRIPTION_HEAL);
}
@@ -58,7 +58,7 @@ public class HealFlag extends TimedFlag {
return "20 2";
}
- @Override protected HealFlag flagOf(@NotNull Timed value) {
+ @Override protected HealFlag flagOf(@Nonnull Timed value) {
return new HealFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HideInfoFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HideInfoFlag.java
index d382cac8f..81d85906f 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HideInfoFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HideInfoFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HideInfoFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class HideInfoFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_HIDE_INFO);
}
- @Override protected HideInfoFlag flagOf(@NotNull Boolean value) {
+ @Override protected HideInfoFlag flagOf(@Nonnull Boolean value) {
return value ? HIDE_INFO_TRUE : HIDE_INFO_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileAttackFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileAttackFlag.java
index 9ec805814..da5e8e4af 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileAttackFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileAttackFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HostileAttackFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class HostileAttackFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_HOSTILE_ATTACK);
}
- @Override protected HostileAttackFlag flagOf(@NotNull Boolean value) {
+ @Override protected HostileAttackFlag flagOf(@Nonnull Boolean value) {
return value ? HOSTILE_ATTACK_TRUE : HOSTILE_ATTACK_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileCapFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileCapFlag.java
index 017e3736a..9d442bb00 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileCapFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileCapFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.NonNegativeIntegerFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HostileCapFlag extends NonNegativeIntegerFlag {
public static final HostileCapFlag HOSTILE_CAP_UNLIMITED =
@@ -37,7 +37,7 @@ public class HostileCapFlag extends NonNegativeIntegerFlag {
super(value, Captions.FLAG_DESCRIPTION_HOSTILE_CAP);
}
- @Override protected HostileCapFlag flagOf(@NotNull Integer value) {
+ @Override protected HostileCapFlag flagOf(@Nonnull Integer value) {
return new HostileCapFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileInteractFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileInteractFlag.java
index 96ce742b9..e903cd76c 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileInteractFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HostileInteractFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class HostileInteractFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class HostileInteractFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_HOSTILE_INTERACT);
}
- @Override protected HostileInteractFlag flagOf(@NotNull Boolean value) {
+ @Override protected HostileInteractFlag flagOf(@Nonnull Boolean value) {
return value ? HOSTILE_INTERACT_TRUE : HOSTILE_INTERACT_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceFormFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceFormFlag.java
index a0f54097e..b380d0773 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceFormFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceFormFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class IceFormFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class IceFormFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_ICE_FORM);
}
- @Override protected IceFormFlag flagOf(@NotNull Boolean value) {
+ @Override protected IceFormFlag flagOf(@Nonnull Boolean value) {
return value ? ICE_FORM_TRUE : ICE_FORM_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceMeltFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceMeltFlag.java
index 0c1bf93a6..ef97c8964 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceMeltFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/IceMeltFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class IceMeltFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class IceMeltFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_ICE_MELT);
}
- @Override protected IceMeltFlag flagOf(@NotNull Boolean value) {
+ @Override protected IceMeltFlag flagOf(@Nonnull Boolean value) {
return value ? ICE_MELT_TRUE : ICE_MELT_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InstabreakFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InstabreakFlag.java
index 7c87fcff4..90d5632f1 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InstabreakFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InstabreakFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class InstabreakFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class InstabreakFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_INSTABREAK);
}
- @Override protected InstabreakFlag flagOf(@NotNull Boolean value) {
+ @Override protected InstabreakFlag flagOf(@Nonnull Boolean value) {
return value ? INSTABREAK_TRUE : INSTABREAK_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InvincibleFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InvincibleFlag.java
index b19e0d393..e3328a6a2 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InvincibleFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/InvincibleFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class InvincibleFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class InvincibleFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_INVINCIBLE);
}
- @Override protected InvincibleFlag flagOf(@NotNull Boolean value) {
+ @Override protected InvincibleFlag flagOf(@Nonnull Boolean value) {
return value ? INVINCIBLE_TRUE : INVINCIBLE_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ItemDropFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ItemDropFlag.java
index 1c71be3eb..654505a38 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ItemDropFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ItemDropFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class ItemDropFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class ItemDropFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_ITEM_DROP);
}
- @Override protected ItemDropFlag flagOf(@NotNull Boolean value) {
+ @Override protected ItemDropFlag flagOf(@Nonnull Boolean value) {
return value ? ITEM_DROP_TRUE : ITEM_DROP_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepFlag.java
index ce23f2510..187237f2a 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepFlag.java
@@ -30,7 +30,7 @@ import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class KeepFlag extends PlotFlag {
@@ -41,11 +41,11 @@ public class KeepFlag extends PlotFlag {
*
* @param value Flag value
*/
- protected KeepFlag(@NotNull Object value) {
+ protected KeepFlag(@Nonnull Object value) {
super(value, Captions.FLAG_CATEGORY_MIXED, Captions.FLAG_DESCRIPTION_KEEP);
}
- @Override public KeepFlag parse(@NotNull String input) throws FlagParseException {
+ @Override public KeepFlag parse(@Nonnull String input) throws FlagParseException {
if (MathMan.isInteger(input)) {
final long value = Long.parseLong(input);
if (value < 0) {
@@ -64,7 +64,7 @@ public class KeepFlag extends PlotFlag {
}
}
- @Override public KeepFlag merge(@NotNull Object newValue) {
+ @Override public KeepFlag merge(@Nonnull Object newValue) {
if (newValue.equals(true)) {
return flagOf(true);
} else if (newValue.equals(false)) {
@@ -93,7 +93,7 @@ public class KeepFlag extends PlotFlag {
return "3w 4d 2h";
}
- @Override protected KeepFlag flagOf(@NotNull Object value) {
+ @Override protected KeepFlag flagOf(@Nonnull Object value) {
return new KeepFlag(value);
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepInventoryFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepInventoryFlag.java
index 872c3157d..40592bfd3 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepInventoryFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KeepInventoryFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class KeepInventoryFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class KeepInventoryFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_KEEP_INVENTORY);
}
- @Override protected KeepInventoryFlag flagOf(@NotNull final Boolean value) {
+ @Override protected KeepInventoryFlag flagOf(@Nonnull final Boolean value) {
return value ? KEEP_INVENTORY_TRUE : KEEP_INVENTORY_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KelpGrowFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KelpGrowFlag.java
index 495db4160..43bcb5398 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KelpGrowFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/KelpGrowFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class KelpGrowFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class KelpGrowFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_KELP_GROW);
}
- @Override protected KelpGrowFlag flagOf(@NotNull Boolean value) {
+ @Override protected KelpGrowFlag flagOf(@Nonnull Boolean value) {
return value ? KELP_GROW_TRUE : KELP_GROW_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LiquidFlowFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LiquidFlowFlag.java
index c200ed6a9..c0c0e4f17 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LiquidFlowFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LiquidFlowFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.PlotFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
@@ -43,7 +43,7 @@ public class LiquidFlowFlag extends PlotFlag {
@@ -38,7 +38,7 @@ public class MiscBreakFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_MISC_BREAK);
}
- @Override protected MiscBreakFlag flagOf(@NotNull Boolean value) {
+ @Override protected MiscBreakFlag flagOf(@Nonnull Boolean value) {
return value ? MISC_BREAK_TRUE : MISC_BREAK_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscCapFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscCapFlag.java
index 2291d6343..dfe55373e 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscCapFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscCapFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.NonNegativeIntegerFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class MiscCapFlag extends NonNegativeIntegerFlag {
public static final MiscCapFlag MISC_CAP_UNLIMITED = new MiscCapFlag(Integer.MAX_VALUE);
@@ -36,7 +36,7 @@ public class MiscCapFlag extends NonNegativeIntegerFlag {
super(value, Captions.FLAG_DESCRIPTION_MISC_CAP);
}
- @Override protected MiscCapFlag flagOf(@NotNull Integer value) {
+ @Override protected MiscCapFlag flagOf(@Nonnull Integer value) {
return new MiscCapFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscInteractFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscInteractFlag.java
index a70191a9d..a64116119 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscInteractFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscInteractFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class MiscInteractFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class MiscInteractFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_MISC_INTERACT);
}
- @Override protected MiscInteractFlag flagOf(@NotNull Boolean value) {
+ @Override protected MiscInteractFlag flagOf(@Nonnull Boolean value) {
return value ? MISC_INTERACT_TRUE : MISC_INTERACT_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscPlaceFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscPlaceFlag.java
index 8579d33df..2cf52f8e0 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscPlaceFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MiscPlaceFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class MiscPlaceFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class MiscPlaceFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_MISC_PLACE);
}
- @Override protected MiscPlaceFlag flagOf(@NotNull Boolean value) {
+ @Override protected MiscPlaceFlag flagOf(@Nonnull Boolean value) {
return value ? MISC_PLACE_TRUE : MISC_PLACE_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobBreakFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobBreakFlag.java
index fd8db8c69..e0d8e88e5 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobBreakFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobBreakFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class MobBreakFlag extends BooleanFlag {
@@ -38,7 +38,7 @@ public class MobBreakFlag extends BooleanFlag {
super(value, Captions.FLAG_DESCRIPTION_MOB_BREAK);
}
- @Override protected MobBreakFlag flagOf(@NotNull Boolean value) {
+ @Override protected MobBreakFlag flagOf(@Nonnull Boolean value) {
return value ? MOB_BREAK_TRUE : MOB_BREAK_FALSE;
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobCapFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobCapFlag.java
index f05f2699a..a1e202984 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobCapFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobCapFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.NonNegativeIntegerFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class MobCapFlag extends NonNegativeIntegerFlag {
public static final MobCapFlag MOB_CAP_UNLIMITED = new MobCapFlag(Integer.MAX_VALUE);
@@ -36,7 +36,7 @@ public class MobCapFlag extends NonNegativeIntegerFlag {
super(value, Captions.FLAG_DESCRIPTION_MOB_CAP);
}
- @Override protected MobCapFlag flagOf(@NotNull Integer value) {
+ @Override protected MobCapFlag flagOf(@Nonnull Integer value) {
return new MobCapFlag(value);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobPlaceFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobPlaceFlag.java
index b0f85914c..ae54d6321 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobPlaceFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/MobPlaceFlag.java
@@ -27,7 +27,7 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
-import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
public class MobPlaceFlag extends BooleanFlag