diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 268f320..097337b 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -86,7 +86,7 @@ public class BlockEventHandler implements Listener this.dataStore = dataStore; //create the list of blocks which will not trigger a warning when they're placed outside of land claims - this.trashBlocks = new ArrayList(); + this.trashBlocks = new ArrayList<>(); this.trashBlocks.add(Material.COBBLESTONE); this.trashBlocks.add(Material.TORCH); this.trashBlocks.add(Material.DIRT); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java index 5e7f7ce..7a4dea5 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java @@ -59,10 +59,10 @@ public class Claim public UUID ownerID; //list of players who (beyond the claim owner) have permission to grant permissions in this claim - public ArrayList managers = new ArrayList(); + public ArrayList managers = new ArrayList<>(); //permissions for this claim, see ClaimPermission class - private HashMap playerIDToClaimPermissionMap = new HashMap(); + private HashMap playerIDToClaimPermissionMap = new HashMap<>(); //whether or not this claim is in the data store //if a claim instance isn't in the data store, it isn't "active" - players can't interract with it @@ -81,7 +81,7 @@ public class Claim //children (subdivisions) //note subdivisions themselves never have children - public ArrayList children = new ArrayList(); + public ArrayList children = new ArrayList<>(); //information about a siege involving this claim. null means no siege is impacting this claim public SiegeData siegeData = null; @@ -303,7 +303,7 @@ public class Claim Claim claim = new Claim (new Location(this.lesserBoundaryCorner.getWorld(), this.lesserBoundaryCorner.getBlockX() - howNear, this.lesserBoundaryCorner.getBlockY(), this.lesserBoundaryCorner.getBlockZ() - howNear), new Location(this.greaterBoundaryCorner.getWorld(), this.greaterBoundaryCorner.getBlockX() + howNear, this.greaterBoundaryCorner.getBlockY(), this.greaterBoundaryCorner.getBlockZ() + howNear), - null, new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList(), null); + null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null); return claim.contains(location, false, true); } @@ -942,7 +942,7 @@ public class Claim public ArrayList getChunks() { - ArrayList chunks = new ArrayList(); + ArrayList chunks = new ArrayList<>(); World world = this.getLesserBoundaryCorner().getWorld(); Chunk lesserChunk = this.getLesserBoundaryCorner().getChunk(); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java b/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java index 70d5c63..e092b36 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java @@ -86,7 +86,7 @@ class CleanupUnusedClaimTask implements Runnable if (expireEventCanceled()) return; //make a copy of this player's claim list - Vector claims = new Vector(); + Vector claims = new Vector<>(); for (int i = 0; i < ownerData.getClaims().size(); i++) { claims.add(ownerData.getClaims().get(i)); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java index d027d2c..33d4a10 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java @@ -65,14 +65,14 @@ public abstract class DataStore { //in-memory cache for player data - protected ConcurrentHashMap playerNameToPlayerDataMap = new ConcurrentHashMap(); + protected ConcurrentHashMap playerNameToPlayerDataMap = new ConcurrentHashMap<>(); //in-memory cache for group (permission-based) data - protected ConcurrentHashMap permissionToBonusBlocksMap = new ConcurrentHashMap(); + protected ConcurrentHashMap permissionToBonusBlocksMap = new ConcurrentHashMap<>(); //in-memory cache for claim data - ArrayList claims = new ArrayList(); - ConcurrentHashMap> chunksToClaimsMap = new ConcurrentHashMap>(); + ArrayList claims = new ArrayList<>(); + ConcurrentHashMap> chunksToClaimsMap = new ConcurrentHashMap<>(); //in-memory cache for messages private String[] messages; @@ -108,7 +108,7 @@ public abstract class DataStore static final String SUBDIVISION_VIDEO_URL = "" + ChatColor.DARK_AQUA + ChatColor.UNDERLINE + "bit.ly/mcgpsub" + ChatColor.RESET; //list of UUIDs which are soft-muted - ConcurrentHashMap softMuteMap = new ConcurrentHashMap(); + ConcurrentHashMap softMuteMap = new ConcurrentHashMap<>(); //world guard reference, if available private WorldGuardWrapper worldGuard = null; @@ -274,7 +274,7 @@ public abstract class DataStore { GriefPrevention.AddLogEntry("Failed to read from the banned words data file: " + e.toString()); e.printStackTrace(); - return new ArrayList(); + return new ArrayList<>(); } } @@ -781,7 +781,7 @@ public abstract class DataStore } else { - return Collections.unmodifiableCollection(new ArrayList()); + return Collections.unmodifiableCollection(new ArrayList<>()); } } @@ -904,10 +904,10 @@ public abstract class DataStore new Location(world, smallx, smally, smallz), new Location(world, bigx, bigy, bigz), ownerID, - new ArrayList(), - new ArrayList(), - new ArrayList(), - new ArrayList(), + new ArrayList<>(), + new ArrayList<>(), + new ArrayList<>(), + new ArrayList<>(), id); newClaim.parent = parent; @@ -1200,7 +1200,7 @@ public abstract class DataStore } //timestamp for each siege cooldown to end - private HashMap siegeCooldownRemaining = new HashMap(); + private HashMap 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) @@ -1275,7 +1275,7 @@ public abstract class DataStore synchronized public void deleteClaimsForPlayer(UUID playerID, boolean releasePets) { //make a list of the player's claims - ArrayList claimsToDelete = new ArrayList(); + ArrayList claimsToDelete = new ArrayList<>(); for (int i = 0; i < this.claims.size(); i++) { Claim claim = this.claims.get(i); @@ -1492,7 +1492,7 @@ public abstract class DataStore Messages[] messageIDs = Messages.values(); this.messages = new String[Messages.values().length]; - HashMap defaults = new HashMap(); + HashMap defaults = new HashMap<>(); //initialize defaults this.addDefault(defaults, Messages.RespectingClaims, "Now respecting claims.", null); @@ -1810,7 +1810,7 @@ public abstract class DataStore if (this.getSchemaVersion() >= 1) return names; //list to build results - List resultNames = new ArrayList(); + List resultNames = new ArrayList<>(); for (String name : names) { @@ -1864,7 +1864,7 @@ public abstract class DataStore //gets all the claims "near" a location Set getNearbyClaims(Location location) { - Set claims = new HashSet(); + Set claims = new HashSet<>(); Chunk lesserChunk = location.getWorld().getChunkAt(location.subtract(150, 0, 150)); Chunk greaterChunk = location.getWorld().getChunkAt(location.add(300, 0, 300)); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/DatabaseDataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/DatabaseDataStore.java index 9b34c7e..49ff70b 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/DatabaseDataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/DatabaseDataStore.java @@ -188,9 +188,9 @@ public class DatabaseDataStore extends DataStore results = statement.executeQuery("SELECT * FROM griefprevention_playerdata;"); //make a list of changes to be made - HashMap changes = new HashMap(); + HashMap changes = new HashMap<>(); - ArrayList namesToConvert = new ArrayList(); + ArrayList namesToConvert = new ArrayList<>(); while (results.next()) { //get the id @@ -272,8 +272,8 @@ public class DatabaseDataStore extends DataStore results = statement.executeQuery("SELECT * FROM griefprevention_claimdata;"); - ArrayList claimsToRemove = new ArrayList(); - ArrayList subdivisionsToLoad = new ArrayList(); + ArrayList claimsToRemove = new ArrayList<>(); + ArrayList subdivisionsToLoad = new ArrayList<>(); List validWorlds = Bukkit.getServer().getWorlds(); Long claimID = null; @@ -442,10 +442,10 @@ public class DatabaseDataStore extends DataStore String owner = ""; if (claim.ownerID != null) owner = claim.ownerID.toString(); - ArrayList builders = new ArrayList(); - ArrayList containers = new ArrayList(); - ArrayList accessors = new ArrayList(); - ArrayList managers = new ArrayList(); + ArrayList builders = new ArrayList<>(); + ArrayList containers = new ArrayList<>(); + ArrayList accessors = new ArrayList<>(); + ArrayList managers = new ArrayList<>(); claim.getPermissions(builders, containers, accessors, managers); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/EntityCleanupTask.java b/src/main/java/me/ryanhamshire/GriefPrevention/EntityCleanupTask.java index 16d03cb..5df141d 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/EntityCleanupTask.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/EntityCleanupTask.java @@ -45,7 +45,7 @@ class EntityCleanupTask implements Runnable @Override public void run() { - ArrayList worlds = new ArrayList(); + ArrayList worlds = new ArrayList<>(); for (World world : GriefPrevention.instance.getServer().getWorlds()) { if (GriefPrevention.instance.config_claims_worldModes.get(world) == ClaimsMode.Creative) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 7915a64..50e32b5 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -342,7 +342,7 @@ public class EntityEventHandler implements Listener } //make a list of blocks which were allowed to explode - List explodedBlocks = new ArrayList(); + List explodedBlocks = new ArrayList<>(); Claim cachedClaim = null; for (int i = 0; i < blocks.size(); i++) { @@ -1055,7 +1055,7 @@ public class EntityEventHandler implements Listener message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement); if (sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, message); - PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList(), null)); + PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null)); Bukkit.getPluginManager().callEvent(pvpEvent); if (!pvpEvent.isCancelled()) { @@ -1451,7 +1451,7 @@ public class EntityEventHandler implements Listener } } - public static final HashSet positiveEffects = new HashSet(Arrays.asList + public static final HashSet positiveEffects = new HashSet<>(Arrays.asList ( PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java index 6d9ed8e..248bcf7 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java @@ -149,7 +149,7 @@ public class FlatFileDataStore extends DataStore if (this.getSchemaVersion() == 0) { files = playerDataFolder.listFiles(); - ArrayList namesToConvert = new ArrayList(); + ArrayList namesToConvert = new ArrayList<>(); for (File playerFile : files) { namesToConvert.add(playerFile.getName()); @@ -394,7 +394,7 @@ public class FlatFileDataStore extends DataStore void loadClaimData(File[] files) throws Exception { - ConcurrentHashMap orphans = new ConcurrentHashMap(); + ConcurrentHashMap orphans = new ConcurrentHashMap<>(); for (int i = 0; i < files.length; i++) { if (files[i].isFile()) //avoids folders @@ -430,7 +430,7 @@ public class FlatFileDataStore extends DataStore try { - ArrayList out_parentID = new ArrayList(); //hacky output parameter + ArrayList out_parentID = new ArrayList<>(); //hacky output parameter Claim claim = this.loadClaim(files[i], out_parentID, claimID); if (out_parentID.size() == 0 || out_parentID.get(0) == -1) { @@ -542,10 +542,10 @@ public class FlatFileDataStore extends DataStore if (claim.ownerID != null) ownerID = claim.ownerID.toString(); yaml.set("Owner", ownerID); - ArrayList builders = new ArrayList(); - ArrayList containers = new ArrayList(); - ArrayList accessors = new ArrayList(); - ArrayList managers = new ArrayList(); + ArrayList builders = new ArrayList<>(); + ArrayList containers = new ArrayList<>(); + ArrayList accessors = new ArrayList<>(); + ArrayList managers = new ArrayList<>(); claim.getPermissions(builders, containers, accessors, managers); yaml.set("Builders", builders); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 82c5775..8bbf398 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -80,7 +80,7 @@ public class GriefPrevention extends JavaPlugin public DataStore dataStore; //this tracks item stacks expected to drop which will need protection - ArrayList pendingItemWatchList = new ArrayList(); + ArrayList pendingItemWatchList = new ArrayList<>(); //log entry manager for GP's custom log files CustomLogger customLogger; @@ -461,7 +461,7 @@ public class GriefPrevention extends JavaPlugin config_pvp_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", false); //decide claim mode for each world - this.config_claims_worldModes = new ConcurrentHashMap(); + this.config_claims_worldModes = new ConcurrentHashMap<>(); this.config_creativeWorldsExist = false; for (World world : worlds) { @@ -532,7 +532,7 @@ public class GriefPrevention extends JavaPlugin } //pvp worlds list - this.config_pvp_specifiedWorlds = new HashMap(); + this.config_pvp_specifiedWorlds = new HashMap<>(); for (World world : worlds) { boolean pvpWorld = config.getBoolean("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), world.getPVP()); @@ -540,7 +540,7 @@ public class GriefPrevention extends JavaPlugin } //sea level - this.config_seaLevelOverride = new HashMap(); + this.config_seaLevelOverride = new HashMap<>(); for (int i = 0; i < worlds.size(); i++) { int seaLevelOverride = config.getInt("GriefPrevention.SeaLevelOverrides." + worlds.get(i).getName(), -1); @@ -679,7 +679,7 @@ public class GriefPrevention extends JavaPlugin } //default for siege worlds list - ArrayList defaultSiegeWorldNames = new ArrayList(); + ArrayList defaultSiegeWorldNames = new ArrayList<>(); //get siege world names from the config file List siegeEnabledWorldNames = config.getStringList("GriefPrevention.Siege.Worlds"); @@ -689,7 +689,7 @@ public class GriefPrevention extends JavaPlugin } //validate that list - this.config_siege_enabledWorlds = new ArrayList(); + this.config_siege_enabledWorlds = new ArrayList<>(); for (int i = 0; i < siegeEnabledWorldNames.size(); i++) { String worldName = siegeEnabledWorldNames.get(i); @@ -705,7 +705,7 @@ public class GriefPrevention extends JavaPlugin } //default siege blocks - this.config_siege_blocks = new ArrayList(); + this.config_siege_blocks = new ArrayList<>(); this.config_siege_blocks.add(Material.DIRT); this.config_siege_blocks.add(Material.GRASS_BLOCK); this.config_siege_blocks.add(Material.GRASS); @@ -741,7 +741,7 @@ public class GriefPrevention extends JavaPlugin this.config_siege_blocks.add(Material.SNOW); //build a default config entry - ArrayList defaultBreakableBlocksList = new ArrayList(); + ArrayList defaultBreakableBlocksList = new ArrayList<>(); for (int i = 0; i < this.config_siege_blocks.size(); i++) { defaultBreakableBlocksList.add(this.config_siege_blocks.get(i).name()); @@ -757,7 +757,7 @@ public class GriefPrevention extends JavaPlugin } //parse the list of siege-breakable blocks - this.config_siege_blocks = new ArrayList(); + this.config_siege_blocks = new ArrayList<>(); for (int i = 0; i < breakableBlocksList.size(); i++) { String blockName = breakableBlocksList.get(i); @@ -948,7 +948,7 @@ public class GriefPrevention extends JavaPlugin } //try to parse the list of commands requiring access trust in land claims - this.config_claims_commandsRequiringAccessTrust = new ArrayList(); + this.config_claims_commandsRequiringAccessTrust = new ArrayList<>(); String[] commands = accessTrustSlashCommands.split(";"); for (int i = 0; i < commands.length; i++) { @@ -959,7 +959,7 @@ public class GriefPrevention extends JavaPlugin } //try to parse the list of commands which should be monitored for spam - this.config_spam_monitorSlashCommands = new ArrayList(); + this.config_spam_monitorSlashCommands = new ArrayList<>(); commands = slashCommandsToMonitor.split(";"); for (int i = 0; i < commands.length; i++) { @@ -967,7 +967,7 @@ public class GriefPrevention extends JavaPlugin } //try to parse the list of commands which should be included in eavesdropping - this.config_eavesdrop_whisperCommands = new ArrayList(); + this.config_eavesdrop_whisperCommands = new ArrayList<>(); commands = whisperCommandsToMonitor.split(";"); for (int i = 0; i < commands.length; i++) { @@ -975,7 +975,7 @@ public class GriefPrevention extends JavaPlugin } //try to parse the list of commands which should be banned during pvp combat - this.config_pvp_blockedCommands = new ArrayList(); + this.config_pvp_blockedCommands = new ArrayList<>(); commands = bannedPvPCommandsList.split(";"); for (int i = 0; i < commands.length; i++) { @@ -1488,10 +1488,10 @@ public class GriefPrevention extends JavaPlugin //otherwise build a list of explicit permissions by permission level //and send that to the player - ArrayList builders = new ArrayList(); - ArrayList containers = new ArrayList(); - ArrayList accessors = new ArrayList(); - ArrayList managers = new ArrayList(); + ArrayList builders = new ArrayList<>(); + ArrayList containers = new ArrayList<>(); + ArrayList accessors = new ArrayList<>(); + ArrayList managers = new ArrayList<>(); claim.getPermissions(builders, containers, accessors, managers); GriefPrevention.sendMessage(player, TextMode.Info, Messages.TrustListHeader); @@ -2241,7 +2241,7 @@ public class GriefPrevention extends JavaPlugin else if (cmd.getName().equalsIgnoreCase("adminclaimslist")) { //find admin claims - Vector claims = new Vector(); + Vector claims = new Vector<>(); for (Claim claim : this.dataStore.claims) { if (claim.ownerID == null) //admin claim @@ -3004,7 +3004,7 @@ public class GriefPrevention extends JavaPlugin } //determine which claims should be modified - ArrayList targetClaims = new ArrayList(); + ArrayList targetClaims = new ArrayList<>(); if (claim == null) { PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); @@ -3140,7 +3140,7 @@ public class GriefPrevention extends JavaPlugin } //helper method to resolve a player by name - ConcurrentHashMap playerNameToIDMap = new ConcurrentHashMap(); + ConcurrentHashMap playerNameToIDMap = new ConcurrentHashMap<>(); //thread to build the above cache private class CacheOfflinePlayerNamesThread extends Thread @@ -3664,7 +3664,7 @@ public class GriefPrevention extends JavaPlugin Location lesserCorner = newClaim.getLesserBoundaryCorner(); Location greaterCorner = newClaim.getGreaterBoundaryCorner(); World world = lesserCorner.getWorld(); - ArrayList snapshots = new ArrayList(); + ArrayList snapshots = new ArrayList<>(); for (int chunkx = lesserCorner.getBlockX() / 16; chunkx <= greaterCorner.getBlockX() / 16; chunkx++) { for (int chunkz = lesserCorner.getBlockZ() / 16; chunkz <= greaterCorner.getBlockZ() / 16; chunkz++) @@ -3794,7 +3794,7 @@ public class GriefPrevention extends JavaPlugin */ //Track scheduled "rescues" so we can cancel them if the player happens to teleport elsewhere so we can cancel it. - ConcurrentHashMap portalReturnTaskMap = new ConcurrentHashMap(); + ConcurrentHashMap portalReturnTaskMap = new ConcurrentHashMap<>(); public void startRescueTask(Player player, Location location) { diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/MaterialCollection.java b/src/main/java/me/ryanhamshire/GriefPrevention/MaterialCollection.java index 3ef7bd3..0459054 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/MaterialCollection.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/MaterialCollection.java @@ -24,7 +24,7 @@ import java.util.Set; //ordered list of material info objects, for fast searching public class MaterialCollection { - Set materials = new HashSet(); + Set materials = new HashSet<>(); void Add(MaterialInfo material) { diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerData.java b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerData.java index 607abfd..574e274 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerData.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerData.java @@ -125,7 +125,7 @@ public class PlayerData //ignore list //true means invisible (admin-forced ignore), false means player-created ignore - public ConcurrentHashMap ignoredPlayers = new ConcurrentHashMap(); + public ConcurrentHashMap ignoredPlayers = new ConcurrentHashMap<>(); public boolean ignoreListChanged = false; //profanity warning, once per play session @@ -247,7 +247,7 @@ public class PlayerData { if (this.claims == null) { - this.claims = new Vector(); + this.claims = new Vector<>(); //find all the claims belonging to this player and note them for future reference DataStore dataStore = GriefPrevention.instance.dataStore; diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index bca8d0d..2b53ca1 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -111,13 +111,13 @@ class PlayerEventHandler implements Listener private GriefPrevention instance; //list of temporarily banned ip's - private ArrayList tempBannedIps = new ArrayList(); + private ArrayList 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 recentLoginLogoutNotifications = new ArrayList(); + private ArrayList recentLoginLogoutNotifications = new ArrayList<>(); //regex pattern for the "how do i claim land?" scanner private Pattern howToClaimPattern = null; @@ -163,7 +163,7 @@ class PlayerEventHandler implements Listener else if (this.dataStore.isSoftMuted(player.getUniqueId())) { String notificationMessage = "(Muted " + player.getName() + "): " + message; - Set recipientsToKeep = new HashSet(); + Set recipientsToKeep = new HashSet<>(); for (Player recipient : recipients) { if (this.dataStore.isSoftMuted(recipient.getUniqueId())) @@ -229,7 +229,7 @@ class PlayerEventHandler implements Listener //based on ignore lists, remove some of the audience if (!player.hasPermission("griefprevention.notignorable")) { - Set recipientsToRemove = new HashSet(); + Set recipientsToRemove = new HashSet<>(); PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); for (Player recipient : recipients) { @@ -537,7 +537,7 @@ class PlayerEventHandler implements Listener } } - private ConcurrentHashMap commandCategoryMap = new ConcurrentHashMap(); + private ConcurrentHashMap commandCategoryMap = new ConcurrentHashMap<>(); private CommandCategory getCommandCategory(String commandName) { @@ -548,7 +548,7 @@ class PlayerEventHandler implements Listener if (category != null) return category; //otherwise build a list of all the aliases of this command across all installed plugins - HashSet aliases = new HashSet(); + HashSet aliases = new HashSet<>(); aliases.add(commandName); aliases.add("minecraft:" + commandName); for (Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()) @@ -618,7 +618,7 @@ class PlayerEventHandler implements Listener GriefPrevention.AddLogEntry(entryBuilder.toString(), CustomLogEntryTypes.SocialActivity, true); } - private ConcurrentHashMap lastLoginThisServerSessionMap = new ConcurrentHashMap(); + private ConcurrentHashMap 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 deathTimestamps = new HashMap(); + private HashMap 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 heldLogoutMessages = new HashMap(); + private HashMap 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 commonAdjacentBlocks_water = new HashSet(Arrays.asList(Material.WATER, Material.FARMLAND, Material.DIRT, Material.STONE)); - private HashSet commonAdjacentBlocks_lava = new HashSet(Arrays.asList(Material.LAVA, Material.DIRT, Material.STONE)); + private HashSet commonAdjacentBlocks_water = new HashSet<>(Arrays.asList(Material.WATER, Material.FARMLAND, Material.DIRT, Material.STONE)); + private HashSet commonAdjacentBlocks_lava = new HashSet<>(Arrays.asList(Material.LAVA, Material.DIRT, Material.STONE)); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent bucketEvent) @@ -2145,7 +2145,7 @@ class PlayerEventHandler implements Listener //if in restore nature fill mode if (playerData.shovelMode == ShovelMode.RestoreNatureFill) { - ArrayList allowedFillBlocks = new ArrayList(); + ArrayList allowedFillBlocks = new ArrayList<>(); Environment environment = clickedBlock.getWorld().getEnvironment(); if (environment == Environment.NETHER) { @@ -2474,7 +2474,7 @@ class PlayerEventHandler implements Listener instance.sendMessage(player, TextMode.Instr, Messages.ClaimStart); //show him where he's working - Claim newClaim = new Claim(clickedBlock.getLocation(), clickedBlock.getLocation(), null, new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList(), null); + Claim newClaim = new Claim(clickedBlock.getLocation(), clickedBlock.getLocation(), null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null); Visualization visualization = Visualization.FromClaim(newClaim, clickedBlock.getY(), VisualizationType.RestoreNature, player.getLocation()); // alert plugins of a visualization @@ -2624,7 +2624,7 @@ class PlayerEventHandler implements Listener } //determines whether a block type is an inventory holder. uses a caching strategy to save cpu time - private ConcurrentHashMap inventoryHolderCache = new ConcurrentHashMap(); + private ConcurrentHashMap inventoryHolderCache = new ConcurrentHashMap<>(); private boolean isInventoryHolder(Block clickedBlock) { diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java b/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java index c58c6fe..99646f8 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java @@ -122,7 +122,7 @@ class RestoreNatureExecutionTask implements Runnable //show visualization to player who started the restoration if (player != null) { - Claim claim = new Claim(lesserCorner, greaterCorner, null, new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList(), null); + Claim claim = new Claim(lesserCorner, greaterCorner, null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null); Visualization visualization = Visualization.FromClaim(claim, player.getLocation().getBlockY(), VisualizationType.RestoreNature, player.getLocation()); Visualization.Apply(player, visualization); } diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureProcessingTask.java b/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureProcessingTask.java index 15e86b2..fea3e63 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureProcessingTask.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/RestoreNatureProcessingTask.java @@ -68,7 +68,7 @@ class RestoreNatureProcessingTask implements Runnable this.player = player; this.creativeMode = creativeMode; - this.notAllowedToHang = new ArrayList(); + this.notAllowedToHang = new ArrayList<>(); this.notAllowedToHang.add(Material.DIRT); this.notAllowedToHang.add(Material.GRASS); this.notAllowedToHang.add(Material.SNOW); @@ -85,7 +85,7 @@ class RestoreNatureProcessingTask implements Runnable this.notAllowedToHang.add(Material.STONE); } - this.playerBlocks = new ArrayList(); + this.playerBlocks = new ArrayList<>(); this.playerBlocks.addAll(RestoreNatureProcessingTask.getPlayerBlocks(this.environment, this.biome)); //in aggressive or creative world mode, also treat these blocks as user placed, to be removed @@ -390,7 +390,7 @@ class RestoreNatureProcessingTask implements Runnable Material.LILY_PAD }; - ArrayList excludedBlocks = new ArrayList(); + ArrayList excludedBlocks = new ArrayList<>(); for (int i = 0; i < excludedBlocksArray.length; i++) excludedBlocks.add(excludedBlocksArray[i]); excludedBlocks.addAll(Tag.SAPLINGS.getValues()); @@ -455,13 +455,13 @@ class RestoreNatureProcessingTask implements Runnable private void fillHolesAndTrenches() { - ArrayList fillableBlocks = new ArrayList(); + ArrayList fillableBlocks = new ArrayList<>(); fillableBlocks.add(Material.AIR); fillableBlocks.add(Material.WATER); fillableBlocks.add(Material.LAVA); fillableBlocks.add(Material.GRASS); - ArrayList notSuitableForFillBlocks = new ArrayList(); + ArrayList notSuitableForFillBlocks = new ArrayList<>(); notSuitableForFillBlocks.add(Material.GRASS); notSuitableForFillBlocks.add(Material.CACTUS); notSuitableForFillBlocks.add(Material.WATER); @@ -647,7 +647,7 @@ class RestoreNatureProcessingTask implements Runnable //NOTE on this list. why not make a list of natural blocks? //answer: better to leave a few player blocks than to remove too many natural blocks. remember we're "restoring nature" //a few extra player blocks can be manually removed, but it will be impossible to guess exactly which natural materials to use in manual repair of an overzealous block removal - ArrayList playerBlocks = new ArrayList(); + ArrayList playerBlocks = new ArrayList<>(); playerBlocks.add(Material.FIRE); playerBlocks.add(Material.WHITE_BED); playerBlocks.add(Material.ORANGE_BED); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/SiegeData.java b/src/main/java/me/ryanhamshire/GriefPrevention/SiegeData.java index 847e691..4678cd2 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/SiegeData.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/SiegeData.java @@ -34,7 +34,7 @@ public class SiegeData { this.defender = defender; this.attacker = attacker; - this.claims = new ArrayList(); + this.claims = new ArrayList<>(); this.claims.add(claim); } } diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/SpamDetector.java b/src/main/java/me/ryanhamshire/GriefPrevention/SpamDetector.java index 31359dd..176ce04 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/SpamDetector.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/SpamDetector.java @@ -14,7 +14,7 @@ class SpamDetector private int duplicateMessageCount = 0; //data for individual chatters - ConcurrentHashMap dataStore = new ConcurrentHashMap(); + ConcurrentHashMap dataStore = new ConcurrentHashMap<>(); private ChatterData getChatterData(UUID chatterID) { @@ -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 recentMessageLengths = new ConcurrentLinkedQueue(); + private ConcurrentLinkedQueue recentMessageLengths = new ConcurrentLinkedQueue<>(); private int recentTotalLength = 0; public void AddMessage(String message, long timestamp) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java b/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java index ddc6db6..620bdae 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java @@ -47,12 +47,12 @@ class UUIDFetcher { if (lookupCache == null) { - lookupCache = new HashMap(); + lookupCache = new HashMap<>(); } if (correctedNames == null) { - correctedNames = new HashMap(); + correctedNames = new HashMap<>(); } GriefPrevention.AddLogEntry("UUID conversion process started. Please be patient - this may take a while."); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/Visualization.java b/src/main/java/me/ryanhamshire/GriefPrevention/Visualization.java index 54e495a..e9e0b18 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/Visualization.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/Visualization.java @@ -37,7 +37,7 @@ import java.util.ArrayList; //the result is that those players see new blocks, but the world hasn't been changed. other players can't see the new blocks, either. public class Visualization { - public ArrayList elements = new ArrayList(); + public ArrayList elements = new ArrayList<>(); //sends a visualization to a player public static void Apply(Player player, Visualization visualization)