Ignored lots of compiler warnings.

Mostly these are deprecations from the Spigot team which I believe
shouldn't be deprecated.  For example, players refer to each other by
name, not UUID - so there will always be a need for player lookup by
name.  Also the block IDs are a well-documented standard that everyone
understands, even if they're not very human-friendly.  Plugins use those
IDs and data values to specify block types for example in config files.
As for the rest of the ignores, I either decided the warnings are just
noise based on the situation, or that I'm comfortable with the risks.
Possibly for the first time in 5 years of dev work on this plugin, I
just compiled without any warnings.  :)
This commit is contained in:
ryanhamshire 2016-01-20 13:56:31 -08:00
parent 079d3c143a
commit 289b832b9a
17 changed files with 80 additions and 54 deletions

View File

@ -31,6 +31,7 @@ class AutoExtendClaimTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private int getLowestBuiltY() private int getLowestBuiltY()
{ {
int y = this.claim.getLesserBoundaryCorner().getBlockY(); int y = this.claim.getLesserBoundaryCorner().getBlockY();

View File

@ -139,6 +139,7 @@ public class BlockEventHandler implements Listener
if(!player.hasPermission("griefprevention.eavesdropsigns")) if(!player.hasPermission("griefprevention.eavesdropsigns"))
{ {
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers(); Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
for(Player otherPlayer : players) for(Player otherPlayer : players)
{ {
@ -174,6 +175,7 @@ public class BlockEventHandler implements Listener
} }
//when a player places a block... //when a player places a block...
@SuppressWarnings("null")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent placeEvent) public void onBlockPlace(BlockPlaceEvent placeEvent)
{ {
@ -754,7 +756,7 @@ public class BlockEventHandler implements Listener
//from where? //from where?
Block fromBlock = dispenseEvent.getBlock(); Block fromBlock = dispenseEvent.getBlock();
Dispenser dispenser = new Dispenser(fromBlock.getType(), fromBlock.getData()); Dispenser dispenser = (Dispenser)fromBlock.getState();
//to where? //to where?
Block toBlock = fromBlock.getRelative(dispenser.getFacing()); Block toBlock = fromBlock.getRelative(dispenser.getFacing());

View File

@ -825,6 +825,7 @@ public class Claim
return thisCorner.getWorld().getName().compareTo(otherCorner.getWorld().getName()) < 0; return thisCorner.getWorld().getName().compareTo(otherCorner.getWorld().getName()) < 0;
} }
@SuppressWarnings("deprecation")
long getPlayerInvestmentScore() long getPlayerInvestmentScore()
{ {
//decide which blocks will be considered player placed //decide which blocks will be considered player placed

View File

@ -345,6 +345,8 @@ public abstract class DataStore
class NoTransferException extends Exception class NoTransferException extends Exception
{ {
private static final long serialVersionUID = 1L;
NoTransferException(String message) NoTransferException(String message)
{ {
super(message); super(message);
@ -1005,6 +1007,7 @@ public abstract class DataStore
//if the claim should be opened to looting //if the claim should be opened to looting
if(grantAccess) if(grantAccess)
{ {
@SuppressWarnings("deprecation")
Player winner = GriefPrevention.instance.getServer().getPlayer(winnerName); Player winner = GriefPrevention.instance.getServer().getPlayer(winnerName);
if(winner != null) if(winner != null)
{ {
@ -1020,7 +1023,9 @@ public abstract class DataStore
//if the siege ended due to death, transfer inventory to winner //if the siege ended due to death, transfer inventory to winner
if(death) if(death)
{ {
@SuppressWarnings("deprecation")
Player winner = GriefPrevention.instance.getServer().getPlayer(winnerName); Player winner = GriefPrevention.instance.getServer().getPlayer(winnerName);
@SuppressWarnings("deprecation")
Player loser = GriefPrevention.instance.getServer().getPlayer(loserName); Player loser = GriefPrevention.instance.getServer().getPlayer(loserName);
if(winner != null && loser != null) if(winner != null && loser != null)
{ {

View File

@ -43,6 +43,7 @@ class DeliverClaimBlocksTask implements Runnable
//if no player specified, this task will create a player-specific task for each online player, scheduled one tick apart //if no player specified, this task will create a player-specific task for each online player, scheduled one tick apart
if(this.player == null) if(this.player == null)
{ {
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers(); Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
long i = 0; long i = 0;

View File

@ -50,7 +50,6 @@ import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.Rabbit; import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Rabbit.Type;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
@ -166,6 +165,7 @@ public class EntityEventHandler implements Listener
{ {
//when not allowed, drop as item instead of forming a block //when not allowed, drop as item instead of forming a block
event.setCancelled(true); event.setCancelled(true);
@SuppressWarnings("deprecation")
ItemStack itemStack = new ItemStack(entity.getMaterial(), 1, entity.getBlockData()); ItemStack itemStack = new ItemStack(entity.getMaterial(), 1, entity.getBlockData());
Item item = block.getWorld().dropItem(entity.getLocation(), itemStack); Item item = block.getWorld().dropItem(entity.getLocation(), itemStack);
item.setVelocity(new Vector()); item.setVelocity(new Vector());
@ -218,6 +218,7 @@ public class EntityEventHandler implements Listener
this.handleExplosion(explodeEvent.getBlock().getLocation(), null, explodeEvent.blockList()); this.handleExplosion(explodeEvent.getBlock().getLocation(), null, explodeEvent.blockList());
} }
@SuppressWarnings("deprecation")
void handleExplosion(Location location, Entity entity, List<Block> blocks) void handleExplosion(Location location, Entity entity, List<Block> blocks)
{ {
//only applies to claims-enabled worlds //only applies to claims-enabled worlds

View File

@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -374,6 +374,7 @@ public class GriefPrevention extends JavaPlugin
namesThread.start(); namesThread.start();
//load ignore lists for any already-online players //load ignore lists for any already-online players
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers(); Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
for(Player player : players) for(Player player : players)
{ {
@ -926,6 +927,7 @@ public class GriefPrevention extends JavaPlugin
} }
//handles slash commands //handles slash commands
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
Player player = null; Player player = null;
@ -2878,6 +2880,7 @@ public class GriefPrevention extends JavaPlugin
} }
} }
@SuppressWarnings("deprecation")
public OfflinePlayer resolvePlayerByName(String name) public OfflinePlayer resolvePlayerByName(String name)
{ {
//try online players first //try online players first
@ -2951,6 +2954,7 @@ public class GriefPrevention extends JavaPlugin
public void onDisable() public void onDisable()
{ {
//save data for any online players //save data for any online players
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)this.getServer().getOnlinePlayers(); Collection<Player> players = (Collection<Player>)this.getServer().getOnlinePlayers();
for(Player player : players) for(Player player : players)
{ {
@ -3222,6 +3226,7 @@ public class GriefPrevention extends JavaPlugin
} }
} }
@SuppressWarnings("deprecation")
public void restoreChunk(Chunk chunk, int miny, boolean aggressiveMode, long delayInTicks, Player playerReceivingVisualization) public void restoreChunk(Chunk chunk, int miny, boolean aggressiveMode, long delayInTicks, Player playerReceivingVisualization)
{ {
//build a snapshot of this chunk, including 1 block boundary outside of the chunk all the way around //build a snapshot of this chunk, including 1 block boundary outside of the chunk all the way around

View File

@ -19,9 +19,7 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.Vector; import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -34,7 +32,6 @@ import me.ryanhamshire.GriefPrevention.Visualization;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
//holds all of GriefPrevention's player-tied data //holds all of GriefPrevention's player-tied data
public class PlayerData public class PlayerData

View File

@ -31,19 +31,14 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.bukkit.Achievement;
import org.bukkit.BanList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.TravelAgent; import org.bukkit.TravelAgent;
import org.bukkit.BanList.Type;
import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -56,7 +51,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Hanging; import org.bukkit.entity.Hanging;
import org.bukkit.entity.Horse; import org.bukkit.entity.Horse;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
@ -497,6 +491,7 @@ class PlayerEventHandler implements Listener
if(category == CommandCategory.Whisper && args.length > 1) if(category == CommandCategory.Whisper && args.length > 1)
{ {
//determine target player, might be NULL //determine target player, might be NULL
@SuppressWarnings("deprecation")
Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]); Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]);
//softmute feature //softmute feature
@ -522,6 +517,7 @@ class PlayerEventHandler implements Listener
String logMessage = logMessageBuilder.toString(); String logMessage = logMessageBuilder.toString();
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers(); Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
for(Player onlinePlayer : players) for(Player onlinePlayer : players)
{ {
@ -758,6 +754,7 @@ class PlayerEventHandler implements Listener
} }
//when a player successfully joins the server... //when a player successfully joins the server...
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
void onPlayerJoin(PlayerJoinEvent event) void onPlayerJoin(PlayerJoinEvent event)
{ {
@ -840,6 +837,7 @@ class PlayerEventHandler implements Listener
GriefPrevention.AddLogEntry("Auto-banned new player " + player.getName() + " because that account is using an IP address very recently used by banned player " + info.bannedAccountName + " (" + info.address.toString() + ").", CustomLogEntryTypes.AdminActivity); GriefPrevention.AddLogEntry("Auto-banned new player " + player.getName() + " because that account is using an IP address very recently used by banned player " + info.bannedAccountName + " (" + info.address.toString() + ").", CustomLogEntryTypes.AdminActivity);
//notify any online ops //notify any online ops
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers(); Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
for(Player otherPlayer : players) for(Player otherPlayer : players)
{ {
@ -1563,6 +1561,7 @@ class PlayerEventHandler implements Listener
} }
//when a player interacts with the world //when a player interacts with the world
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
void onPlayerInteract(PlayerInteractEvent event) void onPlayerInteract(PlayerInteractEvent event)
{ {
@ -2490,6 +2489,7 @@ class PlayerEventHandler implements Listener
private ConcurrentHashMap<Integer, Boolean> inventoryHolderCache = new ConcurrentHashMap<Integer, Boolean>(); private ConcurrentHashMap<Integer, Boolean> inventoryHolderCache = new ConcurrentHashMap<Integer, Boolean>();
private boolean isInventoryHolder(Block clickedBlock) private boolean isInventoryHolder(Block clickedBlock)
{ {
@SuppressWarnings("deprecation")
Integer cacheKey = clickedBlock.getTypeId(); Integer cacheKey = clickedBlock.getTypeId();
Boolean cachedValue = this.inventoryHolderCache.get(cacheKey); Boolean cachedValue = this.inventoryHolderCache.get(cacheKey);
if(cachedValue != null) if(cachedValue != null)

View File

@ -18,9 +18,6 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.BanList.Type;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
//kicks or bans a player //kicks or bans a player

View File

@ -55,6 +55,7 @@ class RestoreNatureExecutionTask implements Runnable
this.player = player; this.player = player;
} }
@SuppressWarnings("deprecation")
@Override @Override
public void run() public void run()
{ {

View File

@ -50,6 +50,7 @@ class RestoreNatureProcessingTask implements Runnable
private ArrayList<Integer> notAllowedToHang; //natural blocks which don't naturally hang in their air private ArrayList<Integer> notAllowedToHang; //natural blocks which don't naturally hang in their air
private ArrayList<Integer> playerBlocks; //a "complete" list of player-placed blocks. MUST BE MAINTAINED as patches introduce more private ArrayList<Integer> playerBlocks; //a "complete" list of player-placed blocks. MUST BE MAINTAINED as patches introduce more
@SuppressWarnings("deprecation")
public RestoreNatureProcessingTask(BlockSnapshot[][][] snapshots, int miny, Environment environment, Biome biome, Location lesserBoundaryCorner, Location greaterBoundaryCorner, int seaLevel, boolean aggressiveMode, boolean creativeMode, Player player) public RestoreNatureProcessingTask(BlockSnapshot[][][] snapshots, int miny, Environment environment, Biome biome, Location lesserBoundaryCorner, Location greaterBoundaryCorner, int seaLevel, boolean aggressiveMode, boolean creativeMode, Player player)
{ {
this.snapshots = snapshots; this.snapshots = snapshots;
@ -149,6 +150,7 @@ class RestoreNatureProcessingTask implements Runnable
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task); GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task);
} }
@SuppressWarnings("deprecation")
private void removePlayerLeaves() private void removePlayerLeaves()
{ {
if(this.seaLevel < 1) return; if(this.seaLevel < 1) return;
@ -171,6 +173,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
//converts sandstone adjacent to sand to sand, and any other sandstone to air //converts sandstone adjacent to sand to sand, and any other sandstone to air
@SuppressWarnings("deprecation")
private void removeSandstone() private void removeSandstone()
{ {
for(int x = 1; x < snapshots.length - 1; x++) for(int x = 1; x < snapshots.length - 1; x++)
@ -210,6 +213,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private void reduceStone() private void reduceStone()
{ {
if(this.seaLevel < 1) return; if(this.seaLevel < 1) return;
@ -257,6 +261,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private void reduceLogs() private void reduceLogs()
{ {
if(this.seaLevel < 1) return; if(this.seaLevel < 1) return;
@ -295,6 +300,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private void removePlayerBlocks() private void removePlayerBlocks()
{ {
int miny = this.miny; int miny = this.miny;
@ -317,6 +323,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private void removeHanging() private void removeHanging()
{ {
int miny = this.miny; int miny = this.miny;
@ -343,6 +350,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private void removeWallsAndTowers() private void removeWallsAndTowers()
{ {
int [] excludedBlocksArray = new int [] int [] excludedBlocksArray = new int []
@ -396,6 +404,7 @@ class RestoreNatureProcessingTask implements Runnable
}while(changed); }while(changed);
} }
@SuppressWarnings("deprecation")
private void coverSurfaceStone() private void coverSurfaceStone()
{ {
for(int x = 1; x < snapshots.length - 1; x++) for(int x = 1; x < snapshots.length - 1; x++)
@ -420,6 +429,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private void fillHolesAndTrenches() private void fillHolesAndTrenches()
{ {
ArrayList<Integer> fillableBlocks = new ArrayList<Integer>(); ArrayList<Integer> fillableBlocks = new ArrayList<Integer>();
@ -478,6 +488,7 @@ class RestoreNatureProcessingTask implements Runnable
}while(changed); }while(changed);
} }
@SuppressWarnings("deprecation")
private void fixWater() private void fixWater()
{ {
int miny = this.miny; int miny = this.miny;
@ -562,6 +573,7 @@ class RestoreNatureProcessingTask implements Runnable
}while(changed); }while(changed);
} }
@SuppressWarnings("deprecation")
private void removeDumpedFluids() private void removeDumpedFluids()
{ {
if(this.seaLevel < 1) return; if(this.seaLevel < 1) return;
@ -586,6 +598,7 @@ class RestoreNatureProcessingTask implements Runnable
} }
} }
@SuppressWarnings("deprecation")
private int highestY(int x, int z, boolean ignoreLeaves) private int highestY(int x, int z, boolean ignoreLeaves)
{ {
int y; int y;
@ -607,6 +620,7 @@ class RestoreNatureProcessingTask implements Runnable
return y; return y;
} }
@SuppressWarnings("deprecation")
static ArrayList<Integer> getPlayerBlocks(Environment environment, Biome biome) static ArrayList<Integer> getPlayerBlocks(Environment environment, Biome biome)
{ {
//NOTE on this list. why not make a list of natural blocks? //NOTE on this list. why not make a list of natural blocks?

View File

@ -43,6 +43,7 @@ class SecureClaimTask implements Runnable
claim.doorsOpen = false; claim.doorsOpen = false;
//eject bad guys //eject bad guys
@SuppressWarnings("unchecked")
Collection<Player> onlinePlayers = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers(); Collection<Player> onlinePlayers = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
for(Player player : onlinePlayers) for(Player player : onlinePlayers)
{ {

View File

@ -53,6 +53,7 @@ public class Visualization
} }
//reverts a visualization by sending another block change list, this time with the real world block values //reverts a visualization by sending another block change list, this time with the real world block values
@SuppressWarnings("deprecation")
public static void Revert(Player player) public static void Revert(Player player)
{ {
if(!player.isOnline()) return; if(!player.isOnline()) return;
@ -125,6 +126,7 @@ public class Visualization
//adds a claim's visualization to the current visualization //adds a claim's visualization to the current visualization
//handy for combining several visualizations together, as when visualization a top level claim with several subdivisions inside //handy for combining several visualizations together, as when visualization a top level claim with several subdivisions inside
//locality is a performance consideration. only create visualization blocks for around 100 blocks of the locality //locality is a performance consideration. only create visualization blocks for around 100 blocks of the locality
@SuppressWarnings("deprecation")
private void addClaimElements(Claim claim, int height, VisualizationType visualizationType, Location locality) private void addClaimElements(Claim claim, int height, VisualizationType visualizationType, Location locality)
{ {
Location smallXsmallZ = claim.getLesserBoundaryCorner(); Location smallXsmallZ = claim.getLesserBoundaryCorner();

View File

@ -34,6 +34,7 @@ class VisualizationApplicationTask implements Runnable
this.player = player; this.player = player;
} }
@SuppressWarnings("deprecation")
@Override @Override
public void run() public void run()
{ {

View File

@ -2,8 +2,6 @@ package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;