From 183277db21b8aa7e2d74e23609e50e08bdb668e0 Mon Sep 17 00:00:00 2001 From: StevenLawson Date: Sat, 19 Jul 2014 21:02:00 -0400 Subject: [PATCH] Clean up sources of compile warnings. Move anything that causes deprecation warnings into TFM_DepreciationAggregator if no alternative implementation possible. --- .../Commands/Command_cbtool.java | 2 +- .../Commands/Command_deop.java | 2 +- .../Commands/Command_dispfill.java | 53 +++++++-------- .../Commands/Command_glist.java | 6 +- .../TotalFreedomMod/Commands/Command_op.java | 2 +- .../TotalFreedomMod/Commands/Command_ro.java | 3 +- .../Commands/Command_saconfig.java | 5 +- .../Commands/Command_setlever.java | 7 +- .../Commands/Command_trail.java | 3 +- .../Commands/Command_whitelist.java | 4 +- .../Commands/Command_whohas.java | 23 +++---- .../TotalFreedomMod/Commands/TFM_Command.java | 16 ++++- .../TotalFreedomMod/Config/TFM_Config.java | 14 +++- .../Config/TFM_MainConfig.java | 5 +- .../HTTPD/TFM_HTTPD_Manager.java | 1 - .../Listener/TFM_EntityListener.java | 2 +- .../Listener/TFM_PlayerListener.java | 8 +-- .../TotalFreedomMod/TFM_BanManager.java | 1 + .../TotalFreedomMod/TFM_CommandBlocker.java | 1 + .../TFM_DepreciationAggregator.java | 64 +++++++++++++++++++ .../TotalFreedomMod/TFM_RollbackManager.java | 16 ++--- .../TotalFreedomMod/TFM_ServiceChecker.java | 1 + .../TotalFreedomMod/TFM_Util.java | 8 +-- .../World/CleanroomBlockPopulator.java | 1 + .../World/CleanroomChunkGenerator.java | 1 + 25 files changed, 166 insertions(+), 83 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/TFM_DepreciationAggregator.java diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cbtool.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cbtool.java index 16de2d4..cd291a2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cbtool.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cbtool.java @@ -29,7 +29,7 @@ public class Command_cbtool extends TFM_Command if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player) { - Block targetBlock = sender_p.getTargetBlock(null, 100); + Block targetBlock = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getTargetBlock(sender_p, null, 100); playerMsg("Your target block: " + targetBlock.getLocation().toString()); return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java index c3403e7..96143ad 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java @@ -31,7 +31,7 @@ public class Command_deop extends TFM_Command // if the player is not online if (player == null) { - player = server.getOfflinePlayer(args[0]); + player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, args[0]); } TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_dispfill.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_dispfill.java index 3dbfbc5..f319bc6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_dispfill.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_dispfill.java @@ -35,52 +35,51 @@ public class Command_dispfill extends TFM_Command return true; } - String[] items_raw = StringUtils.split(args[1], ","); - List items = new ArrayList(); - for (String search_item : items_raw) + final List items = new ArrayList(); + + final String[] itemsRaw = StringUtils.split(args[1], ","); + for (final String searchItem : itemsRaw) { - ItemStack is = null; - - is = new ItemStack(Material.matchMaterial(search_item), 64); - - if (is == null) + Material material = Material.matchMaterial(searchItem); + if (material == null) { try { - is = new ItemStack(Integer.parseInt(search_item), 64); + material = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getMaterial(Integer.parseInt(searchItem)); } catch (NumberFormatException ex) { } } - if (is != null) + if (material != null) { - items.add(is); + items.add(new ItemStack(material, 64)); } else { - sender.sendMessage("Skipping invalid item: " + search_item); + sender.sendMessage("Skipping invalid item: " + searchItem); } } - ItemStack[] items_array = items.toArray(new ItemStack[items.size()]); + + final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]); int affected = 0; - Location center_location = sender_p.getLocation(); - Block center_block = center_location.getBlock(); - for (int x_offset = -radius; x_offset <= radius; x_offset++) + final Location centerLocation = sender_p.getLocation(); + final Block centerBlock = centerLocation.getBlock(); + for (int xOffset = -radius; xOffset <= radius; xOffset++) { - for (int y_offset = -radius; y_offset <= radius; y_offset++) + for (int yOffset = -radius; yOffset <= radius; yOffset++) { - for (int z_offset = -radius; z_offset <= radius; z_offset++) + for (int zOffset = -radius; zOffset <= radius; zOffset++) { - Block targetBlock = center_block.getRelative(x_offset, y_offset, z_offset); - if (targetBlock.getLocation().distanceSquared(center_location) < (radius * radius)) + final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, zOffset); + if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius)) { if (targetBlock.getType().equals(Material.DISPENSER)) { sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(targetBlock.getLocation())); - setDispenserContents(targetBlock, items_array); + setDispenserContents(targetBlock, itemsArray); affected++; } } @@ -98,11 +97,13 @@ public class Command_dispfill extends TFM_Command return true; } - private static void setDispenserContents(Block targetBlock, ItemStack[] items) + private static void setDispenserContents(final Block targetBlock, final ItemStack[] items) { - Dispenser dispenser = (Dispenser) targetBlock.getState(); - Inventory disp_inv = dispenser.getInventory(); - disp_inv.clear(); - disp_inv.addItem(items); + if (targetBlock.getType() == Material.DISPENSER) + { + final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory(); + dispenserInv.clear(); + dispenserInv.addItem(items); + } } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java index dd9bcd6..9dfed29 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.ArrayList; import java.util.List; -import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; import me.StevenLawson.TotalFreedomMod.TFM_AdminList; import me.StevenLawson.TotalFreedomMod.TFM_Ban; import me.StevenLawson.TotalFreedomMod.TFM_BanManager; @@ -10,7 +9,6 @@ import me.StevenLawson.TotalFreedomMod.TFM_Player; import me.StevenLawson.TotalFreedomMod.TFM_PlayerList; import me.StevenLawson.TotalFreedomMod.TFM_Util; import net.minecraft.util.org.apache.commons.lang3.StringUtils; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -52,8 +50,6 @@ public class Command_glist extends TFM_Command String username; final List ips = new ArrayList(); - - final Player player = getPlayer(args[1]); if (player == null) @@ -80,7 +76,7 @@ public class Command_glist extends TFM_Command { TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ","), true); - Player target = server.getPlayerExact(username); + Player target = getPlayer(username, true); if (target != null) { TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(target), target.getName())); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java index f889dbe..709fb27 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java @@ -40,7 +40,7 @@ public class Command_op extends TFM_Command { if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole) { - player = server.getOfflinePlayer(args[0]); + player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, args[0]); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ro.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ro.java index 52f7b84..cb0a371 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ro.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ro.java @@ -35,7 +35,7 @@ public class Command_ro extends TFM_Command { try { - fromMaterial = Material.getMaterial(Integer.parseInt(materialName)); + fromMaterial = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getMaterial(Integer.parseInt(materialName)); } catch (NumberFormatException ex) { @@ -106,7 +106,6 @@ public class Command_ro extends TFM_Command TFM_Util.adminAction(sender.getName(), "Remove complete! " + affected + " blocks removed.", false); - return true; } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java index 81630cf..c2cc221 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java @@ -162,7 +162,7 @@ public class Command_saconfig extends TFM_Command return true; } - player = Bukkit.getOfflinePlayer(superadmin.getLastLoginName()); + player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, superadmin.getLastLoginName()); } TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list", true); @@ -192,7 +192,6 @@ public class Command_saconfig extends TFM_Command String targetName = args[1]; - final Player player = getPlayer(targetName); if (player != null) @@ -207,7 +206,7 @@ public class Command_saconfig extends TFM_Command } TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true); - TFM_AdminList.removeSuperadmin(Bukkit.getOfflinePlayer(targetName)); + TFM_AdminList.removeSuperadmin(me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, targetName)); // Twitterbot if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean()) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setlever.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setlever.java index 853eb80..5ba66ee 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setlever.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_setlever.java @@ -1,6 +1,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.List; +import me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -54,15 +55,15 @@ public class Command_setlever extends TFM_Command final Location leverLocation = new Location(world, x, y, z); - final boolean leverOn = (args[4].trim().equalsIgnoreCase("on") || args[4].trim().equalsIgnoreCase("1")) ? true : false; + final boolean leverOn = (args[4].trim().equalsIgnoreCase("on") || args[4].trim().equalsIgnoreCase("1")); final Block targetBlock = leverLocation.getBlock(); if (targetBlock.getType() == Material.LEVER) { - org.bukkit.material.Lever lever = new org.bukkit.material.Lever(Material.LEVER, targetBlock.getData()); + org.bukkit.material.Lever lever = TFM_DepreciationAggregator.makeLeverWithData(TFM_DepreciationAggregator.getData_Block(targetBlock)); lever.setPowered(leverOn); - targetBlock.setData(lever.getData()); + TFM_DepreciationAggregator.setData_Block(targetBlock, TFM_DepreciationAggregator.getData_MaterialData(lever)); targetBlock.getState().update(); } else diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_trail.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_trail.java index 5675ec3..63fe4b9 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_trail.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_trail.java @@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.ArrayList; import java.util.List; import java.util.Random; -import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -75,7 +74,7 @@ public class Command_trail extends TFM_Command if (!fromBlock.equals(toBlock)) { fromBlock.setType(Material.WOOL); - fromBlock.setData((byte) RANDOM.nextInt(16)); + me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.setData_Block(fromBlock, (byte) RANDOM.nextInt(16)); } } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java index 50c2527..18588d5 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java @@ -92,7 +92,7 @@ public class Command_whitelist extends TFM_Command if (player == null) { - player = server.getOfflinePlayer(search_name); + player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, search_name); } TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the whitelist.", false); @@ -114,7 +114,7 @@ public class Command_whitelist extends TFM_Command if (player == null) { - player = server.getOfflinePlayer(search_name); + player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, search_name); } if (player.isWhitelisted()) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java index d75cd43..e518d55 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java @@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH) -@CommandParameters(description = "See who has a block and optionally smite", usage = "/ [smite]", aliases = "wh") +@CommandParameters(description = "See who has a block and optionally smite.", usage = "/ [smite]", aliases = "wh") public class Command_whohas extends TFM_Command { @Override @@ -31,28 +31,29 @@ public class Command_whohas extends TFM_Command } } - Material material = Material.matchMaterial(args[0]); + final String materialName = args[0]; + Material material = Material.matchMaterial(materialName); if (material == null) { try { - material = Material.getMaterial(Integer.parseInt(args[0])); + material = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getMaterial(Integer.parseInt(materialName)); } catch (NumberFormatException ex) { } - - if (material == null) - { - playerMsg("Invalid block: " + args[0], ChatColor.RED); - return true; - } } - List players = new ArrayList(); + if (material == null) + { + playerMsg("Invalid block: " + materialName, ChatColor.RED); + return true; + } - for (Player player : server.getOnlinePlayers()) + final List players = new ArrayList(); + + for (final Player player : server.getOnlinePlayers()) { if (player.getInventory().contains(material)) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java b/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java index c24a793..6f19abb 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java @@ -134,6 +134,11 @@ public abstract class TFM_Command } public Player getPlayer(final String partialName) + { + return getPlayer(partialName, false); + } + + public Player getPlayer(final String partialName, final boolean exact) { if (partialName == null || partialName.isEmpty()) { @@ -143,7 +148,7 @@ public abstract class TFM_Command final Player[] players = server.getOnlinePlayers(); // Check exact matches first. - for (Player player : players) + for (final Player player : players) { if (partialName.equalsIgnoreCase(player.getName())) { @@ -151,8 +156,13 @@ public abstract class TFM_Command } } + if (exact) + { + return null; + } + // Then check partial matches in name. - for (Player player : players) + for (final Player player : players) { if (player.getName().toLowerCase().contains(partialName.toLowerCase())) { @@ -161,7 +171,7 @@ public abstract class TFM_Command } // Then check partial matches in display name. - for (Player player : players) + for (final Player player : players) { if (player.getDisplayName().toLowerCase().contains(partialName.toLowerCase())) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java index acfb726..1d5019e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java +++ b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_Config.java @@ -2,8 +2,10 @@ package me.StevenLawson.TotalFreedomMod.Config; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.apache.commons.lang.exception.ExceptionUtils; +import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; @@ -137,9 +139,17 @@ public class TFM_Config extends YamlConfiguration // BukkitLib @ https://github. final YamlConfiguration DEFAULT_CONFIG = new YamlConfiguration(); try { - DEFAULT_CONFIG.load(plugin.getResource(configFile.getName())); + final InputStreamReader isr = new InputStreamReader(plugin.getResource(configFile.getName())); + DEFAULT_CONFIG.load(isr); + isr.close(); } - catch (Throwable ex) + catch (IOException ex) + { + plugin.getLogger().severe("Could not load default configuration: " + configFile.getName()); + plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex)); + return null; + } + catch (InvalidConfigurationException ex) { plugin.getLogger().severe("Could not load default configuration: " + configFile.getName()); plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex)); diff --git a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java index 1f01665..6f3c339 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_MainConfig.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.EnumMap; import java.util.List; import me.StevenLawson.TotalFreedomMod.TFM_Log; @@ -272,7 +273,9 @@ public class TFM_MainConfig try { defaults = new YamlConfiguration(); - defaults.load(defaultConfig); + final InputStreamReader isr = new InputStreamReader(defaultConfig); + defaults.load(isr); + isr.close(); } catch (IOException ex) { diff --git a/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java b/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java index 3d3f460..9ba3070 100644 --- a/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java +++ b/src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java @@ -17,7 +17,6 @@ import org.bukkit.Bukkit; public class TFM_HTTPD_Manager { - @Deprecated public static String MIME_DEFAULT_BINARY; // private static final Pattern EXT_REGEX; diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java index 3d2b001..3704818 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java @@ -158,7 +158,7 @@ public class TFM_EntityListener implements Listener if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { Projectile entity = event.getEntity(); - if (event.getEntityType() == EntityType.ARROW && entity.getShooter() instanceof Player) + if (event.getEntityType() == EntityType.ARROW) { entity.getWorld().createExplosion(entity.getLocation(), 2F); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 484531a..2041e8b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -107,7 +107,7 @@ public class TFM_PlayerListener implements Listener event.setCancelled(true); - final Location location = player.getTargetBlock(null, 5).getLocation(); + final Location location = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getTargetBlock(player, null, 5).getLocation(); final List entries = TFM_RollbackManager.getEntriesAtLocation(location); if (entries.isEmpty()) @@ -185,7 +185,7 @@ public class TFM_PlayerListener implements Listener if (event.getAction().equals(Action.LEFT_CLICK_AIR)) { - targetBlock = player.getTargetBlock(null, 120); + targetBlock = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getTargetBlock(player, null, 120); } else { @@ -222,7 +222,7 @@ public class TFM_PlayerListener implements Listener Vector playerDirection = location.getDirection().normalize(); double distance = 150.0; - Block targetBlock = player.getTargetBlock(null, Math.round((float) distance)); + Block targetBlock = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getTargetBlock(player, null, Math.round((float) distance)); if (targetBlock != null) { distance = location.distance(targetBlock.getLocation()); @@ -275,7 +275,7 @@ public class TFM_PlayerListener implements Listener final int STRENGTH = 4; // Clownfish - if (event.getItem().getData().getData() == 2) + if (TFM_DepreciationAggregator.getData_MaterialData(event.getItem().getData()) == 2) { if (TFM_AdminList.isSeniorAdmin(player, true) || TFM_AdminList.isTelnetAdmin(player, true)) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_BanManager.java b/src/me/StevenLawson/TotalFreedomMod/TFM_BanManager.java index 2c79e04..b54fff2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_BanManager.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_BanManager.java @@ -66,6 +66,7 @@ public class TFM_BanManager save(); TFM_Log.info("Loaded " + ipBans.size() + " IP bans and " + uuidBans.size() + " UUID bans"); + @SuppressWarnings("unchecked") final TFM_UuidResolver resolver = new TFM_UuidResolver((List) TFM_ConfigEntry.UNBANNABLE_USERNAMES.getList()); for (UUID uuid : resolver.call().values()) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java b/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java index 41525da..abc7aeb 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java @@ -40,6 +40,7 @@ public class TFM_CommandBlocker return; } + @SuppressWarnings("unchecked") List _blockedCommands = (List) TFM_ConfigEntry.BLOCKED_COMMANDS.getList(); for (String rawEntry : _blockedCommands) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_DepreciationAggregator.java b/src/me/StevenLawson/TotalFreedomMod/TFM_DepreciationAggregator.java new file mode 100644 index 0000000..6ffa5df --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_DepreciationAggregator.java @@ -0,0 +1,64 @@ +package me.StevenLawson.TotalFreedomMod; + +import java.util.HashSet; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Server; +import org.bukkit.block.Block; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.material.MaterialData; + +@SuppressWarnings("deprecation") +public class TFM_DepreciationAggregator +{ + public static Block getTargetBlock(LivingEntity entity, HashSet< Byte> transparent, int maxDistance) + { + return entity.getTargetBlock(transparent, maxDistance); + } + + public static OfflinePlayer getOfflinePlayer(Server server, String name) + { + return server.getOfflinePlayer(name); + } + + public static Material getMaterial(int id) + { + return Material.getMaterial(id); + } + + public static byte getData_MaterialData(MaterialData md) + { + return md.getData(); + } + + public static void setData_MaterialData(MaterialData md, byte data) + { + md.setData(data); + } + + public static byte getData_Block(Block block) + { + return block.getData(); + } + + public static void setData_Block(Block block, byte data) + { + block.setData(data); + } + + public static org.bukkit.material.Lever makeLeverWithData(byte data) + { + return new org.bukkit.material.Lever(Material.LEVER, data); + } + + public static int getTypeId_Block(Block block) + { + return block.getTypeId(); + } + + public static String getName_EntityType(EntityType et) + { + return et.getName(); + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_RollbackManager.java b/src/me/StevenLawson/TotalFreedomMod/TFM_RollbackManager.java index dd646fe..58220e9 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_RollbackManager.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_RollbackManager.java @@ -209,7 +209,7 @@ public class TFM_RollbackManager public final short y; public final int z; public final byte data; - public final short blockId; + public final Material blockMaterial; private final boolean isBreak; private RollbackEntry(String author, Block block, EntryType entryType) @@ -224,14 +224,14 @@ public class TFM_RollbackManager if (entryType == EntryType.BLOCK_BREAK) { - this.blockId = (short) block.getTypeId(); - this.data = block.getData(); + this.blockMaterial = block.getType(); + this.data = TFM_DepreciationAggregator.getData_Block(block); this.isBreak = true; } else { - this.blockId = (short) block.getTypeId(); - this.data = block.getData(); + this.blockMaterial = block.getType(); + this.data = TFM_DepreciationAggregator.getData_Block(block); this.isBreak = false; } } @@ -251,7 +251,7 @@ public class TFM_RollbackManager public Material getMaterial() { - return Material.getMaterial(blockId); + return blockMaterial; } public EntryType getType() @@ -265,7 +265,7 @@ public class TFM_RollbackManager if (isBreak) { block.setType(getMaterial()); - block.setData(data); + TFM_DepreciationAggregator.setData_Block(block, data); } else { @@ -284,7 +284,7 @@ public class TFM_RollbackManager else { block.setType(getMaterial()); - block.setData(data); + TFM_DepreciationAggregator.setData_Block(block, data); } } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java index b118f66..8352166 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java @@ -98,6 +98,7 @@ public class TFM_ServiceChecker final Iterator serviceIt = ((JSONObject) status.next()).entrySet().iterator(); while (serviceIt.hasNext()) { + @SuppressWarnings("unchecked") final Entry pair = (Entry) serviceIt.next(); if ("lastcheck".equals(pair.getKey())) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index fcd378a..41d5cf7 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -73,11 +73,11 @@ public class TFM_Util { try { - if (type.getName() != null) + if (TFM_DepreciationAggregator.getName_EntityType(type) != null) { if (Creature.class.isAssignableFrom(type.getEntityClass())) { - mobtypes.put(type.getName().toLowerCase(), type); + mobtypes.put(TFM_DepreciationAggregator.getName_EntityType(type).toLowerCase(), type); } } } @@ -527,7 +527,6 @@ public class TFM_Util TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 1 minute."); - TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage)); TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(player), player.getName(), "AutoEject", expires, kickMessage)); player.kickPlayer(kickMessage); @@ -542,7 +541,6 @@ public class TFM_Util TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 3 minutes."); - TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage)); TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(player), player.getName(), "AutoEject", expires, kickMessage)); player.kickPlayer(kickMessage); @@ -963,7 +961,6 @@ public class TFM_Util field.setAccessible(true); return (T) field.get(from); - } catch (NoSuchFieldException ex) { @@ -1013,7 +1010,6 @@ public class TFM_Util String packageName = Bukkit.getServer().getClass().getPackage().getName(); return packageName.substring(packageName.lastIndexOf('.') + 1); - } public static class TFM_EntityWiper diff --git a/src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java index 2baeb6d..eec31a1 100644 --- a/src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java +++ b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomBlockPopulator.java @@ -22,6 +22,7 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; +@SuppressWarnings("deprecation") public class CleanroomBlockPopulator extends BlockPopulator { byte[] layerDataValues; diff --git a/src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java index f2a801e..1eaabac 100644 --- a/src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java +++ b/src/me/StevenLawson/TotalFreedomMod/World/CleanroomChunkGenerator.java @@ -30,6 +30,7 @@ import org.bukkit.World; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; +@SuppressWarnings("deprecation") public class CleanroomChunkGenerator extends ChunkGenerator { private static final Logger log = Bukkit.getLogger();