diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/uuid/SQLUUIDHandler.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/uuid/SQLUUIDHandler.java index 86cd9ae0d..4c74be5b6 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/uuid/SQLUUIDHandler.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -31,13 +31,13 @@ import java.util.ArrayDeque; import java.util.Collections; import java.util.HashMap; import java.util.UUID; +import java.util.concurrent.TimeUnit; public class SQLUUIDHandler extends UUIDHandlerImplementation { final int MAX_REQUESTS = 500; private final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/"; - private final int INTERVAL = 12000; private final JSONParser jsonParser = new JSONParser(); private final SQLite sqlite; @@ -133,7 +133,10 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { "Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)"); } try { - Thread.sleep(INTERVAL * 50); + //Mojang allows requests every 10 minutes according to https://wiki.vg/Mojang_API + //15 Minutes is chosen here since system timers are not always precise + //and it should provide enough time where Mojang won't block requests. + TimeUnit.MINUTES.sleep(15); } catch (InterruptedException e) { e.printStackTrace(); break; @@ -142,7 +145,6 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { if (whenDone != null) { whenDone.run(); } - return; }); }); } catch (SQLException e) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/ConfigurationOptions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/ConfigurationOptions.java index 5d13920e4..81c96196d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/ConfigurationOptions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/ConfigurationOptions.java @@ -6,7 +6,6 @@ package com.github.intellectualsites.plotsquared.configuration; */ class ConfigurationOptions { private final Configuration configuration; - private char pathSeparator = '.'; private boolean copyDefaults = false; protected ConfigurationOptions(Configuration configuration) { @@ -26,28 +25,12 @@ class ConfigurationOptions { * Gets the char that will be used to separate {@link * ConfigurationSection}s. * - *

This value does not affect how the {@link Configuration} is stored, - * only in how you access the data. The default value is '.'. + *

This value is always '.'. * * @return Path separator */ - public char pathSeparator() { - return pathSeparator; - } - - /** - * Sets the char that will be used to separate {@link - * ConfigurationSection}s. - * - *

This value does not affect how the {@link Configuration} is stored, - * only in how you access the data. The default value is '.'. - * - * @param value Path separator - * @return This object, for chaining - */ - public ConfigurationOptions pathSeparator(char value) { - pathSeparator = value; - return this; + char pathSeparator() { + return '.'; } /** diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/MemoryConfigurationOptions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/MemoryConfigurationOptions.java index 971ea1e70..22f9d751b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/MemoryConfigurationOptions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/MemoryConfigurationOptions.java @@ -18,8 +18,4 @@ public class MemoryConfigurationOptions extends ConfigurationOptions { return this; } - @Override public MemoryConfigurationOptions pathSeparator(char value) { - super.pathSeparator(value); - return this; - } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/FileConfigurationOptions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/FileConfigurationOptions.java index a216d0566..6eb99bb6e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/FileConfigurationOptions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/FileConfigurationOptions.java @@ -25,11 +25,6 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { return this; } - @Override public FileConfigurationOptions pathSeparator(char value) { - super.pathSeparator(value); - return this; - } - /** * Gets the header that will be applied to the top of the saved output. * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/YamlConfigurationOptions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/YamlConfigurationOptions.java index a17bc3538..a7e71cdaf 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/YamlConfigurationOptions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/configuration/file/YamlConfigurationOptions.java @@ -5,7 +5,6 @@ package com.github.intellectualsites.plotsquared.configuration.file; * YamlConfiguration}. */ public class YamlConfigurationOptions extends FileConfigurationOptions { - private int indent = 2; YamlConfigurationOptions(YamlConfiguration configuration) { super(configuration); @@ -20,11 +19,6 @@ public class YamlConfigurationOptions extends FileConfigurationOptions { return this; } - @Override public YamlConfigurationOptions pathSeparator(char value) { - super.pathSeparator(value); - return this; - } - @Override public YamlConfigurationOptions header(String value) { super.header(value); return this; @@ -42,27 +36,8 @@ public class YamlConfigurationOptions extends FileConfigurationOptions { * * @return How much to indent by */ - public int indent() { - return indent; + int indent() { + return 2; } - /** - * Sets how much spaces should be used to indent each line. - * - *

The minimum value this may be is 2, and the maximum is 9. - * - * @param value New indent - * @return This object, for chaining - */ - public YamlConfigurationOptions indent(int value) { - if (value < 2) { - throw new IllegalArgumentException("Indent must be at least 2 characters"); - } - if (value > 9) { - throw new IllegalArgumentException("Indent cannot be greater than 9 characters"); - } - - indent = value; - return this; - } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java index c9bba547a..e26cffaed 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java @@ -24,10 +24,9 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan; import java.util.*; -@CommandDeclaration(command = "setflag", aliases = {"f", "flag", "setf", "setflag"}, - usage = "/plot flag ", description = "Set plot flags", - category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, - permission = "plots.flag") public class FlagCmd extends SubCommand { +@CommandDeclaration(command = "setflag", aliases = {"f", "flag", + "setflag"}, usage = "/plot flag ", description = "Set plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag") +public class FlagCmd extends SubCommand { private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) { key = key.toLowerCase(); 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 8d427bbcd..899139b98 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 @@ -149,8 +149,14 @@ import java.util.List; } PlotComment comment = value.get(index - 1); inbox.removeComment(plot, comment); - plot.removeComment(comment); - MainUtil.sendMessage(player, Captions.COMMENT_REMOVED, comment.comment); + boolean success = plot.removeComment(comment); + //noinspection StatementWithEmptyBody + if (success) { + MainUtil + .sendMessage(player, Captions.COMMENT_REMOVED, comment.comment); + } else { + //TODO Comment removal failure message + } } })) { sendMessage(player, Captions.NOT_IN_PLOT); 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 dc9564371..5beef2aab 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 @@ -1,12 +1,19 @@ package com.github.intellectualsites.plotsquared.plot.database; import com.github.intellectualsites.plotsquared.plot.flag.Flag; -import com.github.intellectualsites.plotsquared.plot.object.*; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; +import com.github.intellectualsites.plotsquared.plot.object.PlotId; +import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; public interface AbstractDB { @@ -224,7 +231,7 @@ public interface AbstractDB { /** * @param cluster PlotCluster Object - * @param uuid Player that should be removed + * @param uuid Player that should be removed */ void setHelper(PlotCluster cluster, UUID uuid); @@ -276,7 +283,7 @@ public interface AbstractDB { /** * Removes the specified comment from the given plot. * - * @param plot the plot + * @param plot the plot * @param comment the comment to remove */ void removeComment(Plot plot, PlotComment comment); @@ -284,7 +291,7 @@ public interface AbstractDB { /** * Clears the specified inbox on the given plot. * - * @param plot the plot + * @param plot the plot * @param inbox the inbox to clear */ void clearInbox(Plot plot, String inbox); @@ -292,13 +299,13 @@ public interface AbstractDB { /** * Adds the specified comment to the given plot. * - * @param plot the plot + * @param plot the plot * @param comment the comment to add */ void setComment(Plot plot, PlotComment comment); /** - * Gets Plot Comments. + * Gets Plot comments. * * @param plot The Plot to get comments from */ diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java index abb4dad24..47a03cf60 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java @@ -1,13 +1,21 @@ package com.github.intellectualsites.plotsquared.plot.database; import com.github.intellectualsites.plotsquared.plot.flag.Flag; -import com.github.intellectualsites.plotsquared.plot.object.*; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotCluster; +import com.github.intellectualsites.plotsquared.plot.object.PlotId; +import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; /** * Database Functions @@ -74,6 +82,8 @@ public class DBFunc { DBFunc.dbManager.validateAllPlots(plots); } + + //TODO Consider Removal /** * Check if a {@link ResultSet} contains a column. * @@ -81,7 +91,7 @@ public class DBFunc { * @param name * @return */ - public static boolean hasColumn(ResultSet resultSet, String name) { + @Deprecated public static boolean hasColumn(ResultSet resultSet, String name) { try { ResultSetMetaData meta = resultSet.getMetaData(); int count = meta.getColumnCount(); 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 118733f36..1827bbb64 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 @@ -24,29 +24,21 @@ public class ClassicPlotManager extends SquarePlotManager { BlockBucket blocks) { switch (component) { case "floor": - setFloor(plotId, blocks); - return true; + return setFloor(plotId, blocks); case "wall": - setWallFilling(plotId, blocks); - return true; + return setWallFilling(plotId, blocks); case "all": - setAll(plotId, blocks); - return true; + return setAll(plotId, blocks); case "air": - setAir(plotId, blocks); - return true; + return setAir(plotId, blocks); case "main": - setMain(plotId, blocks); - return true; + return setMain(plotId, blocks); case "middle": - setMiddle(plotId, blocks); - return true; + return setMiddle(plotId, blocks); case "outline": - setOutline(plotId, blocks); - return true; + return setOutline(plotId, blocks); case "border": - setWall(plotId, blocks); - return true; + return setWall(plotId, blocks); } return false; } @@ -54,8 +46,7 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean unClaimPlot(Plot plot, Runnable whenDone) { setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING); setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); - GlobalBlockQueue.IMP.addTask(whenDone); - return true; + return GlobalBlockQueue.IMP.addTask(whenDone); } public boolean setFloor(PlotId plotId, BlockBucket blocks) { @@ -70,8 +61,7 @@ public class ClassicPlotManager extends SquarePlotManager { queue.setCuboid(pos1, pos2, blocks); } } - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setAll(PlotId plotId, BlockBucket blocks) { @@ -86,8 +76,7 @@ public class ClassicPlotManager extends SquarePlotManager { Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); queue.setCuboid(pos1, pos2, blocks); } - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setAir(PlotId plotId, BlockBucket blocks) { @@ -103,8 +92,7 @@ public class ClassicPlotManager extends SquarePlotManager { Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); queue.setCuboid(pos1, pos2, blocks); } - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setMain(PlotId plotId, BlockBucket blocks) { @@ -119,8 +107,7 @@ public class ClassicPlotManager extends SquarePlotManager { new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT - 1, region.maxZ); queue.setCuboid(pos1, pos2, blocks); } - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setMiddle(PlotId plotId, BlockBucket blocks) { @@ -134,8 +121,7 @@ public class ClassicPlotManager extends SquarePlotManager { int x = MathMan.average(corners[0].getX(), corners[1].getX()); int z = MathMan.average(corners[0].getZ(), corners[1].getZ()); queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks.getBlock()); - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setOutline(PlotId plotId, BlockBucket blocks) { @@ -187,8 +173,7 @@ public class ClassicPlotManager extends SquarePlotManager { queue.setCuboid(pos1, pos2, blocks); } } - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setWallFilling(PlotId plotId, BlockBucket blocks) { @@ -235,8 +220,7 @@ public class ClassicPlotManager extends SquarePlotManager { } } } - queue.enqueue(); - return true; + return queue.enqueue(); } public boolean setWall(PlotId plotId, BlockBucket blocks) { @@ -276,8 +260,7 @@ public class ClassicPlotManager extends SquarePlotManager { queue.setBlock(x, y, z, blocks.getBlock()); } } - queue.enqueue(); - return true; + return queue.enqueue(); } /** @@ -308,8 +291,7 @@ public class ClassicPlotManager extends SquarePlotManager { new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK); queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK); - queue.enqueue(); - return true; + return queue.enqueue(); } @Override public boolean createRoadSouth(Plot plot) { @@ -337,8 +319,7 @@ public class ClassicPlotManager extends SquarePlotManager { new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK); queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK); - queue.enqueue(); - return true; + return queue.enqueue(); } @Override public boolean createRoadSouthEast(Plot plot) { @@ -356,8 +337,7 @@ public class ClassicPlotManager extends SquarePlotManager { PlotBlock.get((short) 7, (byte) 0)); queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK); - queue.enqueue(); - return true; + return queue.enqueue(); } @Override public boolean removeRoadEast(Plot plot) { @@ -377,8 +357,7 @@ public class ClassicPlotManager extends SquarePlotManager { new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK); queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1), new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), classicPlotWorld.TOP_BLOCK); - queue.enqueue(); - return true; + return queue.enqueue(); } @Override public boolean removeRoadSouth(Plot plot) { @@ -398,8 +377,7 @@ public class ClassicPlotManager extends SquarePlotManager { new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK); queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz), new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), classicPlotWorld.TOP_BLOCK); - queue.enqueue(); - return true; + return queue.enqueue(); } @Override public boolean removeRoadSouthEast(Plot plot) { @@ -416,14 +394,14 @@ public class ClassicPlotManager extends SquarePlotManager { new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK); queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz), new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), classicPlotWorld.TOP_BLOCK); - queue.enqueue(); - return true; + return queue.enqueue(); } /** * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED). */ @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)); if (Settings.General.MERGE_REPLACE_WALL) { @@ -434,12 +412,14 @@ public class ClassicPlotManager extends SquarePlotManager { } @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; } @Override public boolean regenerateAllPlotWalls() { + //TODO This method shouldn't always return true for (Plot plot : classicPlotWorld.getPlots()) { if (plot.hasOwner()) { setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK); @@ -460,8 +440,7 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean claimPlot(Plot plot) { final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; - setWall(plot.getId(), claim); - return true; + return setWall(plot.getId(), claim); } @Override public String[] getPlotComponents(PlotId plotId) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 27a04e402..30c5034a8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -2418,20 +2418,16 @@ public class Plot { * @param direction * @return */ - public Plot getRelative(int direction) { + @Deprecated public Plot getRelative(int direction) { return this.area.getPlotAbs(this.id.getRelative(direction)); } /** - * Gets the plot in a relative direction
- * 0 = north
- * 1 = east
- * 2 = south
- * 3 = west
+ * Gets the plot in a relative direction * Note: May be null if the partial plot area does not include the relative location * * @param direction - * @return + * @return the plot relative to this one */ public Plot getRelative(Direction direction) { return this.area.getPlotAbs(this.id.getRelative(direction)); @@ -2441,7 +2437,7 @@ public class Plot { * Gets a set of plots connected (and including) this plot
* - This result is cached globally * - * @return + * @return a Set of Plots connected to this Plot */ public Set getConnectedPlots() { if (this.settings == null) { @@ -2802,6 +2798,11 @@ public class Plot { return false; } + /** + * Checks if the owner of this Plot is online. + * + * @return true if the owner of the Plot is online + */ public boolean isOnline() { if (this.owner == null) { return false; @@ -3098,23 +3099,23 @@ public class Plot { return getFlags().containsKey(flag); } - @SuppressWarnings("deprecation") public boolean removeComment(PlotComment comment) { + public boolean removeComment(PlotComment comment) { return getSettings().removeComment(comment); } - @SuppressWarnings("deprecation") public void removeComments(List comments) { + public void removeComments(List comments) { getSettings().removeComments(comments); } - @SuppressWarnings("deprecation") public List getComments(String inbox) { + public List getComments(String inbox) { return getSettings().getComments(inbox); } - @SuppressWarnings("deprecation") public void addComment(PlotComment comment) { + public void addComment(PlotComment comment) { getSettings().addComment(comment); } - @SuppressWarnings("deprecation") public void setComments(List list) { + public void setComments(List list) { getSettings().setComments(list); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java index 0c797c706..c5c17b4a4 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java @@ -102,9 +102,10 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue { } } - @Override public void enqueue() { + @Override public boolean enqueue() { if (parent != null) { - parent.enqueue(); + return parent.enqueue(); } + return false; } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/GlobalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/GlobalBlockQueue.java index 6d75b6bfb..3373f8e57 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/GlobalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/GlobalBlockQueue.java @@ -45,10 +45,10 @@ public class GlobalBlockQueue { public GlobalBlockQueue(QueueProvider provider, int threads) { this.provider = provider; - activeQueues = new ConcurrentLinkedDeque<>(); - inactiveQueues = new ConcurrentLinkedDeque<>(); - runnables = new ConcurrentLinkedDeque<>(); - running = new AtomicBoolean(); + this.activeQueues = new ConcurrentLinkedDeque<>(); + this.inactiveQueues = new ConcurrentLinkedDeque<>(); + this.runnables = new ConcurrentLinkedDeque<>(); + this.running = new AtomicBoolean(); this.PARALLEL_THREADS = threads; } @@ -151,12 +151,20 @@ public class GlobalBlockQueue { return false; } - public void enqueue(LocalBlockQueue queue) { - inactiveQueues.remove(queue); + /** + * TODO Documentation needed. + * + * @param queue todo + * @return true if added to queue, false otherwise + */ + public boolean enqueue(LocalBlockQueue queue) { + boolean success = false; + success = inactiveQueues.remove(queue); if (queue.size() > 0 && !activeQueues.contains(queue)) { queue.optimize(); - activeQueues.add(queue); + success = activeQueues.add(queue); } + return success; } public void dequeue(LocalBlockQueue queue) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java index fd921c18c..04a9e2f0c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java @@ -96,8 +96,8 @@ public abstract class LocalBlockQueue { } } - public void enqueue() { - GlobalBlockQueue.IMP.enqueue(this); + public boolean enqueue() { + return GlobalBlockQueue.IMP.enqueue(this); } public void setCuboid(Location pos1, Location pos2, PlotBlock block) {