Finalize fields where possible (#1021)
This commit is contained in:
parent
bf214afe2e
commit
26124d3dee
|
|
@ -11,9 +11,9 @@ import java.util.ArrayList;
|
|||
//automatically extends a claim downward based on block types detected
|
||||
class AutoExtendClaimTask implements Runnable
|
||||
{
|
||||
private Claim claim;
|
||||
private ArrayList<ChunkSnapshot> chunks;
|
||||
private Environment worldType;
|
||||
private final Claim claim;
|
||||
private final ArrayList<ChunkSnapshot> chunks;
|
||||
private final Environment worldType;
|
||||
|
||||
public AutoExtendClaimTask(Claim claim, ArrayList<ChunkSnapshot> chunks, Environment worldType)
|
||||
{
|
||||
|
|
@ -113,8 +113,8 @@ class AutoExtendClaimTask implements Runnable
|
|||
//runs in the main execution thread, where it can safely change claims and save those changes
|
||||
private class ExecuteExtendClaimTask implements Runnable
|
||||
{
|
||||
private Claim claim;
|
||||
private int newY;
|
||||
private final Claim claim;
|
||||
private final int newY;
|
||||
|
||||
public ExecuteExtendClaimTask(Claim claim, int newY)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ import java.util.UUID;
|
|||
public class BlockEventHandler implements Listener
|
||||
{
|
||||
//convenience reference to singleton datastore
|
||||
private DataStore dataStore;
|
||||
private final DataStore dataStore;
|
||||
|
||||
private ArrayList<Material> trashBlocks;
|
||||
private final ArrayList<Material> trashBlocks;
|
||||
|
||||
//constructor
|
||||
public BlockEventHandler(DataStore dataStore)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.bukkit.Bukkit;
|
|||
//used to send delayed messages, for example a quit message after the player has been gone a while
|
||||
class BroadcastMessageTask implements Runnable
|
||||
{
|
||||
private String message;
|
||||
private final String message;
|
||||
|
||||
public BroadcastMessageTask(String message)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ class CheckForPortalTrapTask extends BukkitRunnable
|
|||
{
|
||||
GriefPrevention instance;
|
||||
//player who recently teleported via nether portal
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
//where to send the player back to if he hasn't left the portal frame
|
||||
private Location returnLocation;
|
||||
private final Location returnLocation;
|
||||
|
||||
public CheckForPortalTrapTask(Player player, GriefPrevention plugin, Location locationToReturn)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class CustomLogger
|
|||
private final int secondsBetweenWrites = 300;
|
||||
|
||||
//stringbuilder is not thread safe, stringbuffer is
|
||||
private StringBuffer queuedEntries = new StringBuffer();
|
||||
private final StringBuffer queuedEntries = new StringBuffer();
|
||||
|
||||
CustomLogger()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ public abstract class DataStore
|
|||
}
|
||||
|
||||
//turns a location into a string, useful in data storage
|
||||
private String locationStringDelimiter = ";";
|
||||
private final String locationStringDelimiter = ";";
|
||||
|
||||
String locationToString(Location location)
|
||||
{
|
||||
|
|
@ -1198,7 +1198,7 @@ public abstract class DataStore
|
|||
}
|
||||
|
||||
//timestamp for each siege cooldown to end
|
||||
private HashMap<String, Long> siegeCooldownRemaining = new HashMap<>();
|
||||
private final HashMap<String, Long> siegeCooldownRemaining = new HashMap<>();
|
||||
|
||||
//whether or not a sieger can siege a particular victim or claim, considering only cooldowns
|
||||
synchronized public boolean onCooldown(Player attacker, Player defender, Claim defenderClaim)
|
||||
|
|
@ -1838,8 +1838,8 @@ public abstract class DataStore
|
|||
|
||||
private class SavePlayerDataThread extends Thread
|
||||
{
|
||||
private UUID playerID;
|
||||
private PlayerData playerData;
|
||||
private final UUID playerID;
|
||||
private final PlayerData playerData;
|
||||
|
||||
SavePlayerDataThread(UUID playerID, PlayerData playerData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ public class DatabaseDataStore extends DataStore
|
|||
{
|
||||
private Connection databaseConnection = null;
|
||||
|
||||
private String databaseUrl;
|
||||
private String userName;
|
||||
private String password;
|
||||
private final String databaseUrl;
|
||||
private final String userName;
|
||||
private final String password;
|
||||
|
||||
private String updateNameSQL;
|
||||
private String insertClaimSQL;
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ import java.util.Collection;
|
|||
//runs every 5 minutes in the main thread, grants blocks per hour / 12 to each online player who appears to be actively playing
|
||||
class DeliverClaimBlocksTask implements Runnable
|
||||
{
|
||||
private Player player;
|
||||
private GriefPrevention instance;
|
||||
private int idleThresholdSquared;
|
||||
private final Player player;
|
||||
private final GriefPrevention instance;
|
||||
private final int idleThresholdSquared;
|
||||
|
||||
public DeliverClaimBlocksTask(Player player, GriefPrevention instance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import java.util.List;
|
|||
class EntityCleanupTask implements Runnable
|
||||
{
|
||||
//where to start cleaning in the list of entities
|
||||
private double percentageStart;
|
||||
private final double percentageStart;
|
||||
|
||||
public EntityCleanupTask(double percentageStart)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ import java.util.UUID;
|
|||
public class EntityEventHandler implements Listener
|
||||
{
|
||||
//convenience reference for the singleton datastore
|
||||
private DataStore dataStore;
|
||||
GriefPrevention instance;
|
||||
private final DataStore dataStore;
|
||||
private final GriefPrevention instance;
|
||||
private final NamespacedKey luredByPlayer;
|
||||
|
||||
public EntityEventHandler(DataStore dataStore, GriefPrevention plugin)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||
class EquipShovelProcessingTask implements Runnable
|
||||
{
|
||||
//player data
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public EquipShovelProcessingTask(Player player)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3137,8 +3137,8 @@ public class GriefPrevention extends JavaPlugin
|
|||
//thread to build the above cache
|
||||
private class CacheOfflinePlayerNamesThread extends Thread
|
||||
{
|
||||
private OfflinePlayer[] offlinePlayers;
|
||||
private ConcurrentHashMap<String, UUID> playerNameToIDMap;
|
||||
private final OfflinePlayer[] offlinePlayers;
|
||||
private final ConcurrentHashMap<String, UUID> playerNameToIDMap;
|
||||
|
||||
CacheOfflinePlayerNamesThread(OfflinePlayer[] offlinePlayers, ConcurrentHashMap<String, UUID> playerNameToIDMap)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
//loads ignore data from file into a hash map
|
||||
class IgnoreLoaderThread extends Thread
|
||||
{
|
||||
private UUID playerToLoad;
|
||||
private ConcurrentHashMap<UUID, Boolean> destinationMap;
|
||||
private final UUID playerToLoad;
|
||||
private final ConcurrentHashMap<UUID, Boolean> destinationMap;
|
||||
|
||||
IgnoreLoaderThread(UUID playerToLoad, ConcurrentHashMap<UUID, Boolean> destinationMap)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -107,23 +107,23 @@ import java.util.regex.Pattern;
|
|||
|
||||
class PlayerEventHandler implements Listener
|
||||
{
|
||||
private DataStore dataStore;
|
||||
private GriefPrevention instance;
|
||||
private final DataStore dataStore;
|
||||
private final GriefPrevention instance;
|
||||
|
||||
//list of temporarily banned ip's
|
||||
private ArrayList<IpBanInfo> tempBannedIps = new ArrayList<>();
|
||||
private final ArrayList<IpBanInfo> tempBannedIps = new ArrayList<>();
|
||||
|
||||
//number of milliseconds in a day
|
||||
private final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24;
|
||||
|
||||
//timestamps of login and logout notifications in the last minute
|
||||
private ArrayList<Long> recentLoginLogoutNotifications = new ArrayList<>();
|
||||
private final ArrayList<Long> recentLoginLogoutNotifications = new ArrayList<>();
|
||||
|
||||
//regex pattern for the "how do i claim land?" scanner
|
||||
private Pattern howToClaimPattern = null;
|
||||
|
||||
//matcher for banned words
|
||||
private WordFinder bannedWordFinder;
|
||||
private final WordFinder bannedWordFinder;
|
||||
|
||||
//spam tracker
|
||||
SpamDetector spamDetector = new SpamDetector();
|
||||
|
|
@ -537,7 +537,7 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
}
|
||||
|
||||
private ConcurrentHashMap<String, CommandCategory> commandCategoryMap = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, CommandCategory> commandCategoryMap = new ConcurrentHashMap<>();
|
||||
|
||||
private CommandCategory getCommandCategory(String commandName)
|
||||
{
|
||||
|
|
@ -618,7 +618,7 @@ class PlayerEventHandler implements Listener
|
|||
GriefPrevention.AddLogEntry(entryBuilder.toString(), CustomLogEntryTypes.SocialActivity, true);
|
||||
}
|
||||
|
||||
private ConcurrentHashMap<UUID, Date> lastLoginThisServerSessionMap = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<UUID, Date> lastLoginThisServerSessionMap = new ConcurrentHashMap<>();
|
||||
|
||||
//when a player attempts to join the server...
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
|
@ -875,7 +875,7 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//when a player dies...
|
||||
private HashMap<UUID, Long> deathTimestamps = new HashMap<>();
|
||||
private final HashMap<UUID, Long> deathTimestamps = new HashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
void onPlayerDeath(PlayerDeathEvent event)
|
||||
|
|
@ -908,7 +908,7 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//when a player quits...
|
||||
private HashMap<UUID, Integer> heldLogoutMessages = new HashMap<>();
|
||||
private final HashMap<UUID, Integer> heldLogoutMessages = new HashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
void onPlayerQuit(PlayerQuitEvent event)
|
||||
|
|
@ -1449,8 +1449,8 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//block use of buckets within other players' claims
|
||||
private HashSet<Material> commonAdjacentBlocks_water = new HashSet<>(Arrays.asList(Material.WATER, Material.FARMLAND, Material.DIRT, Material.STONE));
|
||||
private HashSet<Material> commonAdjacentBlocks_lava = new HashSet<>(Arrays.asList(Material.LAVA, Material.DIRT, Material.STONE));
|
||||
private final HashSet<Material> commonAdjacentBlocks_water = new HashSet<>(Arrays.asList(Material.WATER, Material.FARMLAND, Material.DIRT, Material.STONE));
|
||||
private final HashSet<Material> commonAdjacentBlocks_lava = new HashSet<>(Arrays.asList(Material.LAVA, Material.DIRT, Material.STONE));
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent bucketEvent)
|
||||
|
|
@ -2623,7 +2623,7 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//determines whether a block type is an inventory holder. uses a caching strategy to save cpu time
|
||||
private ConcurrentHashMap<Material, Boolean> inventoryHolderCache = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<Material, Boolean> inventoryHolderCache = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean isInventoryHolder(Block clickedBlock)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,16 +28,16 @@ import org.bukkit.entity.Player;
|
|||
class PlayerKickBanTask implements Runnable
|
||||
{
|
||||
//player to kick or ban
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
//message to send player.
|
||||
private String reason;
|
||||
private final String reason;
|
||||
|
||||
//source of ban
|
||||
private String source;
|
||||
private final String source;
|
||||
|
||||
//whether to ban
|
||||
private boolean ban;
|
||||
private final boolean ban;
|
||||
|
||||
public PlayerKickBanTask(Player player, String reason, String source, boolean ban)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ import org.bukkit.entity.Player;
|
|||
class PlayerRescueTask implements Runnable
|
||||
{
|
||||
//original location where /trapped was used
|
||||
private Location location;
|
||||
private final Location location;
|
||||
|
||||
//rescue destination, may be decided at instantiation or at execution
|
||||
private Location destination;
|
||||
|
||||
//player data
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public PlayerRescueTask(Player player, Location location, Location destination)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.bukkit.entity.Player;
|
|||
//used to send delayed messages, for example help text triggered by a player's chat
|
||||
class PvPImmunityValidationTask implements Runnable
|
||||
{
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public PvPImmunityValidationTask(Player player)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ class RestoreNatureExecutionTask implements Runnable
|
|||
{
|
||||
//results from processing thread
|
||||
//will be applied to the world
|
||||
private BlockSnapshot[][][] snapshots;
|
||||
private final BlockSnapshot[][][] snapshots;
|
||||
|
||||
//boundaries for changes
|
||||
private int miny;
|
||||
private Location lesserCorner;
|
||||
private Location greaterCorner;
|
||||
private final int miny;
|
||||
private final Location lesserCorner;
|
||||
private final Location greaterCorner;
|
||||
|
||||
//player who should be notified about the result (will see a visualization when the restoration is complete)
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public RestoreNatureExecutionTask(BlockSnapshot[][][] snapshots, int miny, Location lesserCorner, Location greaterCorner, Player player)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,23 +36,23 @@ class RestoreNatureProcessingTask implements Runnable
|
|||
{
|
||||
//world information captured from the main thread
|
||||
//will be updated and sent back to main thread to be applied to the world
|
||||
private BlockSnapshot[][][] snapshots;
|
||||
private final BlockSnapshot[][][] snapshots;
|
||||
|
||||
//other information collected from the main thread.
|
||||
//not to be updated, only to be passed back to main thread to provide some context about the operation
|
||||
private int miny;
|
||||
private Environment environment;
|
||||
private Location lesserBoundaryCorner;
|
||||
private Location greaterBoundaryCorner;
|
||||
private Player player; //absolutely must not be accessed. not thread safe.
|
||||
private Biome biome;
|
||||
private boolean creativeMode;
|
||||
private int seaLevel;
|
||||
private boolean aggressiveMode;
|
||||
private final Environment environment;
|
||||
private final Location lesserBoundaryCorner;
|
||||
private final Location greaterBoundaryCorner;
|
||||
private final Player player; //absolutely must not be accessed. not thread safe.
|
||||
private final Biome biome;
|
||||
private final boolean creativeMode;
|
||||
private final int seaLevel;
|
||||
private final boolean aggressiveMode;
|
||||
|
||||
//two lists of materials
|
||||
private ArrayList<Material> notAllowedToHang; //natural blocks which don't naturally hang in their air
|
||||
private ArrayList<Material> playerBlocks; //a "complete" list of player-placed blocks. MUST BE MAINTAINED as patches introduce more
|
||||
private final ArrayList<Material> notAllowedToHang; //natural blocks which don't naturally hang in their air
|
||||
private final ArrayList<Material> playerBlocks; //a "complete" list of player-placed blocks. MUST BE MAINTAINED as patches introduce more
|
||||
|
||||
|
||||
public RestoreNatureProcessingTask(BlockSnapshot[][][] snapshots, int miny, Environment environment, Biome biome, Location lesserBoundaryCorner, Location greaterBoundaryCorner, int seaLevel, boolean aggressiveMode, boolean creativeMode, Player player)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.Collection;
|
|||
//secures a claim after a siege looting window has closed
|
||||
class SecureClaimTask implements Runnable
|
||||
{
|
||||
private SiegeData siegeData;
|
||||
private final SiegeData siegeData;
|
||||
|
||||
public SecureClaimTask(SiegeData siegeData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import org.bukkit.entity.Player;
|
|||
//used to send delayed messages, for example help text triggered by a player's chat
|
||||
class SendPlayerMessageTask implements Runnable
|
||||
{
|
||||
private Player player;
|
||||
private ChatColor color;
|
||||
private String message;
|
||||
private final Player player;
|
||||
private final ChatColor color;
|
||||
private final String message;
|
||||
|
||||
public SendPlayerMessageTask(Player player, ChatColor color, String message)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.bukkit.entity.Player;
|
|||
//for example, defender escaped or attacker gave up and left
|
||||
class SiegeCheckupTask implements Runnable
|
||||
{
|
||||
private SiegeData siegeData;
|
||||
private final SiegeData siegeData;
|
||||
|
||||
public SiegeCheckupTask(SiegeData siegeData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ class ChatterData
|
|||
public boolean spamWarned = false; //whether the player has received a warning recently
|
||||
|
||||
//all recent message lengths and their total
|
||||
private ConcurrentLinkedQueue<LengthTimestampPair> recentMessageLengths = new ConcurrentLinkedQueue<>();
|
||||
private final ConcurrentLinkedQueue<LengthTimestampPair> recentMessageLengths = new ConcurrentLinkedQueue<>();
|
||||
private int recentTotalLength = 0;
|
||||
|
||||
public void AddMessage(String message, long timestamp)
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ import org.bukkit.entity.Player;
|
|||
//applies a visualization for a player by sending him block change packets
|
||||
class VisualizationApplicationTask implements Runnable
|
||||
{
|
||||
private Visualization visualization;
|
||||
private Player player;
|
||||
private PlayerData playerData;
|
||||
private final Visualization visualization;
|
||||
private final Player player;
|
||||
private final PlayerData playerData;
|
||||
|
||||
public VisualizationApplicationTask(Player player, PlayerData playerData, Visualization visualization)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ import java.util.Collections;
|
|||
//applies a visualization for a player by sending him block change packets
|
||||
class VisualizationReversionTask implements Runnable
|
||||
{
|
||||
private Visualization visualization;
|
||||
private Player player;
|
||||
private PlayerData playerData;
|
||||
private final Visualization visualization;
|
||||
private final Player player;
|
||||
private final PlayerData playerData;
|
||||
|
||||
public VisualizationReversionTask(Player player, PlayerData playerData, Visualization visualization)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import org.bukkit.inventory.meta.BookMeta;
|
|||
|
||||
public class WelcomeTask implements Runnable
|
||||
{
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
public WelcomeTask(Player player)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class AccrueClaimBlocksEvent extends Event
|
|||
return handlers;
|
||||
}
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private int blocksToAccrue;
|
||||
private boolean isIdle = false;
|
||||
private boolean cancelled = false;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class ClaimDeletedEvent extends Event
|
|||
return handlers;
|
||||
}
|
||||
|
||||
private Claim claim;
|
||||
private final Claim claim;
|
||||
|
||||
public ClaimDeletedEvent(Claim claim)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class ClaimModifiedEvent extends Event implements Cancellable
|
|||
|
||||
private final Claim from;
|
||||
private final Claim to;
|
||||
private CommandSender modifier;
|
||||
private final CommandSender modifier;
|
||||
private boolean cancelled;
|
||||
|
||||
public ClaimModifiedEvent(Claim from, Claim to, CommandSender modifier)
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ public class PlayerKickBanEvent extends Event
|
|||
return handlers;
|
||||
}
|
||||
|
||||
private Player player;
|
||||
private String reason;
|
||||
private String source;
|
||||
private boolean ban;
|
||||
private final Player player;
|
||||
private final String reason;
|
||||
private final String source;
|
||||
private final boolean ban;
|
||||
private boolean cancelled = false;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public class PreventBlockBreakEvent extends Event implements Cancellable
|
|||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private BlockBreakEvent innerEvent;
|
||||
private final BlockBreakEvent innerEvent;
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class Metrics {
|
|||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
private boolean enabled;
|
||||
private final boolean enabled;
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import java.util.concurrent.Callable;
|
|||
*/
|
||||
public class MetricsHandler
|
||||
{
|
||||
private Metrics metrics;
|
||||
private final Metrics metrics;
|
||||
|
||||
public MetricsHandler(GriefPrevention plugin, String dataMode)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user