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;
}
@SuppressWarnings("MixedMutabilityReturnType")
@Override
public List<String> onTabComplete(
CommandSender commandSender, Command command, String label,

View File

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

View File

@ -461,7 +461,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.tamed.tamed = tamed.isTamed();
}
@SuppressWarnings("EmptyCatch")
@SuppressWarnings({"EmptyCatch", "deprecation"}) // Paper deprecation
@Override
public Entity spawn(World world, int xOffset, int 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
public boolean equals(final Object obj) {
if (obj == null) {

View File

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

View File

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

View File

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

View File

@ -85,6 +85,7 @@ public class EntitySpawnListener implements Listener {
test(entity);
}
@SuppressWarnings("FutureReturnValueIgnored")
public static void test(Entity entity) {
@NonNull World world = entity.getWorld();
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)
public void creatureSpawnEvent(EntitySpawnEvent event) {
Entity entity = event.getEntity();

View File

@ -83,6 +83,7 @@ public class PaperListener implements Listener {
this.plotAreaManager = plotAreaManager;
}
@SuppressWarnings("ReferenceEquality")
@EventHandler
public void onEntityPathfind(EntityPathfindEvent event) {
if (!Settings.Paper_Components.ENTITY_PATHING) {
@ -117,6 +118,7 @@ public class PaperListener implements Listener {
event.setCancelled(true);
}
@SuppressWarnings("ReferenceEquality")
@EventHandler
public void onEntityPathfind(SlimePathfindEvent event) {
if (!Settings.Paper_Components.ENTITY_PATHING) {
@ -159,7 +161,7 @@ public class PaperListener implements Listener {
event.setCancelled(true);
}
@SuppressWarnings("MissingCasesInEnumSwitch")
@SuppressWarnings({"MissingCasesInEnumSwitch", "FallThrough"})
@EventHandler
public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) {
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 org.bukkit.block.Banner;
import org.bukkit.block.Beacon;
import org.bukkit.block.Bed;
import org.bukkit.block.BlockState;
import org.bukkit.block.CommandBlock;
import org.bukkit.block.Comparator;
@ -51,6 +50,7 @@ import org.bukkit.block.Jukebox;
import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
import org.bukkit.block.Structure;
import org.bukkit.block.data.type.Bed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
import org.checkerframework.checker.nullness.qual.NonNull;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -193,6 +193,7 @@ public class BukkitUtil extends WorldUtil {
return Bukkit.getWorld(string);
}
@SuppressWarnings("FutureReturnValueIgnored")
private static void ensureLoaded(
final @NonNull String world,
final int x,
@ -203,6 +204,7 @@ public class BukkitUtil extends WorldUtil {
.thenAccept(chunk -> ensureMainThread(chunkConsumer, chunk));
}
@SuppressWarnings("FutureReturnValueIgnored")
private static void ensureLoaded(final @NonNull Location location, final @NonNull Consumer<Chunk> chunkConsumer) {
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();
}
@SuppressWarnings({"deprecation", "DefaultCharset"}) // Suppress Json deprecation, we can't use features from gson 2.8.1 and newer yet
public void updateChecker() {
task = Bukkit.getScheduler().runTaskTimerAsynchronously(this.javaPlugin, () -> {
try {
@ -91,7 +92,7 @@ public class UpdateUtility implements Listener {
notify = false;
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() {

View File

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

View File

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

View File

@ -53,7 +53,7 @@ public abstract class MetaDataAccess<T> implements AutoCloseable {
this.lockAccess = lockAccess;
}
@SuppressWarnings("ALL")
@SuppressWarnings("unchecked")
private static <E extends Throwable> void sneakyThrow(final Throwable e) throws 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
* if the generic parameters are known beforehand.
*
@ -105,7 +105,7 @@ public class FlagContainer {
* @param <T> Flag type
* @return Casted flag
*/
@SuppressWarnings("ALL")
@SuppressWarnings("unchecked")
public static <V, T extends PlotFlag<V, ?>> T castUnsafe(
final PlotFlag<?, ?> flag
) {
@ -181,6 +181,7 @@ public class FlagContainer {
* @param <V> flag value type
* @return value of flag removed
*/
@SuppressWarnings("unchecked")
public <V, T extends PlotFlag<V, ?>> V removeFlag(final T flag) {
final Object value = this.flagMap.remove(flag.getClass());
if (this.plotFlagUpdateHandler != null) {

View File

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