mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
Javadoc changes and cleaning of old unused code
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
e891873d28
commit
17027e6292
@ -251,10 +251,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
this.getServer().getPluginManager().disablePlugin(this);
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void disable() {
|
|
||||||
onDisable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int[] getPluginVersion() {
|
@Override public int[] getPluginVersion() {
|
||||||
String ver = getDescription().getVersion();
|
String ver = getDescription().getVersion();
|
||||||
if (ver.contains("-")) {
|
if (ver.contains("-")) {
|
||||||
@ -555,17 +551,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
@Override public void registerPlayerEvents() {
|
@Override public void registerPlayerEvents() {
|
||||||
final PlayerEvents main = new PlayerEvents();
|
final PlayerEvents main = new PlayerEvents();
|
||||||
getServer().getPluginManager().registerEvents(main, this);
|
getServer().getPluginManager().registerEvents(main, this);
|
||||||
try {
|
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerPlotPlusEvents() {
|
@Override public void registerPlotPlusEvents() {
|
||||||
|
@ -25,7 +25,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("unused") public class EntitySpawnListener implements Listener {
|
public class EntitySpawnListener implements Listener {
|
||||||
|
|
||||||
private static boolean ignoreTP = false;
|
private static boolean ignoreTP = false;
|
||||||
|
|
||||||
|
@ -15,28 +15,28 @@ import java.util.List;
|
|||||||
public interface IPlotMain extends ILogger {
|
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);
|
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();
|
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();
|
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
|
* @param player The player to convert to a PlotPlayer
|
||||||
* @return A PlotPlayer
|
* @return A PlotPlayer
|
||||||
@ -44,70 +44,56 @@ public interface IPlotMain extends ILogger {
|
|||||||
PlotPlayer wrapPlayer(Object player);
|
PlotPlayer wrapPlayer(Object player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the implementation.
|
* Completely shuts down the plugin.
|
||||||
*
|
|
||||||
* <ul>
|
|
||||||
* <li>If a full disable isn't feasibly, just disable what it can.
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
void disable();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Completely shut down the plugin
|
|
||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of the PlotSquared being used.
|
* Gets the version of the PlotSquared being used.
|
||||||
*
|
*
|
||||||
* @return the plugin version
|
* @return the plugin version
|
||||||
*/
|
*/
|
||||||
int[] getPluginVersion();
|
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
|
* @return the plugin version as a string
|
||||||
*/
|
*/
|
||||||
String getPluginVersionString();
|
String getPluginVersionString();
|
||||||
|
|
||||||
/**
|
|
||||||
* Usually PlotSquared
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getPluginName();
|
String getPluginName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of Minecraft that is running.
|
* Gets the version of Minecraft that is running.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int[] getServerVersion();
|
int[] getServerVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the server implementation name and version
|
* Gets the server implementation name and version
|
||||||
*/
|
*/
|
||||||
String getServerImplementation();
|
String getServerImplementation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the NMS package prefix.
|
* Gets the NMS package prefix.
|
||||||
*
|
*
|
||||||
* @return The NMS package prefix
|
* @return The NMS package prefix
|
||||||
*/
|
*/
|
||||||
String getNMSPackage();
|
String getNMSPackage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the schematic handler.
|
* Gets the schematic handler.
|
||||||
*
|
*
|
||||||
* @return The {@link SchematicHandler}
|
* @return The {@link SchematicHandler}
|
||||||
*/
|
*/
|
||||||
SchematicHandler initSchematicHandler();
|
SchematicHandler initSchematicHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Chat Manager.
|
* Starts the {@link ChatManager}.
|
||||||
*
|
*
|
||||||
* @return The {@link ChatManager}
|
* @return the ChatManager
|
||||||
*/
|
*/
|
||||||
ChatManager initChatManager();
|
ChatManager initChatManager();
|
||||||
|
|
||||||
@ -124,7 +110,7 @@ public interface IPlotMain extends ILogger {
|
|||||||
void runEntityTask();
|
void runEntityTask();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the implementation specific commands.
|
* Registerss the implementation specific commands.
|
||||||
*/
|
*/
|
||||||
void registerCommands();
|
void registerCommands();
|
||||||
|
|
||||||
@ -133,11 +119,6 @@ public interface IPlotMain extends ILogger {
|
|||||||
*/
|
*/
|
||||||
void registerPlayerEvents();
|
void registerPlayerEvents();
|
||||||
|
|
||||||
/**
|
|
||||||
* Register inventory related events.
|
|
||||||
*/
|
|
||||||
void registerInventoryEvents();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register plot plus related events.
|
* Register plot plus related events.
|
||||||
*/
|
*/
|
||||||
@ -149,54 +130,54 @@ public interface IPlotMain extends ILogger {
|
|||||||
void registerForceFieldEvents();
|
void registerForceFieldEvents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the WorldEdit hook.
|
* Registers the WorldEdit hook.
|
||||||
*/
|
*/
|
||||||
boolean initWorldEdit();
|
boolean initWorldEdit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the economy provider.
|
* Gets the economy provider.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
EconHandler getEconomyHandler();
|
EconHandler getEconomyHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link QueueProvider} class.
|
* Gets the {@link QueueProvider} class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
QueueProvider initBlockQueue();
|
QueueProvider initBlockQueue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link WorldUtil} class.
|
* Gets the {@link WorldUtil} class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
WorldUtil initWorldUtil();
|
WorldUtil initWorldUtil();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the EventUtil class.
|
* Gets the EventUtil class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
EventUtil initEventUtil();
|
EventUtil initEventUtil();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the chunk manager.
|
* Gets the chunk manager.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ChunkManager initChunkManager();
|
ChunkManager initChunkManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link SetupUtils} class.
|
* Gets the {@link SetupUtils} class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SetupUtils initSetupUtils();
|
SetupUtils initSetupUtils();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link HybridUtils} class.
|
* Gets {@link HybridUtils} class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -215,7 +196,7 @@ public interface IPlotMain extends ILogger {
|
|||||||
void setGenerator(String world);
|
void setGenerator(String world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link UUIDHandlerImplementation} which will cache and
|
* Gets the {@link UUIDHandlerImplementation} which will cache and
|
||||||
* provide UUIDs.
|
* provide UUIDs.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
@ -223,7 +204,7 @@ public interface IPlotMain extends ILogger {
|
|||||||
UUIDHandlerImplementation initUUIDHandler();
|
UUIDHandlerImplementation initUUIDHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link InventoryUtil} class (used for implementation specific
|
* Gets the {@link InventoryUtil} class (used for implementation specific
|
||||||
* inventory guis).
|
* inventory guis).
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
@ -231,14 +212,14 @@ public interface IPlotMain extends ILogger {
|
|||||||
InventoryUtil initInventoryUtil();
|
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
|
* @param player
|
||||||
*/
|
*/
|
||||||
void unregister(PlotPlayer 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 world
|
||||||
* @param name
|
* @param name
|
||||||
@ -268,7 +249,7 @@ public interface IPlotMain extends ILogger {
|
|||||||
IndependentPlotGenerator getDefaultGenerator();
|
IndependentPlotGenerator getDefaultGenerator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class that will manage player titles.
|
* Gets the class that will manage player titles.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +30,7 @@ import lombok.Getter;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -150,7 +151,6 @@ import java.util.zip.ZipInputStream;
|
|||||||
}
|
}
|
||||||
if (Settings.Enabled_Components.EVENTS) {
|
if (Settings.Enabled_Components.EVENTS) {
|
||||||
this.IMP.registerPlayerEvents();
|
this.IMP.registerPlayerEvents();
|
||||||
this.IMP.registerInventoryEvents();
|
|
||||||
this.IMP.registerPlotPlusEvents();
|
this.IMP.registerPlotPlusEvents();
|
||||||
}
|
}
|
||||||
// Required
|
// Required
|
||||||
@ -1145,7 +1145,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
if (type == 2) {
|
if (type == 2) {
|
||||||
Set<PlotCluster> clusters = this.clusters_tmp != null ?
|
Set<PlotCluster> clusters = this.clusters_tmp != null ?
|
||||||
this.clusters_tmp.get(world) :
|
this.clusters_tmp.get(world) :
|
||||||
new HashSet<PlotCluster>();
|
new HashSet<>();
|
||||||
if (clusters == null) {
|
if (clusters == null) {
|
||||||
throw new IllegalArgumentException("No cluster exists for world: " + world);
|
throw new IllegalArgumentException("No cluster exists for world: " + world);
|
||||||
}
|
}
|
||||||
@ -1577,7 +1577,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
database = new SQLite(file);
|
database = new SQLite(file);
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.log(C.PREFIX + "&cNo storage type is set!");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
|
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("&d==== End of stacktrace ====");
|
||||||
PlotSquared.log("&6Please go to the " + IMP.getPluginName()
|
PlotSquared.log("&6Please go to the " + IMP.getPluginName()
|
||||||
+ " 'storage.yml' and configure the database correctly.");
|
+ " '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"));
|
return Double.parseDouble(System.getProperty("java.specification.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachPlotArea(@NonNull final RunnableVal<PlotArea> runnable) {
|
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
runnable.run(area);
|
runnable.run(area);
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste",
|
@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",
|
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 {
|
private static String readFile(@NonNull final File file) throws IOException {
|
||||||
final StringBuilder content = new StringBuilder();
|
final StringBuilder content = new StringBuilder();
|
||||||
final List<String> lines = new ArrayList<>();
|
final List<String> lines;
|
||||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||||
String line;
|
lines = reader.lines().collect(Collectors.toList());
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
||||||
content.append(lines.get(i)).append("\n");
|
content.append(lines.get(i)).append("\n");
|
||||||
|
@ -14,7 +14,7 @@ public interface AbstractDB {
|
|||||||
UUID everyone = UUID.fromString("1-1-3-3-7");
|
UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Plot owner.
|
* Sets Plot owner.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param uuid the uuid of the new owner
|
* @param uuid the uuid of the new owner
|
||||||
@ -22,7 +22,7 @@ public interface AbstractDB {
|
|||||||
void setOwner(Plot plot, UUID uuid);
|
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 plots Plots for which the default table entries should be created
|
||||||
* @param whenDone the task to run when the method is finished executing
|
* @param whenDone the task to run when the method is finished executing
|
||||||
@ -30,7 +30,7 @@ public interface AbstractDB {
|
|||||||
void createPlotsAndData(List<Plot> plots, Runnable whenDone);
|
void createPlotsAndData(List<Plot> plots, Runnable whenDone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a plot.
|
* Creates a plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot to create
|
* @param plot the plot to create
|
||||||
*/
|
*/
|
||||||
@ -44,7 +44,7 @@ public interface AbstractDB {
|
|||||||
void createTables() throws Exception;
|
void createTables() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a plot.
|
* Deletess a plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot to delete
|
* @param plot the plot to delete
|
||||||
*/
|
*/
|
||||||
@ -57,14 +57,14 @@ public interface AbstractDB {
|
|||||||
void deleteTrusted(Plot plot);
|
void deleteTrusted(Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all denied players from the plot.
|
* Removes all denied players from the plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
*/
|
*/
|
||||||
void deleteDenied(Plot plot);
|
void deleteDenied(Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all comments from the plot.
|
* Deletes all comments from the plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
*/
|
*/
|
||||||
@ -81,7 +81,7 @@ public interface AbstractDB {
|
|||||||
void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result);
|
void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the plot settings.
|
* Creates the plot settings.
|
||||||
*
|
*
|
||||||
* @param id the plot entry id
|
* @param id the plot entry id
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
@ -89,7 +89,7 @@ public interface AbstractDB {
|
|||||||
void createPlotSettings(int id, Plot plot);
|
void createPlotSettings(int id, Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the table entry ID.
|
* Gets the table entry ID.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @return {@code Integer} = Plot Entry Id
|
* @return {@code Integer} = Plot Entry Id
|
||||||
@ -97,7 +97,7 @@ public interface AbstractDB {
|
|||||||
int getId(Plot plot);
|
int getId(Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the id of a given plot cluster.
|
* Gets the id of a given plot cluster.
|
||||||
*
|
*
|
||||||
* @param cluster PlotCluster Object
|
* @param cluster PlotCluster Object
|
||||||
* @return Integer = Cluster Entry Id
|
* @return Integer = Cluster Entry Id
|
||||||
@ -120,7 +120,7 @@ public interface AbstractDB {
|
|||||||
HashMap<String, Set<PlotCluster>> getClusters();
|
HashMap<String, Set<PlotCluster>> getClusters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the merged status for a plot.
|
* Sets the merged status for a plot.
|
||||||
*
|
*
|
||||||
* @param plot The plot to set the merged status of
|
* @param plot The plot to set the merged status of
|
||||||
* @param merged boolean[]
|
* @param merged boolean[]
|
||||||
@ -128,7 +128,7 @@ public interface AbstractDB {
|
|||||||
void setMerged(Plot plot, boolean[] merged);
|
void setMerged(Plot plot, boolean[] merged);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap the settings, helpers etc. of two plots.
|
* Swaps the settings, helpers etc. of two plots.
|
||||||
*
|
*
|
||||||
* @param plot1 Plot1
|
* @param plot1 Plot1
|
||||||
* @param plot2 Plot2
|
* @param plot2 Plot2
|
||||||
@ -136,7 +136,7 @@ public interface AbstractDB {
|
|||||||
void swapPlots(Plot plot1, Plot plot2);
|
void swapPlots(Plot plot1, Plot plot2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set plot flags.
|
* Sets plot flags.
|
||||||
*
|
*
|
||||||
* @param plot Plot Object
|
* @param plot Plot Object
|
||||||
* @param flags flags to set
|
* @param flags flags to set
|
||||||
@ -144,7 +144,7 @@ public interface AbstractDB {
|
|||||||
void setFlags(Plot plot, HashMap<Flag<?>, Object> flags);
|
void setFlags(Plot plot, HashMap<Flag<?>, Object> flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename a cluster to the given name.
|
* Renames a cluster to the given name.
|
||||||
*
|
*
|
||||||
* @param cluster the cluster to rename
|
* @param cluster the cluster to rename
|
||||||
* @param name the new cluster name
|
* @param name the new cluster name
|
||||||
@ -152,7 +152,7 @@ public interface AbstractDB {
|
|||||||
void setClusterName(PlotCluster cluster, String name);
|
void setClusterName(PlotCluster cluster, String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the plot alias.
|
* Sets the plot alias.
|
||||||
*
|
*
|
||||||
* @param plot Plot for which the alias should be set
|
* @param plot Plot for which the alias should be set
|
||||||
* @param alias Plot Alias
|
* @param alias Plot Alias
|
||||||
@ -160,14 +160,14 @@ public interface AbstractDB {
|
|||||||
void setAlias(Plot plot, String alias);
|
void setAlias(Plot plot, String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge a plot.
|
* Purges a plot.
|
||||||
*
|
*
|
||||||
* @param uniqueIds list of plot id (db) to be purged
|
* @param uniqueIds list of plot id (db) to be purged
|
||||||
*/
|
*/
|
||||||
void purgeIds(Set<Integer> uniqueIds);
|
void purgeIds(Set<Integer> uniqueIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge a whole world.
|
* Purges a whole world.
|
||||||
*
|
*
|
||||||
* @param area World in which the plots should be purged
|
* @param area World in which the plots should be purged
|
||||||
* @param plotIds the {@code PlotId}s of {@code Plot}s to purge
|
* @param plotIds the {@code PlotId}s of {@code Plot}s to purge
|
||||||
@ -175,7 +175,7 @@ public interface AbstractDB {
|
|||||||
void purge(PlotArea area, Set<PlotId> plotIds);
|
void purge(PlotArea area, Set<PlotId> plotIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the plot home position.
|
* Sets the plot home position.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param position the position of plot home
|
* @param position the position of plot home
|
||||||
@ -239,7 +239,7 @@ public interface AbstractDB {
|
|||||||
void setInvited(PlotCluster cluster, UUID uuid);
|
void setInvited(PlotCluster cluster, UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified player from the denied list of the specified plot.
|
* Removes the specified player from the denied list of the specified plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param uuid the uuid of the player to remove
|
* @param uuid the uuid of the player to remove
|
||||||
@ -247,7 +247,7 @@ public interface AbstractDB {
|
|||||||
void removeDenied(Plot plot, UUID uuid);
|
void removeDenied(Plot plot, UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deny the specified player from the given plot.
|
* Denies the specified player from the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param uuid the uuid of the player to deny
|
* @param uuid the uuid of the player to deny
|
||||||
@ -255,7 +255,7 @@ public interface AbstractDB {
|
|||||||
void setDenied(Plot plot, UUID uuid);
|
void setDenied(Plot plot, UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ratings from the specified plot.
|
* Gets the ratings from the specified plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @return the plot ratings (pre-calculated)
|
* @return the plot ratings (pre-calculated)
|
||||||
@ -263,7 +263,7 @@ public interface AbstractDB {
|
|||||||
HashMap<UUID, Integer> getRatings(Plot plot);
|
HashMap<UUID, Integer> getRatings(Plot plot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a rating for a plot.
|
* Sets a rating for a plot.
|
||||||
*
|
*
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param rater
|
* @param rater
|
||||||
@ -272,7 +272,7 @@ public interface AbstractDB {
|
|||||||
void setRating(Plot plot, UUID rater, int value);
|
void setRating(Plot plot, UUID rater, int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified comment from the given plot.
|
* Removes the specified comment from the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param comment the comment to remove
|
* @param comment the comment to remove
|
||||||
@ -280,7 +280,7 @@ public interface AbstractDB {
|
|||||||
void removeComment(Plot plot, PlotComment comment);
|
void removeComment(Plot plot, PlotComment comment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the specified inbox on the given plot.
|
* Clears the specified inbox on the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param inbox the inbox to clear
|
* @param inbox the inbox to clear
|
||||||
@ -288,7 +288,7 @@ public interface AbstractDB {
|
|||||||
void clearInbox(Plot plot, String inbox);
|
void clearInbox(Plot plot, String inbox);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the specified comment to the given plot.
|
* Adds the specified comment to the given plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot
|
* @param plot the plot
|
||||||
* @param comment the comment to add
|
* @param comment the comment to add
|
||||||
@ -296,7 +296,7 @@ public interface AbstractDB {
|
|||||||
void setComment(Plot plot, PlotComment comment);
|
void setComment(Plot plot, PlotComment comment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plot Comments.
|
* Gets Plot Comments.
|
||||||
*
|
*
|
||||||
* @param plot The Plot to get comments from
|
* @param plot The Plot to get comments from
|
||||||
*/
|
*/
|
||||||
@ -311,7 +311,7 @@ public interface AbstractDB {
|
|||||||
void movePlot(Plot originalPlot, Plot newPlot);
|
void movePlot(Plot originalPlot, Plot newPlot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a old uuid with a new one in the database.
|
* Replaces a old uuid with a new one in the database.
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li> Useful for replacing a few uuids (not the entire database).</li>
|
* <li> Useful for replacing a few uuids (not the entire database).</li>
|
||||||
@ -331,7 +331,7 @@ public interface AbstractDB {
|
|||||||
boolean deleteTables();
|
boolean deleteTables();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the database. Generally not recommended to be used by add-ons.
|
* Closes the database. Generally not recommended to be used by add-ons.
|
||||||
*/
|
*/
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
@ -29,9 +29,10 @@ public class PlotId {
|
|||||||
* Get a Plot Id based on a string
|
* Get a Plot Id based on a string
|
||||||
*
|
*
|
||||||
* @param string to create id from
|
* @param string to create id from
|
||||||
* @return null if the string is invalid
|
* @return the PlotId representation of the arguement
|
||||||
|
* @throws IllegalArgumentException if the string does not contain a valid PlotId
|
||||||
*/
|
*/
|
||||||
public static PlotId fromString(@Nonnull String string) {
|
@Nonnull public static PlotId fromString(@Nonnull String string) {
|
||||||
String[] parts = string.split("[;|,]");
|
String[] parts = string.split("[;|,]");
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
|
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");
|
||||||
|
@ -63,34 +63,22 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
|
|
||||||
@Nullable @Override public Plot getOwnedPlot(@Nonnull final Location location) {
|
@Nullable @Override public Plot getOwnedPlot(@Nonnull final Location location) {
|
||||||
PlotId pid = PlotId.fromString(location.getWorld());
|
PlotId pid = PlotId.fromString(location.getWorld());
|
||||||
if (pid == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Plot plot = this.plots.get(pid);
|
Plot plot = this.plots.get(pid);
|
||||||
return plot == null ? null : plot.getBasePlot(false);
|
return plot == null ? null : plot.getBasePlot(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @Override public Plot getOwnedPlotAbs(@Nonnull Location location) {
|
@Nullable @Override public Plot getOwnedPlotAbs(@Nonnull Location location) {
|
||||||
PlotId pid = PlotId.fromString(location.getWorld());
|
PlotId pid = PlotId.fromString(location.getWorld());
|
||||||
if (pid == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return plots.get(pid);
|
return plots.get(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @Override public Plot getPlot(@Nonnull final Location location) {
|
@Nullable @Override public Plot getPlot(@Nonnull final Location location) {
|
||||||
PlotId pid = PlotId.fromString(location.getWorld());
|
PlotId pid = PlotId.fromString(location.getWorld());
|
||||||
if (pid == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getPlot(pid);
|
return getPlot(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @Override public Plot getPlotAbs(@Nonnull final Location location) {
|
@Nullable @Override public Plot getPlotAbs(@Nonnull final Location location) {
|
||||||
final PlotId pid = PlotId.fromString(location.getWorld());
|
final PlotId pid = PlotId.fromString(location.getWorld());
|
||||||
if (pid == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getPlotAbs(pid);
|
return getPlotAbs(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,41 +71,39 @@ public abstract class ChunkManager {
|
|||||||
|
|
||||||
public static void largeRegionTask(final String world, final RegionWrapper region,
|
public static void largeRegionTask(final String world, final RegionWrapper region,
|
||||||
final RunnableVal<ChunkLoc> task, final Runnable whenDone) {
|
final RunnableVal<ChunkLoc> task, final Runnable whenDone) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||||
HashSet<ChunkLoc> chunks = new HashSet<>();
|
Set<ChunkLoc> mcrs = manager.getChunkChunks(world);
|
||||||
Set<ChunkLoc> mcrs = manager.getChunkChunks(world);
|
for (ChunkLoc mcr : mcrs) {
|
||||||
for (ChunkLoc mcr : mcrs) {
|
int bx = mcr.x << 9;
|
||||||
int bx = mcr.x << 9;
|
int bz = mcr.z << 9;
|
||||||
int bz = mcr.z << 9;
|
int tx = bx + 511;
|
||||||
int tx = bx + 511;
|
int tz = bz + 511;
|
||||||
int tz = bz + 511;
|
if (bx <= region.maxX && tx >= region.minX && bz <= region.maxZ
|
||||||
if (bx <= region.maxX && tx >= region.minX && bz <= region.maxZ
|
&& tz >= region.minZ) {
|
||||||
&& tz >= region.minZ) {
|
for (int x = bx >> 4; x <= (tx >> 4); x++) {
|
||||||
for (int x = bx >> 4; x <= (tx >> 4); x++) {
|
int cbx = x << 4;
|
||||||
int cbx = x << 4;
|
int ctx = cbx + 15;
|
||||||
int ctx = cbx + 15;
|
if (cbx <= region.maxX && ctx >= region.minX) {
|
||||||
if (cbx <= region.maxX && ctx >= region.minX) {
|
for (int z = bz >> 4; z <= (tz >> 4); z++) {
|
||||||
for (int z = bz >> 4; z <= (tz >> 4); z++) {
|
int cbz = z << 4;
|
||||||
int cbz = z << 4;
|
int ctz = cbz + 15;
|
||||||
int ctz = cbz + 15;
|
if (cbz <= region.maxZ && ctz >= region.minZ) {
|
||||||
if (cbz <= region.maxZ && ctz >= region.minZ) {
|
chunks.add(new ChunkLoc(x, z));
|
||||||
chunks.add(new ChunkLoc(x, z));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TaskManager.objectTask(chunks, new RunnableVal<ChunkLoc>() {
|
|
||||||
|
|
||||||
@Override public void run(ChunkLoc value) {
|
|
||||||
if (manager.loadChunk(world, value, false)) {
|
|
||||||
task.run(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, whenDone);
|
|
||||||
}
|
}
|
||||||
|
TaskManager.objectTask(chunks, new RunnableVal<ChunkLoc>() {
|
||||||
|
|
||||||
|
@Override public void run(ChunkLoc value) {
|
||||||
|
if (manager.loadChunk(world, value, false)) {
|
||||||
|
task.run(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, whenDone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.object.*;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream;
|
import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -22,6 +23,8 @@ import java.nio.file.Paths;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot functions
|
* plot functions
|
||||||
@ -324,7 +327,7 @@ public class MainUtil {
|
|||||||
* @param owner
|
* @param owner
|
||||||
* @return The player's name, None, Everyone or Unknown
|
* @return The player's name, None, Everyone or Unknown
|
||||||
*/
|
*/
|
||||||
public static String getName(UUID owner) {
|
@Nonnull public static String getName(UUID owner) {
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
return C.NONE.s();
|
return C.NONE.s();
|
||||||
}
|
}
|
||||||
@ -346,7 +349,7 @@ public class MainUtil {
|
|||||||
* @return
|
* @return
|
||||||
* @see Plot#getCorners()
|
* @see Plot#getCorners()
|
||||||
*/
|
*/
|
||||||
public static Location[] getCorners(String world, Collection<RegionWrapper> regions) {
|
@Nonnull public static Location[] getCorners(String world, Collection<RegionWrapper> regions) {
|
||||||
Location min = null;
|
Location min = null;
|
||||||
Location max = null;
|
Location max = null;
|
||||||
for (RegionWrapper region : regions) {
|
for (RegionWrapper region : regions) {
|
||||||
@ -399,20 +402,12 @@ public class MainUtil {
|
|||||||
uuids.add(uuid);
|
uuids.add(uuid);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
id = PlotId.fromString(term);
|
id = PlotId.fromString(term);
|
||||||
if (id != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
area = PlotSquared.get().getPlotAreaByString(term);
|
|
||||||
if (area == null) {
|
|
||||||
alias = term;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<ArrayList<Plot>> plotList = new ArrayList<>(size);
|
ArrayList<ArrayList<Plot>> plotList =
|
||||||
for (int i = 0; i < size; i++) {
|
IntStream.range(0, size).mapToObj(i -> new ArrayList<Plot>())
|
||||||
plotList.add(new ArrayList<Plot>());
|
.collect(Collectors.toCollection(() -> new ArrayList<>(size)));
|
||||||
}
|
|
||||||
|
|
||||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -505,12 +500,6 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (id == null) {
|
|
||||||
if (message) {
|
|
||||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (message) {
|
if (message) {
|
||||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||||
@ -780,31 +769,28 @@ public class MainUtil {
|
|||||||
info = info.replace("%desc%", "No description set.");
|
info = info.replace("%desc%", "No description set.");
|
||||||
if (info.contains("%rating%")) {
|
if (info.contains("%rating%")) {
|
||||||
final String newInfo = info;
|
final String newInfo = info;
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
int max = 10;
|
||||||
int max = 10;
|
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
|
||||||
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES
|
max = 8;
|
||||||
.isEmpty()) {
|
|
||||||
max = 8;
|
|
||||||
}
|
|
||||||
String info;
|
|
||||||
if (full && Settings.Ratings.CATEGORIES != null
|
|
||||||
&& Settings.Ratings.CATEGORIES.size() > 1) {
|
|
||||||
double[] ratings = MainUtil.getAverageRatings(plot);
|
|
||||||
String rating = "";
|
|
||||||
String prefix = "";
|
|
||||||
for (int i = 0; i < ratings.length; i++) {
|
|
||||||
rating += prefix + Settings.Ratings.CATEGORIES.get(i) + '=' + String
|
|
||||||
.format("%.1f", ratings[i]);
|
|
||||||
prefix = ",";
|
|
||||||
}
|
|
||||||
info = newInfo.replaceAll("%rating%", rating);
|
|
||||||
} else {
|
|
||||||
info = newInfo.replaceAll("%rating%",
|
|
||||||
String.format("%.1f", plot.getAverageRating()) + '/' + max);
|
|
||||||
}
|
|
||||||
whenDone.run(info);
|
|
||||||
}
|
}
|
||||||
|
String info1;
|
||||||
|
if (full && Settings.Ratings.CATEGORIES != null
|
||||||
|
&& Settings.Ratings.CATEGORIES.size() > 1) {
|
||||||
|
double[] ratings = MainUtil.getAverageRatings(plot);
|
||||||
|
String rating = "";
|
||||||
|
String prefix = "";
|
||||||
|
for (int i = 0; i < ratings.length; i++) {
|
||||||
|
rating += prefix + Settings.Ratings.CATEGORIES.get(i) + '=' + String
|
||||||
|
.format("%.1f", ratings[i]);
|
||||||
|
prefix = ",";
|
||||||
|
}
|
||||||
|
info1 = newInfo.replaceAll("%rating%", rating);
|
||||||
|
} else {
|
||||||
|
info1 = newInfo.replaceAll("%rating%",
|
||||||
|
String.format("%.1f", plot.getAverageRating()) + '/' + max);
|
||||||
|
}
|
||||||
|
whenDone.run(info1);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -815,10 +801,9 @@ public class MainUtil {
|
|||||||
if (directory.exists()) {
|
if (directory.exists()) {
|
||||||
File[] files = directory.listFiles();
|
File[] files = directory.listFiles();
|
||||||
if (null != files) {
|
if (null != files) {
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (File file : files) {
|
||||||
File file = files[i];
|
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
deleteDirectory(files[i]);
|
deleteDirectory(file);
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.debug("Deleting file: " + file + " | " + file.delete());
|
PlotSquared.debug("Deleting file: " + file + " | " + file.delete());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user