diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
index 1580d8d09..49ac0febb 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
@@ -251,10 +251,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
this.getServer().getPluginManager().disablePlugin(this);
}
- @Override public void disable() {
- onDisable();
- }
-
@Override public int[] getPluginVersion() {
String ver = getDescription().getVersion();
if (ver.contains("-")) {
@@ -555,17 +551,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public void registerPlayerEvents() {
final PlayerEvents main = new PlayerEvents();
getServer().getPluginManager().registerEvents(main, this);
- try {
- getServer().getClass().getMethod("spigot");
- Class.forName("org.bukkit.event.entity.EntitySpawnEvent");
- getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
- } catch (final NoSuchMethodException | ClassNotFoundException ignored) {
- PlotSquared.debug("Not running Spigot. Skipping EntitySpawnListener event.");
- }
- }
-
- @Override public void registerInventoryEvents() {
- // Part of PlayerEvents - can be moved if necessary
+ getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
}
@Override public void registerPlotPlusEvents() {
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java
index 443e07025..6d4fd5844 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java
@@ -25,7 +25,7 @@ import org.bukkit.plugin.Plugin;
import java.util.List;
-@SuppressWarnings("unused") public class EntitySpawnListener implements Listener {
+public class EntitySpawnListener implements Listener {
private static boolean ignoreTP = false;
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java
index e50ec9e8e..6ca241dcd 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java
@@ -15,28 +15,28 @@ import java.util.List;
public interface IPlotMain extends ILogger {
/**
- * Log a message to console.
+ * Logs a message to console.
*
- * @param message The message to log
+ * @param message the message to log
*/
void log(String message);
/**
- * Get the `PlotSquared` directory.
+ * Gets the directory which contains PlotSquared files. The directory may not exist.
*
- * @return The plugin directory
+ * @return the PlotSquared directory
*/
File getDirectory();
/**
- * Get the directory containing all the worlds.
+ * Gets the folder where all world data is stored.
*
- * @return The directory containing the worlds
+ * @return the world folder
*/
File getWorldContainer();
/**
- * Wrap a player into a PlotPlayer object.
+ * Wraps a player into a PlotPlayer object.
*
* @param player The player to convert to a PlotPlayer
* @return A PlotPlayer
@@ -44,70 +44,56 @@ public interface IPlotMain extends ILogger {
PlotPlayer wrapPlayer(Object player);
/**
- * Disable the implementation.
- *
- *
- * - If a full disable isn't feasibly, just disable what it can.
- *
- */
- void disable();
-
- /**
- * Completely shut down the plugin
+ * Completely shuts down the plugin.
*/
void shutdown();
/**
- * Get the version of the PlotSquared being used.
+ * Gets the version of the PlotSquared being used.
*
* @return the plugin version
*/
int[] getPluginVersion();
/**
- * Get the version of the PlotSquared being used as a string.
+ * Gets the version of the PlotSquared being used as a string.
*
* @return the plugin version as a string
*/
String getPluginVersionString();
- /**
- * Usually PlotSquared
- *
- * @return
- */
String getPluginName();
/**
- * Get the version of Minecraft that is running.
+ * Gets the version of Minecraft that is running.
*
* @return
*/
int[] getServerVersion();
/**
- * Get the server implementation name and version
+ * Gets the server implementation name and version
*/
String getServerImplementation();
/**
- * Get the NMS package prefix.
+ * Gets the NMS package prefix.
*
* @return The NMS package prefix
*/
String getNMSPackage();
/**
- * Get the schematic handler.
+ * Gets the schematic handler.
*
* @return The {@link SchematicHandler}
*/
SchematicHandler initSchematicHandler();
/**
- * Get the Chat Manager.
+ * Starts the {@link ChatManager}.
*
- * @return The {@link ChatManager}
+ * @return the ChatManager
*/
ChatManager initChatManager();
@@ -124,7 +110,7 @@ public interface IPlotMain extends ILogger {
void runEntityTask();
/**
- * Register the implementation specific commands.
+ * Registerss the implementation specific commands.
*/
void registerCommands();
@@ -133,11 +119,6 @@ public interface IPlotMain extends ILogger {
*/
void registerPlayerEvents();
- /**
- * Register inventory related events.
- */
- void registerInventoryEvents();
-
/**
* Register plot plus related events.
*/
@@ -149,54 +130,54 @@ public interface IPlotMain extends ILogger {
void registerForceFieldEvents();
/**
- * Register the WorldEdit hook.
+ * Registers the WorldEdit hook.
*/
boolean initWorldEdit();
/**
- * Get the economy provider.
+ * Gets the economy provider.
*
* @return
*/
EconHandler getEconomyHandler();
/**
- * Get the {@link QueueProvider} class.
+ * Gets the {@link QueueProvider} class.
*
* @return
*/
QueueProvider initBlockQueue();
/**
- * Get the {@link WorldUtil} class.
+ * Gets the {@link WorldUtil} class.
*
* @return
*/
WorldUtil initWorldUtil();
/**
- * Get the EventUtil class.
+ * Gets the EventUtil class.
*
* @return
*/
EventUtil initEventUtil();
/**
- * Get the chunk manager.
+ * Gets the chunk manager.
*
* @return
*/
ChunkManager initChunkManager();
/**
- * Get the {@link SetupUtils} class.
+ * Gets the {@link SetupUtils} class.
*
* @return
*/
SetupUtils initSetupUtils();
/**
- * Get {@link HybridUtils} class.
+ * Gets {@link HybridUtils} class.
*
* @return
*/
@@ -215,7 +196,7 @@ public interface IPlotMain extends ILogger {
void setGenerator(String world);
/**
- * Get the {@link UUIDHandlerImplementation} which will cache and
+ * Gets the {@link UUIDHandlerImplementation} which will cache and
* provide UUIDs.
*
* @return
@@ -223,7 +204,7 @@ public interface IPlotMain extends ILogger {
UUIDHandlerImplementation initUUIDHandler();
/**
- * Get the {@link InventoryUtil} class (used for implementation specific
+ * Gets the {@link InventoryUtil} class (used for implementation specific
* inventory guis).
*
* @return
@@ -231,14 +212,14 @@ public interface IPlotMain extends ILogger {
InventoryUtil initInventoryUtil();
/**
- * Unregister a PlotPlayer from cache e.g. if they have logged off.
+ * Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
*
* @param player
*/
void unregister(PlotPlayer player);
/**
- * Get the generator wrapper for a world (world) and generator (name).
+ * Gets the generator wrapper for a world (world) and generator (name).
*
* @param world
* @param name
@@ -268,7 +249,7 @@ public interface IPlotMain extends ILogger {
IndependentPlotGenerator getDefaultGenerator();
/**
- * Get the class that will manage player titles.
+ * Gets the class that will manage player titles.
*
* @return
*/
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
index 7a9abb000..fb39d5938 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java
@@ -30,6 +30,7 @@ import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.*;
import java.net.MalformedURLException;
@@ -150,7 +151,6 @@ import java.util.zip.ZipInputStream;
}
if (Settings.Enabled_Components.EVENTS) {
this.IMP.registerPlayerEvents();
- this.IMP.registerInventoryEvents();
this.IMP.registerPlotPlusEvents();
}
// Required
@@ -1145,7 +1145,7 @@ import java.util.zip.ZipInputStream;
if (type == 2) {
Set clusters = this.clusters_tmp != null ?
this.clusters_tmp.get(world) :
- new HashSet();
+ new HashSet<>();
if (clusters == null) {
throw new IllegalArgumentException("No cluster exists for world: " + world);
}
@@ -1577,7 +1577,7 @@ import java.util.zip.ZipInputStream;
database = new SQLite(file);
} else {
PlotSquared.log(C.PREFIX + "&cNo storage type is set!");
- this.IMP.disable();
+ this.IMP.shutdown(); //shutdown used instead of disable because no database is set
return;
}
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
@@ -1607,7 +1607,7 @@ import java.util.zip.ZipInputStream;
PlotSquared.log("&d==== End of stacktrace ====");
PlotSquared.log("&6Please go to the " + IMP.getPluginName()
+ " 'storage.yml' and configure the database correctly.");
- this.IMP.disable();
+ this.IMP.shutdown(); //shutdown used instead of disable because of database error
}
}
@@ -1822,7 +1822,7 @@ import java.util.zip.ZipInputStream;
return Double.parseDouble(System.getProperty("java.specification.version"));
}
- public void foreachPlotArea(@NonNull final RunnableVal runnable) {
+ public void foreachPlotArea(@Nonnull final RunnableVal runnable) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
runnable.run(area);
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java
index eedba15cf..b191ac323 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java
@@ -18,8 +18,8 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
-import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste",
description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml and your latest.log to https://incendo.org",
@@ -28,12 +28,9 @@ import java.util.List;
private static String readFile(@NonNull final File file) throws IOException {
final StringBuilder content = new StringBuilder();
- final List lines = new ArrayList<>();
+ final List lines;
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
- String line;
- while ((line = reader.readLine()) != null) {
- lines.add(line);
- }
+ lines = reader.lines().collect(Collectors.toList());
}
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
content.append(lines.get(i)).append("\n");
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java
index e5341103d..ae4a1fa76 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java
@@ -14,7 +14,7 @@ public interface AbstractDB {
UUID everyone = UUID.fromString("1-1-3-3-7");
/**
- * Set Plot owner.
+ * Sets Plot owner.
*
* @param plot the plot
* @param uuid the uuid of the new owner
@@ -22,7 +22,7 @@ public interface AbstractDB {
void setOwner(Plot plot, UUID uuid);
/**
- * Create all settings, and create default helpers, trusted + denied lists.
+ * Creates all settings, and create default helpers, trusted + denied lists.
*
* @param plots Plots for which the default table entries should be created
* @param whenDone the task to run when the method is finished executing
@@ -30,7 +30,7 @@ public interface AbstractDB {
void createPlotsAndData(List plots, Runnable whenDone);
/**
- * Create a plot.
+ * Creates a plot.
*
* @param plot the plot to create
*/
@@ -44,7 +44,7 @@ public interface AbstractDB {
void createTables() throws Exception;
/**
- * Delete a plot.
+ * Deletess a plot.
*
* @param plot the plot to delete
*/
@@ -57,14 +57,14 @@ public interface AbstractDB {
void deleteTrusted(Plot plot);
/**
- * Remove all denied players from the plot.
+ * Removes all denied players from the plot.
*
* @param plot the plot
*/
void deleteDenied(Plot plot);
/**
- * Delete all comments from the plot.
+ * Deletes all comments from the plot.
*
* @param plot the plot
*/
@@ -81,7 +81,7 @@ public interface AbstractDB {
void getPersistentMeta(UUID uuid, RunnableVal