Javadoc changes and cleaning of old unused code

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt 2019-02-08 14:49:37 -05:00
parent e891873d28
commit 17027e6292
10 changed files with 128 additions and 192 deletions

View File

@ -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
}
@Override public void registerPlotPlusEvents() {

View File

@ -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;

View File

@ -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.
*
* <ul>
* <li>If a full disable isn't feasibly, just disable what it can.
* </ul>
*/
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
*/

View File

@ -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<PlotCluster> clusters = this.clusters_tmp != null ?
this.clusters_tmp.get(world) :
new HashSet<PlotCluster>();
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<PlotArea> runnable) {
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
runnable.run(area);
}

View File

@ -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<String> lines = new ArrayList<>();
final List<String> 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");

View File

@ -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<Plot> 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<Map<String, byte[]>> result);
/**
* Create the plot settings.
* Creates the plot settings.
*
* @param id the plot entry id
* @param plot the plot
@ -89,7 +89,7 @@ public interface AbstractDB {
void createPlotSettings(int id, Plot plot);
/**
* Get the table entry ID.
* Gets the table entry ID.
*
* @param plot the plot
* @return {@code Integer} = Plot Entry Id
@ -97,7 +97,7 @@ public interface AbstractDB {
int getId(Plot plot);
/**
* Get the id of a given plot cluster.
* Gets the id of a given plot cluster.
*
* @param cluster PlotCluster Object
* @return Integer = Cluster Entry Id
@ -120,7 +120,7 @@ public interface AbstractDB {
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 merged boolean[]
@ -128,7 +128,7 @@ public interface AbstractDB {
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 plot2 Plot2
@ -136,7 +136,7 @@ public interface AbstractDB {
void swapPlots(Plot plot1, Plot plot2);
/**
* Set plot flags.
* Sets plot flags.
*
* @param plot Plot Object
* @param flags flags to set
@ -144,7 +144,7 @@ public interface AbstractDB {
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 name the new cluster name
@ -152,7 +152,7 @@ public interface AbstractDB {
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 alias Plot Alias
@ -160,14 +160,14 @@ public interface AbstractDB {
void setAlias(Plot plot, String alias);
/**
* Purge a plot.
* Purges a plot.
*
* @param uniqueIds list of plot id (db) to be purged
*/
void purgeIds(Set<Integer> uniqueIds);
/**
* Purge a whole world.
* Purges a whole world.
*
* @param area World in which the plots should be purged
* @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);
/**
* Set the plot home position.
* Sets the plot home position.
*
* @param plot the plot
* @param position the position of plot home
@ -239,7 +239,7 @@ public interface AbstractDB {
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 uuid the uuid of the player to remove
@ -247,7 +247,7 @@ public interface AbstractDB {
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 uuid the uuid of the player to deny
@ -255,7 +255,7 @@ public interface AbstractDB {
void setDenied(Plot plot, UUID uuid);
/**
* Get the ratings from the specified plot.
* Gets the ratings from the specified plot.
*
* @param plot the plot
* @return the plot ratings (pre-calculated)
@ -263,7 +263,7 @@ public interface AbstractDB {
HashMap<UUID, Integer> getRatings(Plot plot);
/**
* Set a rating for a plot.
* Sets a rating for a plot.
*
* @param plot
* @param rater
@ -272,7 +272,7 @@ public interface AbstractDB {
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 comment the comment to remove
@ -280,7 +280,7 @@ public interface AbstractDB {
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 inbox the inbox to clear
@ -288,7 +288,7 @@ public interface AbstractDB {
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 comment the comment to add
@ -296,7 +296,7 @@ public interface AbstractDB {
void setComment(Plot plot, PlotComment comment);
/**
* Get Plot Comments.
* Gets Plot Comments.
*
* @param plot The Plot to get comments from
*/
@ -311,7 +311,7 @@ public interface AbstractDB {
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>
* <li> Useful for replacing a few uuids (not the entire database).</li>
@ -331,7 +331,7 @@ public interface AbstractDB {
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();

View File

@ -29,9 +29,10 @@ public class PlotId {
* Get a Plot Id based on a string
*
* @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("[;|,]");
if (parts.length < 2) {
throw new IllegalArgumentException("Cannot create PlotID. String invalid.");

View File

@ -63,34 +63,22 @@ public class SinglePlotArea extends GridPlotWorld {
@Nullable @Override public Plot getOwnedPlot(@Nonnull final Location location) {
PlotId pid = PlotId.fromString(location.getWorld());
if (pid == null) {
return null;
}
Plot plot = this.plots.get(pid);
return plot == null ? null : plot.getBasePlot(false);
}
@Nullable @Override public Plot getOwnedPlotAbs(@Nonnull Location location) {
PlotId pid = PlotId.fromString(location.getWorld());
if (pid == null) {
return null;
}
return plots.get(pid);
}
@Nullable @Override public Plot getPlot(@Nonnull final Location location) {
PlotId pid = PlotId.fromString(location.getWorld());
if (pid == null) {
return null;
}
return getPlot(pid);
}
@Nullable @Override public Plot getPlotAbs(@Nonnull final Location location) {
final PlotId pid = PlotId.fromString(location.getWorld());
if (pid == null) {
return null;
}
return getPlotAbs(pid);
}

View File

@ -71,8 +71,7 @@ public abstract class ChunkManager {
public static void largeRegionTask(final String world, final RegionWrapper region,
final RunnableVal<ChunkLoc> task, final Runnable whenDone) {
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
TaskManager.runTaskAsync(() -> {
HashSet<ChunkLoc> chunks = new HashSet<>();
Set<ChunkLoc> mcrs = manager.getChunkChunks(world);
for (ChunkLoc mcr : mcrs) {
@ -105,7 +104,6 @@ public abstract class ChunkManager {
}
}
}, whenDone);
}
});
}

View File

@ -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.util.expiry.ExpireManager;
import javax.annotation.Nonnull;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@ -22,6 +23,8 @@ import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* plot functions
@ -324,7 +327,7 @@ public class MainUtil {
* @param owner
* @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) {
return C.NONE.s();
}
@ -346,7 +349,7 @@ public class MainUtil {
* @return
* @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 max = null;
for (RegionWrapper region : regions) {
@ -399,20 +402,12 @@ public class MainUtil {
uuids.add(uuid);
} catch (Exception ignored) {
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);
for (int i = 0; i < size; i++) {
plotList.add(new ArrayList<Plot>());
}
ArrayList<ArrayList<Plot>> plotList =
IntStream.range(0, size).mapToObj(i -> new ArrayList<Plot>())
.collect(Collectors.toCollection(() -> new ArrayList<>(size)));
for (Plot plot : PlotSquared.get().getPlots()) {
int count = 0;
@ -505,12 +500,6 @@ public class MainUtil {
}
return null;
}
if (id == null) {
if (message) {
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
}
return null;
}
if (area == null) {
if (message) {
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
@ -780,14 +769,12 @@ public class MainUtil {
info = info.replace("%desc%", "No description set.");
if (info.contains("%rating%")) {
final String newInfo = info;
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
TaskManager.runTaskAsync(() -> {
int max = 10;
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES
.isEmpty()) {
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
max = 8;
}
String info;
String info1;
if (full && Settings.Ratings.CATEGORIES != null
&& Settings.Ratings.CATEGORIES.size() > 1) {
double[] ratings = MainUtil.getAverageRatings(plot);
@ -798,13 +785,12 @@ public class MainUtil {
.format("%.1f", ratings[i]);
prefix = ",";
}
info = newInfo.replaceAll("%rating%", rating);
info1 = newInfo.replaceAll("%rating%", rating);
} else {
info = newInfo.replaceAll("%rating%",
info1 = newInfo.replaceAll("%rating%",
String.format("%.1f", plot.getAverageRating()) + '/' + max);
}
whenDone.run(info);
}
whenDone.run(info1);
});
return;
}
@ -815,10 +801,9 @@ public class MainUtil {
if (directory.exists()) {
File[] files = directory.listFiles();
if (null != files) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
for (File file : files) {
if (file.isDirectory()) {
deleteDirectory(files[i]);
deleteDirectory(file);
} else {
PlotSquared.debug("Deleting file: " + file + " | " + file.delete());
}