chore: More work

This commit is contained in:
NotMyFault 2022-01-20 01:38:20 +01:00
parent 4a2da59505
commit 8385387e88
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
23 changed files with 40 additions and 12 deletions

View File

@ -63,6 +63,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
return false; return false;
} }
@SuppressWarnings("MixedMutabilityReturnType")
@Override @Override
public List<String> onTabComplete( public List<String> onTabComplete(
CommandSender commandSender, Command command, String label, CommandSender commandSender, Command command, String label,

View File

@ -563,6 +563,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
ServerLib.checkUnsafeForks(); ServerLib.checkUnsafeForks();
} }
@SuppressWarnings("CatchAndPrintStackTrace")
private void unload() { private void unload() {
if (!this.methodUnloadSetup) { if (!this.methodUnloadSetup) {
this.methodUnloadSetup = true; this.methodUnloadSetup = true;
@ -648,6 +649,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
} }
} }
@SuppressWarnings("FutureReturnValueIgnored")
private void startUuidCaching( private void startUuidCaching(
final @NonNull SQLiteUUIDService sqLiteUUIDService, final @NonNull SQLiteUUIDService sqLiteUUIDService,
final @NonNull CacheUUIDService cacheUUIDService final @NonNull CacheUUIDService cacheUUIDService

View File

@ -461,7 +461,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.tamed.tamed = tamed.isTamed(); this.tamed.tamed = tamed.isTamed();
} }
@SuppressWarnings("EmptyCatch") @SuppressWarnings({"EmptyCatch", "deprecation"}) // Paper deprecation
@Override @Override
public Entity spawn(World world, int xOffset, int zOffset) { public Entity spawn(World world, int xOffset, int zOffset) {
Location location = new Location(world, this.getX() + xOffset, this.getY(), this.z + zOffset); Location location = new Location(world, this.getX() + xOffset, this.getY(), this.z + zOffset);

View File

@ -261,6 +261,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
} }
} }
@SuppressWarnings({"EqualsHashCode", "EqualsGetClass"}) // Valid comparison
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj == null) { if (obj == null) {

View File

@ -36,6 +36,7 @@ import org.bukkit.World;
public class WorldManagerModule extends AbstractModule { public class WorldManagerModule extends AbstractModule {
@SuppressWarnings("removal") // Internal use only
@Provides @Provides
@Singleton @Singleton
PlatformWorldManager<World> provideWorldManager() { PlatformWorldManager<World> provideWorldManager() {

View File

@ -426,6 +426,7 @@ public class BlockEventListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@SuppressWarnings("FallThrough")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent event) { public void onBlockSpread(BlockSpreadEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
@ -686,7 +687,7 @@ public class BlockEventListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@SuppressWarnings("MissingCaseInEnumSwitch") @SuppressWarnings("MissingCaseesInEnumSwitch")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFade(BlockFadeEvent event) { public void onFade(BlockFadeEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
@ -1075,6 +1076,7 @@ public class BlockEventListener implements Listener {
} }
@SuppressWarnings("OperatorPrecedence")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) { public void onBlockIgnite(BlockIgniteEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -258,6 +258,7 @@ public class ChunkListener implements Listener {
processChunk(event.getChunk(), false); processChunk(event.getChunk(), false);
} }
@SuppressWarnings("FutureReturnValueIgnored")
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) { public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity(); Item entity = event.getEntity();
@ -288,6 +289,7 @@ public class ChunkListener implements Listener {
} }
} }
@SuppressWarnings("FutureReturnValueIgnored")
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) { public void onEntitySpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();

View File

@ -85,6 +85,7 @@ public class EntitySpawnListener implements Listener {
test(entity); test(entity);
} }
@SuppressWarnings("FutureReturnValueIgnored")
public static void test(Entity entity) { public static void test(Entity entity) {
@NonNull World world = entity.getWorld(); @NonNull World world = entity.getWorld();
List<MetadataValue> meta = entity.getMetadata(KEY); List<MetadataValue> meta = entity.getMetadata(KEY);
@ -121,7 +122,7 @@ public class EntitySpawnListener implements Listener {
} }
} }
@SuppressWarnings("MissingCaseInEnumSwitch") @SuppressWarnings({"MissingCaseesInEnumSwitch", "FallThrough"})
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void creatureSpawnEvent(EntitySpawnEvent event) { public void creatureSpawnEvent(EntitySpawnEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();

View File

@ -83,6 +83,7 @@ public class PaperListener implements Listener {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }
@SuppressWarnings("ReferenceEquality")
@EventHandler @EventHandler
public void onEntityPathfind(EntityPathfindEvent event) { public void onEntityPathfind(EntityPathfindEvent event) {
if (!Settings.Paper_Components.ENTITY_PATHING) { if (!Settings.Paper_Components.ENTITY_PATHING) {
@ -117,6 +118,7 @@ public class PaperListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@SuppressWarnings("ReferenceEquality")
@EventHandler @EventHandler
public void onEntityPathfind(SlimePathfindEvent event) { public void onEntityPathfind(SlimePathfindEvent event) {
if (!Settings.Paper_Components.ENTITY_PATHING) { if (!Settings.Paper_Components.ENTITY_PATHING) {
@ -159,7 +161,7 @@ public class PaperListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@SuppressWarnings("MissingCasesInEnumSwitch") @SuppressWarnings({"MissingCasesInEnumSwitch", "FallThrough"})
@EventHandler @EventHandler
public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) { public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) {
if (!Settings.Paper_Components.CREATURE_SPAWN) { if (!Settings.Paper_Components.CREATURE_SPAWN) {

View File

@ -36,7 +36,6 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.block.Banner; import org.bukkit.block.Banner;
import org.bukkit.block.Beacon; import org.bukkit.block.Beacon;
import org.bukkit.block.Bed;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.CommandBlock; import org.bukkit.block.CommandBlock;
import org.bukkit.block.Comparator; import org.bukkit.block.Comparator;
@ -51,6 +50,7 @@ import org.bukkit.block.Jukebox;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.block.Skull; import org.bukkit.block.Skull;
import org.bukkit.block.Structure; import org.bukkit.block.Structure;
import org.bukkit.block.data.type.Bed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;

View File

@ -380,6 +380,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
this.eventDispatcher.doRespawnTask(pp); this.eventDispatcher.doRespawnTask(pp);
} }
@SuppressWarnings("deprecation") // We explicitly want #getHomeSynchronous here
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -429,6 +430,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
playerMove(event); playerMove(event);
} }
@SuppressWarnings("FutureReturnValueIgnored")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event) public void vehicleMove(VehicleMoveEvent event)
throws IllegalAccessException { throws IllegalAccessException {
@ -806,7 +808,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings({"deprecation", "FallThrough"})
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
/*if (!event.isLeftClick() || (event.getAction() != InventoryAction.PLACE_ALL) || event /*if (!event.isLeftClick() || (event.getAction() != InventoryAction.PLACE_ALL) || event

View File

@ -229,6 +229,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
return max; return max;
} }
@SuppressWarnings("FutureReturnValueIgnored")
@Override @Override
public void teleport(final @NonNull Location location, final @NonNull TeleportCause cause) { public void teleport(final @NonNull Location location, final @NonNull TeleportCause cause) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) { if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
@ -316,6 +317,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
this.player.setAllowFlight(fly); this.player.setAllowFlight(fly);
} }
@SuppressWarnings("ReferenceEquality")
@Override @Override
public void playMusic(final @NonNull Location location, final @NonNull ItemType id) { public void playMusic(final @NonNull Location location, final @NonNull ItemType id) {
if (id == ItemTypes.AIR) { if (id == ItemTypes.AIR) {
@ -339,6 +341,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
this.player.kickPlayer(message); this.player.kickPlayer(message);
} }
@SuppressWarnings("ReferenceEquality")
@Override @Override
public void stopSpectating() { public void stopSpectating() {
if (getGameMode() == SPECTATOR) { if (getGameMode() == SPECTATOR) {

View File

@ -337,6 +337,7 @@ public class BukkitEntityUtil {
&& !(victim instanceof Creature))); && !(victim instanceof Creature)));
} }
@SuppressWarnings("OperatorPrecedence")
public static boolean checkEntity(Entity entity, Plot plot) { public static boolean checkEntity(Entity entity, Plot plot) {
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea() if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea()
.getFlagContainer().getFlagMap().isEmpty()) { .getFlagContainer().getFlagMap().isEmpty()) {

View File

@ -77,6 +77,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
return stack; return stack;
} }
@SuppressWarnings("deprecation") // Paper deprecation
@Override @Override
public void open(PlotInventory inv) { public void open(PlotInventory inv) {
BukkitPlayer bp = (BukkitPlayer) inv.getPlayer(); BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
@ -113,6 +114,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
bp.player.updateInventory(); bp.player.updateInventory();
} }
@SuppressWarnings("deprecation") // Paper deprecation
public PlotItemStack getItem(ItemStack item) { public PlotItemStack getItem(ItemStack item) {
if (item == null) { if (item == null) {
return null; return null;
@ -145,7 +147,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
.toArray(PlotItemStack[]::new); .toArray(PlotItemStack[]::new);
} }
@SuppressWarnings("deprecation") // Need #getTitle for Spigot compatibility @SuppressWarnings("deprecation") // #getTitle is needed for Spigot compatibility
@Override @Override
public boolean isOpen(PlotInventory plotInventory) { public boolean isOpen(PlotInventory plotInventory) {
if (!plotInventory.isOpen()) { if (!plotInventory.isOpen()) {

View File

@ -94,6 +94,7 @@ public class BukkitRegionManager extends RegionManager {
return false; return false;
} }
@SuppressWarnings({"FutureReturnValueIgnored", "OperatorPrecedence"})
@Override @Override
public int[] countEntities(@NonNull Plot plot) { public int[] countEntities(@NonNull Plot plot) {
int[] existing = (int[]) plot.getMeta("EntityCount"); int[] existing = (int[]) plot.getMeta("EntityCount");

View File

@ -74,6 +74,7 @@ public class BukkitSetupUtils extends SetupUtils {
this.worldFile = worldFile; this.worldFile = worldFile;
} }
@SuppressWarnings("CatchAndPrintStackTrace")
@Override @Override
public void updateGenerators(final boolean force) { public void updateGenerators(final boolean force) {
if (!SetupUtils.generators.isEmpty() && !force) { if (!SetupUtils.generators.isEmpty() && !force) {

View File

@ -193,6 +193,7 @@ public class BukkitUtil extends WorldUtil {
return Bukkit.getWorld(string); return Bukkit.getWorld(string);
} }
@SuppressWarnings("FutureReturnValueIgnored")
private static void ensureLoaded( private static void ensureLoaded(
final @NonNull String world, final @NonNull String world,
final int x, final int x,
@ -203,6 +204,7 @@ public class BukkitUtil extends WorldUtil {
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk)); .thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
} }
@SuppressWarnings("FutureReturnValueIgnored")
private static void ensureLoaded(final @NonNull Location location, final @NonNull Consumer<Chunk> chunkConsumer) { private static void ensureLoaded(final @NonNull Location location, final @NonNull Consumer<Chunk> chunkConsumer) {
PaperLib.getChunkAtAsync(adapt(location), true).thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk)); PaperLib.getChunkAtAsync(adapt(location), true).thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
} }

View File

@ -61,6 +61,7 @@ public class UpdateUtility implements Listener {
internalVersion = PlotSquared.get().getVersion(); internalVersion = PlotSquared.get().getVersion();
} }
@SuppressWarnings({"deprecation", "DefaultCharset"}) // Suppress Json deprecation, we can't use features from gson 2.8.1 and newer yet
public void updateChecker() { public void updateChecker() {
task = Bukkit.getScheduler().runTaskTimerAsynchronously(this.javaPlugin, () -> { task = Bukkit.getScheduler().runTaskTimerAsynchronously(this.javaPlugin, () -> {
try { try {
@ -91,7 +92,7 @@ public class UpdateUtility implements Listener {
notify = false; notify = false;
LOGGER.info("Congratulations! You are running the latest PlotSquared version"); LOGGER.info("Congratulations! You are running the latest PlotSquared version");
} }
}, 0L, Settings.UpdateChecker.POLL_RATE * 60 * 20); }, 0L, (long) Settings.UpdateChecker.POLL_RATE * 60 * 20);
} }
private void cancelTask() { private void cancelTask() {

View File

@ -75,6 +75,7 @@ public class FaweSchematicHandler extends SchematicHandler {
return delegate.save(tag, path); return delegate.save(tag, path);
} }
@SuppressWarnings("removal") // Just the override
@Override @Override
public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) { public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
delegate.upload(tag, uuid, file, whenDone); delegate.upload(tag, uuid, file, whenDone);

View File

@ -43,7 +43,7 @@ import java.util.UUID;
*/ */
public class OfflinePlayerUUIDService implements UUIDService { public class OfflinePlayerUUIDService implements UUIDService {
@SuppressWarnings("EmptyCatch") @SuppressWarnings({"EmptyCatch", "MixedMutabilityReturnType"})
@Override @Override
public @NonNull List<UUIDMapping> getNames(final @NonNull List<UUID> uuids) { public @NonNull List<UUIDMapping> getNames(final @NonNull List<UUID> uuids) {
if (Settings.UUID.FORCE_LOWERCASE || Bukkit.getWorlds().isEmpty()) { if (Settings.UUID.FORCE_LOWERCASE || Bukkit.getWorlds().isEmpty()) {

View File

@ -53,7 +53,7 @@ public abstract class MetaDataAccess<T> implements AutoCloseable {
this.lockAccess = lockAccess; this.lockAccess = lockAccess;
} }
@SuppressWarnings("ALL") @SuppressWarnings("unchecked")
private static <E extends Throwable> void sneakyThrow(final Throwable e) throws E { private static <E extends Throwable> void sneakyThrow(final Throwable e) throws E {
throw (E) e; throw (E) e;
} }

View File

@ -96,7 +96,7 @@ public class FlagContainer {
} }
/** /**
* Cast a plot flag with wildcard parameters into a parametrisized * Cast a plot flag with wildcard parameters into a parametrized
* PlotFlag. This is an unsafe operation, and should only be performed * PlotFlag. This is an unsafe operation, and should only be performed
* if the generic parameters are known beforehand. * if the generic parameters are known beforehand.
* *
@ -105,7 +105,7 @@ public class FlagContainer {
* @param <T> Flag type * @param <T> Flag type
* @return Casted flag * @return Casted flag
*/ */
@SuppressWarnings("ALL") @SuppressWarnings("unchecked")
public static <V, T extends PlotFlag<V, ?>> T castUnsafe( public static <V, T extends PlotFlag<V, ?>> T castUnsafe(
final PlotFlag<?, ?> flag final PlotFlag<?, ?> flag
) { ) {
@ -181,6 +181,7 @@ public class FlagContainer {
* @param <V> flag value type * @param <V> flag value type
* @return value of flag removed * @return value of flag removed
*/ */
@SuppressWarnings("unchecked")
public <V, T extends PlotFlag<V, ?>> V removeFlag(final T flag) { public <V, T extends PlotFlag<V, ?>> V removeFlag(final T flag) {
final Object value = this.flagMap.remove(flag.getClass()); final Object value = this.flagMap.remove(flag.getClass());
if (this.plotFlagUpdateHandler != null) { if (this.plotFlagUpdateHandler != null) {

View File

@ -73,6 +73,7 @@ public class EntityUtil {
return i; return i;
} }
@SuppressWarnings("unchecked")
public static boolean checkEntity(Plot plot, PlotFlag<Integer, ?>... flags) { public static boolean checkEntity(Plot plot, PlotFlag<Integer, ?>... flags) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
return true; return true;