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 6e0587fdb..9596a25e9 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 @@ -132,8 +132,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain // Check for updates if (PlotSquared.get().getUpdateUtility() != null) { final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility(); - updateUtility - .checkForUpdate(this.getPluginVersionString(), ((updateDescription, throwable) -> { + updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(), + ((updateDescription, throwable) -> { Bukkit.getScheduler().runTask(BukkitMain.this, () -> { getLogger().info("-------- PlotSquared Update Check --------"); if (throwable != null) { @@ -803,4 +803,5 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public LegacyMappings getLegacyMappings() { return this.legacyMappings; } + } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index f56ce0763..9f3f0e0d4 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -642,7 +642,7 @@ import java.util.regex.Pattern; && PlotSquared.get().getUpdateUtility() != null) { final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility(); final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class); - updateUtility.checkForUpdate(bukkitMain.getPluginVersionString(), + updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(), ((updateDescription, throwable) -> { if (throwable != null) { bukkitMain.getLogger().severe(String diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java index 945d2d374..faaf3c7af 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java @@ -263,7 +263,7 @@ public abstract class Command { /** * @param player Caller - * @param args Arguments + * @param args Arguments * @param confirm Instance, Success, Failure * @return CompletableFuture true if the command executed fully, false in * any other case 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 e1eb152b5..8fff0921d 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 @@ -63,12 +63,12 @@ public interface IPlotMain extends ILogger { */ String getPluginVersionString(); - String getPluginName(); + default String getPluginName() { + return "PlotSquared"; + } /** * Gets the version of Minecraft that is running. - * - * @return */ int[] getServerVersion(); @@ -101,7 +101,7 @@ public interface IPlotMain extends ILogger { /** * The task manager will run and manage Minecraft tasks. * - * @return + * @return the PlotSquared task manager */ TaskManager getTaskManager(); @@ -138,49 +138,39 @@ public interface IPlotMain extends ILogger { /** * Gets the economy provider. * - * @return + * @return the PlotSquared economy manager */ EconHandler getEconomyHandler(); /** * Gets the {@link QueueProvider} class. - * - * @return */ QueueProvider initBlockQueue(); /** * Gets the {@link WorldUtil} class. - * - * @return */ WorldUtil initWorldUtil(); /** * Gets the EventUtil class. - * - * @return */ EventUtil initEventUtil(); /** * Gets the chunk manager. * - * @return + * @return the PlotSquared chunk manager */ ChunkManager initChunkManager(); /** * Gets the {@link SetupUtils} class. - * - * @return */ SetupUtils initSetupUtils(); /** * Gets {@link HybridUtils} class. - * - * @return */ HybridUtils initHybridUtils(); @@ -199,32 +189,28 @@ public interface IPlotMain extends ILogger { /** * Gets the {@link UUIDHandlerImplementation} which will cache and * provide UUIDs. - * - * @return */ UUIDHandlerImplementation initUUIDHandler(); /** * Gets the {@link InventoryUtil} class (used for implementation specific * inventory guis). - * - * @return */ InventoryUtil initInventoryUtil(); /** * Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off. * - * @param player + * @param player the player to remove */ void unregister(PlotPlayer player); /** * Gets the generator wrapper for a world (world) and generator (name). * - * @param world - * @param name - * @return + * @param world the world to get the generator from + * @param name the name of the generator + * @return the generator being used for the provided world */ GeneratorWrapper getGenerator(String world, String name); @@ -232,7 +218,7 @@ public interface IPlotMain extends ILogger { /** * Register the chunk processor which will clean out chunks that have too - * many blockstates or entities. + * many block states or entities. */ void registerChunkProcessor(); 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 414e2a0b3..8c6274b53 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 @@ -33,8 +33,8 @@ import com.sk89q.worldedit.WorldEdit; import lombok.Getter; import lombok.NonNull; import lombok.Setter; - import org.jetbrains.annotations.Nullable; + import java.io.*; import java.net.MalformedURLException; import java.net.URISyntaxException; @@ -1623,7 +1623,7 @@ import java.util.zip.ZipInputStream; final Properties properties = new Properties(); properties.load(bufferedReader); final boolean enabled = - Boolean.valueOf(properties.getOrDefault("enabled", true).toString()); + Boolean.parseBoolean(properties.getOrDefault("enabled", true).toString()); if (enabled) { this.updateUtility = new UpdateUtility(properties.getProperty("path"), properties.getProperty("job"), properties.getProperty("artifact")); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java index 27e1a6afb..4646a787a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java @@ -30,6 +30,13 @@ public class PlotVersion { } } + public String versionString() { + if (hash == 0 && build == 0) { + return "NoVer-SNAPSHOT"; + } else { + return "4." + build; + } + } @Override public String toString() { if (hash == 0 && build == 0) { return "PlotSquared-NoVer-SNAPSHOT"; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java index 899139b98..e7e2515c7 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java @@ -14,9 +14,8 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan; import java.util.List; @CommandDeclaration(command = "inbox", description = "Review the comments for a plot", - usage = "/plot inbox [inbox] [delete |clear|page]", permission = "plots.inbox", - category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) public class Inbox - extends SubCommand { + usage = "/plot inbox [inbox] [delete |clear|page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) +public class Inbox extends SubCommand { public void displayComments(PlotPlayer player, List oldComments, int page) { if (oldComments == null || oldComments.isEmpty()) { @@ -150,12 +149,13 @@ import java.util.List; PlotComment comment = value.get(index - 1); inbox.removeComment(plot, comment); boolean success = plot.removeComment(comment); - //noinspection StatementWithEmptyBody if (success) { - MainUtil - .sendMessage(player, Captions.COMMENT_REMOVED, comment.comment); + MainUtil.sendMessage(player, Captions.COMMENT_REMOVED_SUCCESS, + comment.comment); } else { - //TODO Comment removal failure message + MainUtil.sendMessage(player, Captions.COMMENT_REMOVED_FAILURE, + comment.comment); + } } })) { @@ -172,7 +172,7 @@ import java.util.List; if (!comments.isEmpty()) { plot.removeComments(comments); } - MainUtil.sendMessage(player, Captions.COMMENT_REMOVED, "*"); + MainUtil.sendMessage(player, Captions.COMMENT_REMOVED_SUCCESS, "*"); return true; default: try { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java index d284ce708..8e31051fb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java @@ -22,8 +22,8 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager; "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21"); MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki"); - MainUtil.sendMessage(player, - "$2>> $1&lNewest Version$2: $1" + getNewestVersionString()); + // MainUtil.sendMessage(player, + // "$2>> $1&lNewest Version$2: $1" + getNewestVersionString()); } }); return true; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index 9106cbbf3..b53aa42a2 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -280,13 +280,12 @@ public enum Captions { "Comment"), INVALID_INBOX("$2That is not a valid inbox.&-$1Accepted values: %s", "Comment"), NO_PERM_INBOX( - "$2You do not have permission for that inbox", "Comment"), - - NO_PERM_INBOX_MODIFY("$2You do not have permission to modify that inbox", - "Comment"), NO_PLOT_INBOX("$2You must stand in or supply a plot argument", "Comment"), - - COMMENT_REMOVED("$4Successfully deleted comment/s:n$2 - '$3%s$2'", "Comment"), COMMENT_ADDED( - "$4A comment has been left", "Comment"), + "$2You do not have permission for that inbox", "Comment"), NO_PERM_INBOX_MODIFY( + "$2You do not have permission to modify that inbox", "Comment"), NO_PLOT_INBOX( + "$2You must stand in or supply a plot argument", "Comment"), COMMENT_REMOVED_SUCCESS( + "$4Successfully deleted comment/s:n$2 - '$3%s$2'", "Comment"), COMMENT_REMOVED_FAILURE( + "$4Failed to delete comment!", "Comment"), COMMENT_ADDED("$4A comment has been left", + "Comment"), COMMENT_HEADER("$2&m---------&r $1Comments $2&m---------&r", "Comment"), INBOX_EMPTY( "$2No comments", "Comment"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java index 1827bbb64..320953963 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java @@ -399,35 +399,48 @@ public class ClassicPlotManager extends SquarePlotManager { /** * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED). + * + * @return false if part of the merge failed, otherwise true if successful. */ @Override public boolean finishPlotMerge(List plotIds) { - //TODO This method shouldn't always return true final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; - plotIds.forEach(id -> setWall(id, block)); + boolean success = true; + for (PlotId plotId : plotIds) { + success &= setWall(plotId, block); + } if (Settings.General.MERGE_REPLACE_WALL) { final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING; - plotIds.forEach(id -> setWallFilling(id, wallBlock)); + for (PlotId id : plotIds) { + success &= setWallFilling(id, wallBlock); + } } - return true; + return success; } @Override public boolean finishPlotUnlink(List plotIds) { - //TODO This method shouldn't always return true final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; - plotIds.forEach(id -> setWall(id, block)); - return true; + boolean success = true; + for (PlotId id : plotIds) { + success &= setWall(id, block); + } + return success; } + /** + * Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed). + * + * @return true if the wall blocks were successfully set + */ @Override public boolean regenerateAllPlotWalls() { - //TODO This method shouldn't always return true + boolean success = true; for (Plot plot : classicPlotWorld.getPlots()) { if (plot.hasOwner()) { - setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK); + success &= setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK); } else { - setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); + success &= setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); } } - return true; + return success; } @Override public boolean startPlotMerge(List plotIds) { @@ -448,7 +461,9 @@ public class ClassicPlotManager extends SquarePlotManager { } /** - * Remove sign for a plot. + * Retrieves the location of where a sign should be for a plot. + * @param plot The plot + * @return The location where a sign should be */ @Override public Location getSignLoc(Plot plot) { plot = plot.getBasePlot(false); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java index c3aaa3857..0a3fc4de6 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java @@ -147,8 +147,7 @@ public class HybridPlotManager extends ClassicPlotManager { if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { createSchemAbs(queue, pos1, pos2); } - queue.enqueue(); - return true; + return queue.enqueue(); } /** @@ -222,7 +221,9 @@ public class HybridPlotManager extends ClassicPlotManager { } /** - * Remove sign for a plot. + * Retrieves the location of where a sign should be for a plot. + * @param plot The plot + * @return The location where a sign should be */ @Override public Location getSignLoc(Plot plot) { return hybridPlotWorld.getSignLocation(plot); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java index 74f0eddb7..0b39b2b7d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java @@ -39,6 +39,12 @@ public abstract class PlotManager { public abstract boolean unClaimPlot(Plot plot, Runnable whenDone); + /** + * Retrieves the location of where a sign should be for a plot. + * + * @param plot The plot + * @return The location where a sign should be + */ public abstract Location getSignLoc(Plot plot); /* @@ -47,8 +53,7 @@ public abstract class PlotManager { */ public abstract String[] getPlotComponents(PlotId plotId); - public abstract boolean setComponent(PlotId plotId, String component, - BlockBucket blocks); + public abstract boolean setComponent(PlotId plotId, String component, BlockBucket blocks); /* * PLOT MERGING (return false if your generator does not support plot diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java index 6993c3208..7f44d2931 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java @@ -102,8 +102,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue { lastWrappedChunk.setBlock(x & 15, y, z & 15, id); LocalChunk previous = this.blockChunks.put(pair, lastWrappedChunk); if (previous == null) { - chunks.add(lastWrappedChunk); - return true; + return chunks.add(lastWrappedChunk); } this.blockChunks.put(pair, previous); lastWrappedChunk = previous;