diff --git a/.lift.toml b/.lift.toml index cee7a27a1..1501777dd 100644 --- a/.lift.toml +++ b/.lift.toml @@ -1,4 +1,4 @@ jdkVersion = "17" build = "gradle clean build -x test" tools = ["findsecbugs", "ErrorProne", "Semgrep", "Detekt", "Infer"] -ignoreRules = ["CatchAndPrintStackTrace", "ReferenceEquality", "FallThrough", "FutureReturnValueIgnored", "MixedMutabilityReturnType", "EmptyCatch", "MissingCasesInEnumSwitch", "OperatorPrecedence", "StaticAssignmentInConstructor", "ReferenceEquality", "EqualsHashCode", "EqualsGetClass", "TypeParameterUnusedInFormals"] +ignoreRules = ["CatchAndPrintStackTrace", "ReferenceEquality", "FallThrough", "FutureReturnValueIgnored", "MixedMutabilityReturnType", "EmptyCatch", "MissingCasesInEnumSwitch", "OperatorPrecedence", "StaticAssignmentInConstructor", "ReferenceEquality", "EqualsHashCode", "EqualsGetClass", "TypeParameterUnusedInFormals", "StringSplitter", "InlineMeSuggester", "NULL_DEREFERENCE"] diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java index 37a5c8e95..d7e06d63e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java @@ -60,7 +60,7 @@ import java.util.List; public class EntitySpawnListener implements Listener { - private final static String KEY = "P2"; + private static final String KEY = "P2"; private static boolean ignoreTP = false; private static boolean hasPlotArea = false; private static String areaName = null; diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 8db87c52d..991ba3a6b 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -342,6 +342,7 @@ public class PlotSquared { * @param plotArea the {@link PlotArea} to add. * @see #removePlotArea(PlotArea) To remove the reference */ + @SuppressWarnings("unchecked") public void addPlotArea(final @NonNull PlotArea plotArea) { HashMap plots; if (plots_tmp == null || (plots = plots_tmp.remove(plotArea.toString())) == null) { @@ -556,6 +557,7 @@ public class PlotSquared { * * @param input an array of plots to sort */ + @SuppressWarnings("unchecked") private void sortPlotsByHash(final @NonNull Plot @NonNull [] input) { List[] bucket = new ArrayList[32]; Arrays.fill(bucket, new ArrayList<>()); @@ -696,20 +698,12 @@ public class PlotSquared { ArrayList toReturn = new ArrayList<>(plots.size()); for (PlotArea area : areas) { switch (type) { - case CREATION_DATE: - toReturn.addAll(sortPlotsByTemp(map.get(area))); - break; - case CREATION_DATE_TIMESTAMP: - toReturn.addAll(sortPlotsByTimestamp(map.get(area))); - break; - case DISTANCE_FROM_ORIGIN: - toReturn.addAll(sortPlotsByHash(map.get(area))); - break; - case LAST_MODIFIED: - toReturn.addAll(sortPlotsByModified(map.get(area))); - break; - default: - break; + case CREATION_DATE -> toReturn.addAll(sortPlotsByTemp(map.get(area))); + case CREATION_DATE_TIMESTAMP -> toReturn.addAll(sortPlotsByTimestamp(map.get(area))); + case DISTANCE_FROM_ORIGIN -> toReturn.addAll(sortPlotsByHash(map.get(area))); + case LAST_MODIFIED -> toReturn.addAll(sortPlotsByModified(map.get(area))); + default -> { + } } } return toReturn; @@ -1540,7 +1534,7 @@ public class PlotSquared { } /** - * Register a caption map. The namespace needs be equal to the namespace used for + * Register a caption map. The namespace needs to be equal to the namespace used for * the {@link TranslatableCaption}s inside the map. * * @param namespace Namespace diff --git a/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java b/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java index 1d92f9fff..62aa64c5f 100644 --- a/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java +++ b/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java @@ -29,7 +29,8 @@ import java.util.Arrays; public class ArrayUtil { - public static final T[] concatAll(T[] first, T[]... rest) { + @SuppressWarnings("unchecked") + public static T[] concatAll(T[] first, T[]... rest) { int totalLength = first.length; for (T[] array : rest) { totalLength += array.length; diff --git a/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java b/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java index 900159364..c984e0cdc 100644 --- a/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java +++ b/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java @@ -35,6 +35,7 @@ public class FlatRandomCollection extends RandomCollection { private final T[] values; + @SuppressWarnings("unchecked") public FlatRandomCollection(Map weights, Random random) { super(weights, random); int max = 0; diff --git a/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java b/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java index b637ab805..e0d594fba 100644 --- a/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java +++ b/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java @@ -241,6 +241,7 @@ public class QuadMap { return false; } + @SuppressWarnings("unchecked") public void recalculateSkip() { QuadMap map = null; for (QuadMap current : new QuadMap[]{this.one, this.two, this.three, this.four}) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java index 3cd29b84b..94cf354f7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -58,6 +58,7 @@ import java.util.concurrent.CompletableFuture; public class Clear extends Command { private final EventDispatcher eventDispatcher; + @SuppressWarnings({"unused", "FieldCanBeLocal"}) private final GlobalBlockQueue blockQueue; @Inject diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java index e1260f87b..88a21b25c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -375,7 +375,6 @@ public abstract class Command { boolean failed = args.length < reqArgs.length; String[] baseSplit = getCommandString().split(" "); String[] fullSplit = getUsage().split(" "); - String base = getCommandString(); if (fullSplit.length - baseSplit.length < reqArgs.length) { String[] tmp = new String[baseSplit.length + reqArgs.length]; System.arraycopy(fullSplit, 0, tmp, 0, fullSplit.length); diff --git a/Core/src/main/java/com/plotsquared/core/command/Condense.java b/Core/src/main/java/com/plotsquared/core/command/Condense.java index 9bba21b5f..41c9c1b50 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -69,6 +69,7 @@ public class Condense extends SubCommand { this.worldUtil = worldUtil; } + @SuppressWarnings("unchecked") @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length != 2 && args.length != 3) { diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java index 581266057..eef9c965d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -255,7 +255,7 @@ public class DatabaseCommand extends SubCommand { player.sendMessage(TranslatableCaption.of("database.failed_to_save_plots")); player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin")); e.printStackTrace(); - player.sendMessage(TranslatableCaption.of(("errors.stacktrace_end"))); + player.sendMessage(TranslatableCaption.of("errors.stacktrace_end")); player.sendMessage(TranslatableCaption.of("database.invalid_args")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Download.java b/Core/src/main/java/com/plotsquared/core/command/Download.java index c3fa313ef..eee156d8e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.java @@ -94,12 +94,12 @@ public class Download extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) && !Permissions + if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && !DoneFlag.isDone(plot)) && !Permissions .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) { player.sendMessage(TranslatableCaption.of("done.done_not_done")); return false; } - if ((!plot.isOwner(player.getUUID())) && !Permissions + if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Permission.PERMISSION_ADMIN.toString())) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java index c1094adda..003418d32 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -367,6 +367,7 @@ public final class FlagCommand extends Command { ); } + @SuppressWarnings({"unchecked", "rawtypes"}) @CommandDeclaration(command = "add", aliases = {"a", "add"}, usage = "/plot flag add ", @@ -435,6 +436,7 @@ public final class FlagCommand extends Command { ); } + @SuppressWarnings({"unchecked", "rawtypes"}) @CommandDeclaration(command = "remove", aliases = {"r", "remove", "delete"}, usage = "/plot flag remove [values]", diff --git a/Core/src/main/java/com/plotsquared/core/command/Like.java b/Core/src/main/java/com/plotsquared/core/command/Like.java index 8db7b137a..d848b1149 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -112,7 +112,7 @@ public class Like extends SubCommand { }); for (final Plot plot : plots) { if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot - .isBasePlot() && (!plot.getLikes().containsKey(uuid))) { + .isBasePlot() && !plot.getLikes().containsKey(uuid)) { plot.teleportPlayer(player, TeleportCause.COMMAND_LIKE, result -> { }); player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); diff --git a/Core/src/main/java/com/plotsquared/core/command/Rate.java b/Core/src/main/java/com/plotsquared/core/command/Rate.java index 0d4b860c8..b6d7d8133 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -104,7 +104,7 @@ public class Rate extends SubCommand { UUID uuid = player.getUUID(); for (Plot p : plots) { if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p - .isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p + .isBasePlot() && !p.getRatings().containsKey(uuid) && !p .isAdded(uuid)) { p.teleportPlayer(player, TeleportCause.COMMAND_RATE, result -> { }); diff --git a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java index 79a9eb9e4..1c49d8a05 100644 --- a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java +++ b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java @@ -88,7 +88,6 @@ public class RegenAllRoads extends SubCommand { ); return false; } - String name = args[0]; PlotManager manager = area.getPlotManager(); if (!(manager instanceof HybridPlotManager)) { player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world")); diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java index d623c7a4d..60dd5feab 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -181,8 +181,6 @@ public class SchematicCmd extends SubCommand { }); } case "saveall", "exportall" -> { - Location loc = player.getLocation(); - final Plot plot = loc.getPlotAbs(); if (!(player instanceof ConsolePlayer)) { player.sendMessage(TranslatableCaption.of("console.not_console")); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java index 47cdf65b3..615d8d141 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -100,7 +100,7 @@ public class Set extends SubCommand { if (Settings.Enabled_Components.CHUNK_PROCESSOR) { forbiddenTypes.addAll(worldUtil.getTileEntityTypes().stream().map( - BlockType::getName).collect(Collectors.toList())); + BlockType::getName).toList()); } if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_ALLOW_UNSAFE) && diff --git a/Core/src/main/java/com/plotsquared/core/command/Visit.java b/Core/src/main/java/com/plotsquared/core/command/Visit.java index 853704ce4..ec9d74497 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Visit.java +++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java @@ -361,30 +361,4 @@ public class Visit extends Command { return completions; } - private void completeNumbers(final List commands, final String arg, final int start) { - for (int i = 0; i < 100; i++) { - final String command = Integer.toString(start + 1); - if (!command.toLowerCase().startsWith(arg.toLowerCase())) { - continue; - } - commands.add(new Command(this, false, command, "", - RequiredType.NONE, CommandCategory.TELEPORT - ) { - }); - } - } - - private void completeAreas(final List commands, final String arg) { - for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) { - final String areaName = area.getWorldName() + ";" + area.getId(); - if (!areaName.toLowerCase().startsWith(arg.toLowerCase())) { - continue; - } - commands.add(new Command(this, false, area.getWorldName() + ";" + area.getId(), "", - RequiredType.NONE, CommandCategory.TELEPORT - ) { - }); - } - } - } diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java index a7fd7d402..4b585ba0a 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java @@ -65,6 +65,7 @@ public class ComponentPreset implements ConfigurationSerializable { this.icon = icon; } + @SuppressWarnings("unchecked") public static ComponentPreset deserialize(final @NonNull Map map) { final ClassicPlotManagerComponent classicPlotManagerComponent = ClassicPlotManagerComponent .fromString(map.getOrDefault("component", "").toString()).orElseThrow(() -> diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index 5bbd5fa1d..0b514996f 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -75,6 +75,7 @@ public class ComponentPresetManager { private final InventoryUtil inventoryUtil; private File componentsFile; + @SuppressWarnings("unchecked") @Inject public ComponentPresetManager(final @NonNull EconHandler econHandler, final @NonNull InventoryUtil inventoryUtil) throws IOException { diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Config.java b/Core/src/main/java/com/plotsquared/core/configuration/Config.java index 3b5436ee1..2bbd02ad8 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Config.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Config.java @@ -58,6 +58,7 @@ public class Config { * @param value type * @return value */ + @SuppressWarnings("unchecked") public static T get(String key, Class root) { String[] split = key.split("\\."); Object instance = getInstance(split, root); @@ -183,6 +184,7 @@ public class Config { return value != null ? value.toString() : "null"; } + @SuppressWarnings({"unchecked", "rawtypes"}) private static void save(PrintWriter writer, Class clazz, Object instance, int indent) { try { String lineSeparator = System.lineSeparator(); @@ -258,21 +260,6 @@ public class Config { } } - /** - * Get the field for a specific config node. - * - * @param split the node (split by period) - * @param root - * @return - */ - private static Field getField(String[] split, Class root) { - Object instance = getInstance(split, root); - if (instance == null) { - return null; - } - return getField(split, instance); - } - /** * Get the field for a specific config node and instance
* Note: As expiry can have multiple blocks there will be multiple instances @@ -305,6 +292,7 @@ public class Config { * @param root * @return The instance or null */ + @SuppressWarnings({"unchecked", "rawtypes"}) private static Object getInstance(String[] split, Class root) { try { Class clazz = root == null ? MethodHandles.lookup().lookupClass() : root; diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java index 1c32bf23e..d30179dd7 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java @@ -101,7 +101,9 @@ public class SQLManager implements AbstractDB { private final String prefix; private final Database database; private final boolean mySQL; + @SuppressWarnings({"unused", "FieldCanBeLocal"}) private final EventDispatcher eventDispatcher; + @SuppressWarnings({"unused", "FieldCanBeLocal"}) private final PlotListener plotListener; private final YamlConfiguration worldConfiguration; /** @@ -408,7 +410,6 @@ public class SQLManager implements AbstractDB { while (iterator.hasNext()) { try { Entry> entry = iterator.next(); - Plot plot = entry.getKey(); Queue tasks = entry.getValue(); if (tasks.isEmpty()) { iterator.remove(); @@ -2295,8 +2296,6 @@ public class SQLManager implements AbstractDB { int size = uniqueIdsList.size(); int packet = 990; int amount = size / packet; - int count = 0; - int last = -1; for (int j = 0; j <= amount; j++) { List subList = uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet)); @@ -3200,6 +3199,7 @@ public class SQLManager implements AbstractDB { return true; } + @SuppressWarnings({"unchecked", "unused"}) @Override public void validateAllPlots(Set toValidate) { if (!isValid()) { @@ -3455,15 +3455,7 @@ public class SQLManager implements AbstractDB { } - private static class UUIDPair { - - public final int id; - public final UUID uuid; - - public UUIDPair(int id, UUID uuid) { - this.id = id; - this.uuid = uuid; - } + private record UUIDPair(int id, UUID uuid) { } diff --git a/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotsChosenEvent.java b/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotsChosenEvent.java index 05660b04d..c511fa813 100644 --- a/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotsChosenEvent.java +++ b/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotsChosenEvent.java @@ -40,8 +40,6 @@ import java.util.List; */ public class PlayerAutoPlotsChosenEvent extends PlotPlayerEvent { - private Result eventResult; - private List plots; /** diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java index 5fc0ed3da..90bf16239 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java @@ -97,8 +97,8 @@ public class HybridGen extends IndependentPlotGenerator { } // Coords Location min = result.getMin(); - int bx = (min.getX()) - hybridPlotWorld.ROAD_OFFSET_X; - int bz = (min.getZ()) - hybridPlotWorld.ROAD_OFFSET_Z; + int bx = min.getX() - hybridPlotWorld.ROAD_OFFSET_X; + int bz = min.getZ() - hybridPlotWorld.ROAD_OFFSET_Z; // The relative X-coordinate (within the plot) of the minimum X coordinate // contained in the scoped queue short relativeOffsetX; diff --git a/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java b/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java index 97f0efad4..94ca5f587 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java +++ b/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java @@ -95,6 +95,7 @@ public abstract class IndependentPlotGenerator { * @param world ChunkGenerator Implementation * @return Chunk generator */ + @SuppressWarnings("unchecked") public GeneratorWrapper specify(final @NonNull String world) { return (GeneratorWrapper) PlotSquared.platform().wrapPlotGenerator(world, this); } diff --git a/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java b/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java index f93741949..5dcd435a9 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java +++ b/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java @@ -42,8 +42,6 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.checkerframework.checker.nullness.qual.NonNull; import java.lang.reflect.Field; @@ -53,8 +51,6 @@ import java.util.Set; public class ProcessedWEExtent extends AbstractDelegateExtent { - private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + ProcessedWEExtent.class.getSimpleName()); - private final Set mask; private final String world; private final int max; @@ -162,6 +158,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { return null; } + @SuppressWarnings("deprecation") @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return WEManager.maskContains(this.mask, position.getX(), position.getZ()) && super diff --git a/Core/src/main/java/com/plotsquared/core/listener/WEExtent.java b/Core/src/main/java/com/plotsquared/core/listener/WEExtent.java index 46da7a033..6892ca436 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/WEExtent.java +++ b/Core/src/main/java/com/plotsquared/core/listener/WEExtent.java @@ -54,6 +54,7 @@ public class WEExtent extends AbstractDelegateExtent { this.mask = mask; } + @SuppressWarnings("unchecked") @Override public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { diff --git a/Core/src/main/java/com/plotsquared/core/player/MetaDataKey.java b/Core/src/main/java/com/plotsquared/core/player/MetaDataKey.java index 94d46eef0..025e628d3 100644 --- a/Core/src/main/java/com/plotsquared/core/player/MetaDataKey.java +++ b/Core/src/main/java/com/plotsquared/core/player/MetaDataKey.java @@ -62,6 +62,7 @@ public final class MetaDataKey { * @param Type * @return MetaData key instance */ + @SuppressWarnings("unchecked") public static @NonNull MetaDataKey of(final @NonNull String key, final @NonNull TypeLiteral type) { synchronized (keyMetaData) { return (MetaDataKey) diff --git a/Core/src/main/java/com/plotsquared/core/player/PersistentMetaDataAccess.java b/Core/src/main/java/com/plotsquared/core/player/PersistentMetaDataAccess.java index 7f0e4b142..7763bfe3f 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PersistentMetaDataAccess.java +++ b/Core/src/main/java/com/plotsquared/core/player/PersistentMetaDataAccess.java @@ -47,6 +47,7 @@ final class PersistentMetaDataAccess extends MetaDataAccess { return this.getPlayer().hasPersistentMeta(getMetaDataKey().toString()); } + @SuppressWarnings("unchecked") @Override public @Nullable T remove() { this.checkClosed(); diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index bb6d87fa7..ea9597c71 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -104,7 +104,8 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, private static final Set> debugModeEnabled = Collections.synchronizedSet(new HashSet<>()); - private static final Map converters = new HashMap<>(); + @SuppressWarnings("rawtypes") + private static final Map, PlotPlayerConverter> converters = new HashMap<>(); private final LockRepository lockRepository = new LockRepository(); private final PlotAreaManager plotAreaManager; private final EventDispatcher eventDispatcher; @@ -128,6 +129,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, this.permissionHandler = permissionHandler; } + @SuppressWarnings({"rawtypes", "unchecked"}) public static PlotPlayer from(final @NonNull T object) { // fast path if (converters.containsKey(object.getClass())) { @@ -234,6 +236,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, * @param the object type to return * @return the value assigned to the key or null if it does not exist */ + @SuppressWarnings("unchecked") T getMeta(String key) { if (this.meta != null) { return (T) this.meta.get(key); @@ -361,7 +364,6 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, } public int getClusterCount(String world) { - UUID uuid = getUUID(); int count = 0; for (PlotArea area : this.plotAreaManager.getPlotAreasSet(world)) { for (PlotCluster cluster : area.getClusters()) { @@ -795,16 +797,16 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, final @NonNull MetaDataKey key, final @NonNull T value ) { - final Object rawValue = value; if (key.getType().getRawType().equals(Integer.class)) { - this.setPersistentMeta(key.toString(), Ints.toByteArray((int) rawValue)); + this.setPersistentMeta(key.toString(), Ints.toByteArray((int) (Object) value)); } else if (key.getType().getRawType().equals(Boolean.class)) { - this.setPersistentMeta(key.toString(), ByteArrayUtilities.booleanToBytes((boolean) rawValue)); + this.setPersistentMeta(key.toString(), ByteArrayUtilities.booleanToBytes((boolean) (Object) value)); } else { throw new IllegalArgumentException(String.format("Unknown meta data type '%s'", key.getType())); } } + @SuppressWarnings("unchecked") @Nullable T getPersistentMeta(final @NonNull MetaDataKey key) { final byte[] value = this.getPersistentMeta(key.toString()); if (value == null) { diff --git a/Core/src/main/java/com/plotsquared/core/player/TemporaryMetaDataAccess.java b/Core/src/main/java/com/plotsquared/core/player/TemporaryMetaDataAccess.java index 83632f6b0..dd1a90536 100644 --- a/Core/src/main/java/com/plotsquared/core/player/TemporaryMetaDataAccess.java +++ b/Core/src/main/java/com/plotsquared/core/player/TemporaryMetaDataAccess.java @@ -47,6 +47,7 @@ final class TemporaryMetaDataAccess extends MetaDataAccess { return this.getPlayer().getMeta(this.getMetaDataKey().toString()) != null; } + @SuppressWarnings("unchecked") @Override public @Nullable T remove() { this.checkClosed(); diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 10992d982..6b6a377bf 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -439,38 +439,6 @@ public abstract class PlotArea { loadConfiguration(config); } - private Component getFlagsComponent(Component flagsComponent, Collection> flagCollection) { - if (flagCollection.isEmpty()) { - flagsComponent = MINI_MESSAGE.parse(TranslatableCaption.of("flag.no_flags").getComponent(LocaleHolder.console())); - } else { - String prefix = " "; - for (final PlotFlag flag : flagCollection) { - Object value; - if (flag instanceof DoubleFlag && !Settings.General.SCIENTIFIC) { - value = FLAG_DECIMAL_FORMAT.format(flag.getValue()); - } else { - value = flag.toString(); - } - Component snip = MINI_MESSAGE.parse( - prefix + CaptionUtility - .format( - ConsolePlayer.getConsole(), - TranslatableCaption.of("info.plot_flag_list").getComponent(LocaleHolder.console()) - ), - Template.of("flag", flag.getName()), - Template.of("value", CaptionUtility.formatRaw(ConsolePlayer.getConsole(), value.toString())) - ); - if (flagsComponent != null) { - flagsComponent.append(snip); - } else { - flagsComponent = snip; - } - prefix = ", "; - } - } - return flagsComponent; - } - public abstract void loadConfiguration(ConfigurationSection config); /** diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index a8c183eb5..ac28cec7e 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -319,7 +319,6 @@ public class ExpireManager { ExpireManager.this.running = 0; return; } - long start = System.currentTimeMillis(); while (!plots.isEmpty()) { if (ExpireManager.this.running != 2) { ExpireManager.this.running = 0; diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java index bd2563f30..b27d9e355 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java @@ -558,6 +558,7 @@ public class PlotAnalysis { return ranks; } + @SuppressWarnings("unchecked") public static void sort(int[] input) { int SIZE = 10; List[] bucket = new ArrayList[SIZE]; diff --git a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java index 02dd5ad4b..9c7ea7bd1 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java @@ -57,7 +57,9 @@ import java.nio.file.Files; public class SinglePlotArea extends GridPlotWorld { + @SuppressWarnings({"unused", "FieldCanBeLocal"}) private final EventDispatcher eventDispatcher; + @SuppressWarnings({"unused", "FieldCanBeLocal"}) private final PlotListener plotListener; public boolean VOID = false; @@ -273,6 +275,7 @@ public class SinglePlotArea extends GridPlotWorld { return false; // do not create signs for single plots } + @SuppressWarnings("deprecation") protected Plot adapt(Plot p) { if (p instanceof SinglePlot) { return p; diff --git a/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java index 87cbd8aa9..1d5c10a8a 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java @@ -57,7 +57,6 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { private final ConcurrentHashMap blockChunks = new ConcurrentHashMap<>(); private final List readRegion = new ArrayList<>(); private final List progressSubscribers = new ArrayList<>(); - private long modified; private LocalChunk lastWrappedChunk; private int lastX = Integer.MIN_VALUE; private int lastZ = Integer.MIN_VALUE; @@ -76,7 +75,6 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { public BasicQueueCoordinator(@NonNull World world) { super(world); this.world = world; - this.modified = System.currentTimeMillis(); } @Override @@ -94,7 +92,6 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { @Override public final void setModified(long modified) { - this.modified = modified; } @Override @@ -120,6 +117,7 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { return setBlock(x, y, z, id.toBaseBlock()); } + @SuppressWarnings("removal") @Override public boolean setBiome(int x, int z, @NonNull BiomeType biomeType) { LocalChunk chunk = getChunk(x >> 4, z >> 4); diff --git a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java index 73fca2809..2bc0fe13c 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -56,6 +56,7 @@ public abstract class QueueCoordinator { private Object chunkObject; private final AtomicBoolean enqueued = new AtomicBoolean(); + @SuppressWarnings({"unused", "FieldCanBeLocal"}) @Inject private GlobalBlockQueue blockQueue; diff --git a/Core/src/main/java/com/plotsquared/core/synchronization/LockRepository.java b/Core/src/main/java/com/plotsquared/core/synchronization/LockRepository.java index 07950dbad..0962dc2db 100644 --- a/Core/src/main/java/com/plotsquared/core/synchronization/LockRepository.java +++ b/Core/src/main/java/com/plotsquared/core/synchronization/LockRepository.java @@ -34,6 +34,7 @@ import java.util.function.Consumer; /** * A repository for keyed {@link java.util.concurrent.locks.Lock locks} */ +@SuppressWarnings("UnstableApiUsage") public final class LockRepository { private final Striped striped; diff --git a/Core/src/main/java/com/plotsquared/core/util/BlockUtil.java b/Core/src/main/java/com/plotsquared/core/util/BlockUtil.java index 97a0796f0..5e5a6de58 100644 --- a/Core/src/main/java/com/plotsquared/core/util/BlockUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/BlockUtil.java @@ -90,7 +90,7 @@ public final class BlockUtil { if (id.length() == 1 && id.charAt(0) == '*') { return FuzzyBlockState.builder().type(BlockTypes.AIR).build(); } - String mutableId = id; + String mutableId; mutableId = id.toLowerCase(); BlockType type = BlockTypes.get(mutableId); if (type != null) { diff --git a/Core/src/main/java/com/plotsquared/core/util/RegionManager.java b/Core/src/main/java/com/plotsquared/core/util/RegionManager.java index 1914ade47..bf9289871 100644 --- a/Core/src/main/java/com/plotsquared/core/util/RegionManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/RegionManager.java @@ -289,7 +289,7 @@ public abstract class RegionManager { true ); - toQueue2.setCompleteTask(whenDone::run); + toQueue2.setCompleteTask(whenDone); if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) { toQueue2.addProgressSubscriber(subscriberFactory.createFull( actor, diff --git a/Core/src/main/java/com/plotsquared/core/util/StringComparison.java b/Core/src/main/java/com/plotsquared/core/util/StringComparison.java index 4dfc3f294..d8c2f65c4 100644 --- a/Core/src/main/java/com/plotsquared/core/util/StringComparison.java +++ b/Core/src/main/java/com/plotsquared/core/util/StringComparison.java @@ -59,6 +59,7 @@ public class StringComparison { this(input, objects, Object::toString); } + @SuppressWarnings("unchecked") public StringComparison(String input, Collection objects, Function toString) { this(input, (T[]) objects.toArray(), toString); } diff --git a/Core/src/main/java/com/plotsquared/core/util/StringMan.java b/Core/src/main/java/com/plotsquared/core/util/StringMan.java index dc8f47942..f44c8e04e 100644 --- a/Core/src/main/java/com/plotsquared/core/util/StringMan.java +++ b/Core/src/main/java/com/plotsquared/core/util/StringMan.java @@ -286,7 +286,7 @@ public class StringMan { } public static boolean isEqualIgnoreCase(String a, String b) { - return (a.equals(b)) || ((a != null) && (b != null) && (a.length() == b.length()) && a + return a.equals(b) || ((a != null) && (b != null) && (a.length() == b.length()) && a .equalsIgnoreCase(b)); } diff --git a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java index 1c204032a..ef3f93a57 100644 --- a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java +++ b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java @@ -265,6 +265,7 @@ public final class TabCompletions { * @return List of completions * @deprecated In favor {@link #completePlayers(String, PlotPlayer, String, List, Predicate)} */ + @SuppressWarnings("unused") @Deprecated(forRemoval = true) private static List completePlayers( final @NonNull String cacheIdentifier, diff --git a/Core/src/main/java/com/plotsquared/core/util/WEManager.java b/Core/src/main/java/com/plotsquared/core/util/WEManager.java index 40fdf6ef0..2ae4e38b7 100644 --- a/Core/src/main/java/com/plotsquared/core/util/WEManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/WEManager.java @@ -109,7 +109,7 @@ public class WEManager { plot = metaDataAccess.get().orElse(null); } if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot)) && ( - (allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot + (allowMember && plot.isAdded(uuid)) || (!allowMember && plot.isOwner(uuid) || plot .getTrusted().contains(uuid))) && !plot.getFlag(NoWorldeditFlag.class)) { for (CuboidRegion region : plot.getRegions()) { BlockVector3 pos1 = region.getMinimumPoint().withY(area.getMinBuildHeight());