Clean up sources of compile warnings.

Move anything that causes deprecation warnings into TFM_DepreciationAggregator if no alternative implementation possible.
This commit is contained in:
StevenLawson 2014-07-19 21:02:00 -04:00
parent 2b597867f0
commit 183277db21
25 changed files with 166 additions and 83 deletions

View File

@ -29,7 +29,7 @@ public class Command_cbtool extends TFM_Command
if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player) 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()); playerMsg("Your target block: " + targetBlock.getLocation().toString());
return true; return true;
} }

View File

@ -31,7 +31,7 @@ public class Command_deop extends TFM_Command
// if the player is not online // if the player is not online
if (player == null) 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); TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false);

View File

@ -35,52 +35,51 @@ public class Command_dispfill extends TFM_Command
return true; return true;
} }
String[] items_raw = StringUtils.split(args[1], ","); final List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> items = new ArrayList<ItemStack>();
for (String search_item : items_raw) final String[] itemsRaw = StringUtils.split(args[1], ",");
for (final String searchItem : itemsRaw)
{ {
ItemStack is = null; Material material = Material.matchMaterial(searchItem);
if (material == null)
is = new ItemStack(Material.matchMaterial(search_item), 64);
if (is == null)
{ {
try try
{ {
is = new ItemStack(Integer.parseInt(search_item), 64); material = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getMaterial(Integer.parseInt(searchItem));
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
} }
} }
if (is != null) if (material != null)
{ {
items.add(is); items.add(new ItemStack(material, 64));
} }
else 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; int affected = 0;
Location center_location = sender_p.getLocation(); final Location centerLocation = sender_p.getLocation();
Block center_block = center_location.getBlock(); final Block centerBlock = centerLocation.getBlock();
for (int x_offset = -radius; x_offset <= radius; x_offset++) 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); final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, zOffset);
if (targetBlock.getLocation().distanceSquared(center_location) < (radius * radius)) if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius))
{ {
if (targetBlock.getType().equals(Material.DISPENSER)) if (targetBlock.getType().equals(Material.DISPENSER))
{ {
sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(targetBlock.getLocation())); sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(targetBlock.getLocation()));
setDispenserContents(targetBlock, items_array); setDispenserContents(targetBlock, itemsArray);
affected++; affected++;
} }
} }
@ -98,11 +97,13 @@ public class Command_dispfill extends TFM_Command
return true; 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(); if (targetBlock.getType() == Material.DISPENSER)
Inventory disp_inv = dispenser.getInventory(); {
disp_inv.clear(); final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory();
disp_inv.addItem(items); dispenserInv.clear();
dispenserInv.addItem(items);
}
} }
} }

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList; import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Ban; import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager; 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_PlayerList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -52,8 +50,6 @@ public class Command_glist extends TFM_Command
String username; String username;
final List<String> ips = new ArrayList<String>(); final List<String> ips = new ArrayList<String>();
final Player player = getPlayer(args[1]); final Player player = getPlayer(args[1]);
if (player == null) 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); 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) if (target != null)
{ {
TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(target), target.getName())); TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(target), target.getName()));

View File

@ -40,7 +40,7 @@ public class Command_op extends TFM_Command
{ {
if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole) if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole)
{ {
player = server.getOfflinePlayer(args[0]); player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, args[0]);
} }
else else
{ {

View File

@ -35,7 +35,7 @@ public class Command_ro extends TFM_Command
{ {
try try
{ {
fromMaterial = Material.getMaterial(Integer.parseInt(materialName)); fromMaterial = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getMaterial(Integer.parseInt(materialName));
} }
catch (NumberFormatException ex) 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); TFM_Util.adminAction(sender.getName(), "Remove complete! " + affected + " blocks removed.", false);
return true; return true;
} }
} }

View File

@ -162,7 +162,7 @@ public class Command_saconfig extends TFM_Command
return true; 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); 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]; String targetName = args[1];
final Player player = getPlayer(targetName); final Player player = getPlayer(targetName);
if (player != null) 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_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 // Twitterbot
if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean()) if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; 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 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(); final Block targetBlock = leverLocation.getBlock();
if (targetBlock.getType() == Material.LEVER) 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); lever.setPowered(leverOn);
targetBlock.setData(lever.getData()); TFM_DepreciationAggregator.setData_Block(targetBlock, TFM_DepreciationAggregator.getData_MaterialData(lever));
targetBlock.getState().update(); targetBlock.getState().update();
} }
else else

View File

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -75,7 +74,7 @@ public class Command_trail extends TFM_Command
if (!fromBlock.equals(toBlock)) if (!fromBlock.equals(toBlock))
{ {
fromBlock.setType(Material.WOOL); fromBlock.setType(Material.WOOL);
fromBlock.setData((byte) RANDOM.nextInt(16)); me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.setData_Block(fromBlock, (byte) RANDOM.nextInt(16));
} }
} }
} }

View File

@ -92,7 +92,7 @@ public class Command_whitelist extends TFM_Command
if (player == null) 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); 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) if (player == null)
{ {
player = server.getOfflinePlayer(search_name); player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, search_name);
} }
if (player.isWhitelisted()) if (player.isWhitelisted())

View File

@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH) @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "See who has a block and optionally smite", usage = "/<command> <item> [smite]", aliases = "wh") @CommandParameters(description = "See who has a block and optionally smite.", usage = "/<command> <item> [smite]", aliases = "wh")
public class Command_whohas extends TFM_Command public class Command_whohas extends TFM_Command
{ {
@Override @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) if (material == null)
{ {
try try
{ {
material = Material.getMaterial(Integer.parseInt(args[0])); material = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getMaterial(Integer.parseInt(materialName));
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
} }
if (material == null)
{
playerMsg("Invalid block: " + args[0], ChatColor.RED);
return true;
}
} }
List<String> players = new ArrayList<String>(); if (material == null)
{
playerMsg("Invalid block: " + materialName, ChatColor.RED);
return true;
}
for (Player player : server.getOnlinePlayers()) final List<String> players = new ArrayList<String>();
for (final Player player : server.getOnlinePlayers())
{ {
if (player.getInventory().contains(material)) if (player.getInventory().contains(material))
{ {

View File

@ -134,6 +134,11 @@ public abstract class TFM_Command
} }
public Player getPlayer(final String partialName) public Player getPlayer(final String partialName)
{
return getPlayer(partialName, false);
}
public Player getPlayer(final String partialName, final boolean exact)
{ {
if (partialName == null || partialName.isEmpty()) if (partialName == null || partialName.isEmpty())
{ {
@ -143,7 +148,7 @@ public abstract class TFM_Command
final Player[] players = server.getOnlinePlayers(); final Player[] players = server.getOnlinePlayers();
// Check exact matches first. // Check exact matches first.
for (Player player : players) for (final Player player : players)
{ {
if (partialName.equalsIgnoreCase(player.getName())) if (partialName.equalsIgnoreCase(player.getName()))
{ {
@ -151,8 +156,13 @@ public abstract class TFM_Command
} }
} }
if (exact)
{
return null;
}
// Then check partial matches in name. // Then check partial matches in name.
for (Player player : players) for (final Player player : players)
{ {
if (player.getName().toLowerCase().contains(partialName.toLowerCase())) if (player.getName().toLowerCase().contains(partialName.toLowerCase()))
{ {
@ -161,7 +171,7 @@ public abstract class TFM_Command
} }
// Then check partial matches in display name. // Then check partial matches in display name.
for (Player player : players) for (final Player player : players)
{ {
if (player.getDisplayName().toLowerCase().contains(partialName.toLowerCase())) if (player.getDisplayName().toLowerCase().contains(partialName.toLowerCase()))
{ {

View File

@ -2,8 +2,10 @@ package me.StevenLawson.TotalFreedomMod.Config;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -137,9 +139,17 @@ public class TFM_Config extends YamlConfiguration // BukkitLib @ https://github.
final YamlConfiguration DEFAULT_CONFIG = new YamlConfiguration(); final YamlConfiguration DEFAULT_CONFIG = new YamlConfiguration();
try 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("Could not load default configuration: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex)); plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));

View File

@ -5,6 +5,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_Log;
@ -272,7 +273,9 @@ public class TFM_MainConfig
try try
{ {
defaults = new YamlConfiguration(); defaults = new YamlConfiguration();
defaults.load(defaultConfig); final InputStreamReader isr = new InputStreamReader(defaultConfig);
defaults.load(isr);
isr.close();
} }
catch (IOException ex) catch (IOException ex)
{ {

View File

@ -17,7 +17,6 @@ import org.bukkit.Bukkit;
public class TFM_HTTPD_Manager public class TFM_HTTPD_Manager
{ {
@Deprecated
public static String MIME_DEFAULT_BINARY; public static String MIME_DEFAULT_BINARY;
// //
private static final Pattern EXT_REGEX; private static final Pattern EXT_REGEX;

View File

@ -158,7 +158,7 @@ public class TFM_EntityListener implements Listener
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (event.getEntityType() == EntityType.ARROW && entity.getShooter() instanceof Player) if (event.getEntityType() == EntityType.ARROW)
{ {
entity.getWorld().createExplosion(entity.getLocation(), 2F); entity.getWorld().createExplosion(entity.getLocation(), 2F);
} }

View File

@ -107,7 +107,7 @@ public class TFM_PlayerListener implements Listener
event.setCancelled(true); 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<RollbackEntry> entries = TFM_RollbackManager.getEntriesAtLocation(location); final List<RollbackEntry> entries = TFM_RollbackManager.getEntriesAtLocation(location);
if (entries.isEmpty()) if (entries.isEmpty())
@ -185,7 +185,7 @@ public class TFM_PlayerListener implements Listener
if (event.getAction().equals(Action.LEFT_CLICK_AIR)) if (event.getAction().equals(Action.LEFT_CLICK_AIR))
{ {
targetBlock = player.getTargetBlock(null, 120); targetBlock = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getTargetBlock(player, null, 120);
} }
else else
{ {
@ -222,7 +222,7 @@ public class TFM_PlayerListener implements Listener
Vector playerDirection = location.getDirection().normalize(); Vector playerDirection = location.getDirection().normalize();
double distance = 150.0; 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) if (targetBlock != null)
{ {
distance = location.distance(targetBlock.getLocation()); distance = location.distance(targetBlock.getLocation());
@ -275,7 +275,7 @@ public class TFM_PlayerListener implements Listener
final int STRENGTH = 4; final int STRENGTH = 4;
// Clownfish // 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)) if (TFM_AdminList.isSeniorAdmin(player, true) || TFM_AdminList.isTelnetAdmin(player, true))
{ {

View File

@ -66,6 +66,7 @@ public class TFM_BanManager
save(); save();
TFM_Log.info("Loaded " + ipBans.size() + " IP bans and " + uuidBans.size() + " UUID bans"); TFM_Log.info("Loaded " + ipBans.size() + " IP bans and " + uuidBans.size() + " UUID bans");
@SuppressWarnings("unchecked")
final TFM_UuidResolver resolver = new TFM_UuidResolver((List<String>) TFM_ConfigEntry.UNBANNABLE_USERNAMES.getList()); final TFM_UuidResolver resolver = new TFM_UuidResolver((List<String>) TFM_ConfigEntry.UNBANNABLE_USERNAMES.getList());
for (UUID uuid : resolver.call().values()) for (UUID uuid : resolver.call().values())

View File

@ -40,6 +40,7 @@ public class TFM_CommandBlocker
return; return;
} }
@SuppressWarnings("unchecked")
List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList(); List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList();
for (String rawEntry : _blockedCommands) for (String rawEntry : _blockedCommands)
{ {

View File

@ -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();
}
}

View File

@ -209,7 +209,7 @@ public class TFM_RollbackManager
public final short y; public final short y;
public final int z; public final int z;
public final byte data; public final byte data;
public final short blockId; public final Material blockMaterial;
private final boolean isBreak; private final boolean isBreak;
private RollbackEntry(String author, Block block, EntryType entryType) private RollbackEntry(String author, Block block, EntryType entryType)
@ -224,14 +224,14 @@ public class TFM_RollbackManager
if (entryType == EntryType.BLOCK_BREAK) if (entryType == EntryType.BLOCK_BREAK)
{ {
this.blockId = (short) block.getTypeId(); this.blockMaterial = block.getType();
this.data = block.getData(); this.data = TFM_DepreciationAggregator.getData_Block(block);
this.isBreak = true; this.isBreak = true;
} }
else else
{ {
this.blockId = (short) block.getTypeId(); this.blockMaterial = block.getType();
this.data = block.getData(); this.data = TFM_DepreciationAggregator.getData_Block(block);
this.isBreak = false; this.isBreak = false;
} }
} }
@ -251,7 +251,7 @@ public class TFM_RollbackManager
public Material getMaterial() public Material getMaterial()
{ {
return Material.getMaterial(blockId); return blockMaterial;
} }
public EntryType getType() public EntryType getType()
@ -265,7 +265,7 @@ public class TFM_RollbackManager
if (isBreak) if (isBreak)
{ {
block.setType(getMaterial()); block.setType(getMaterial());
block.setData(data); TFM_DepreciationAggregator.setData_Block(block, data);
} }
else else
{ {
@ -284,7 +284,7 @@ public class TFM_RollbackManager
else else
{ {
block.setType(getMaterial()); block.setType(getMaterial());
block.setData(data); TFM_DepreciationAggregator.setData_Block(block, data);
} }
} }
} }

View File

@ -98,6 +98,7 @@ public class TFM_ServiceChecker
final Iterator serviceIt = ((JSONObject) status.next()).entrySet().iterator(); final Iterator serviceIt = ((JSONObject) status.next()).entrySet().iterator();
while (serviceIt.hasNext()) while (serviceIt.hasNext())
{ {
@SuppressWarnings("unchecked")
final Entry<String, String> pair = (Entry<String, String>) serviceIt.next(); final Entry<String, String> pair = (Entry<String, String>) serviceIt.next();
if ("lastcheck".equals(pair.getKey())) if ("lastcheck".equals(pair.getKey()))

View File

@ -73,11 +73,11 @@ public class TFM_Util
{ {
try try
{ {
if (type.getName() != null) if (TFM_DepreciationAggregator.getName_EntityType(type) != null)
{ {
if (Creature.class.isAssignableFrom(type.getEntityClass())) 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_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.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)); TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(player), player.getName(), "AutoEject", expires, kickMessage));
player.kickPlayer(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_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.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)); TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUuid(player), player.getName(), "AutoEject", expires, kickMessage));
player.kickPlayer(kickMessage); player.kickPlayer(kickMessage);
@ -963,7 +961,6 @@ public class TFM_Util
field.setAccessible(true); field.setAccessible(true);
return (T) field.get(from); return (T) field.get(from);
} }
catch (NoSuchFieldException ex) catch (NoSuchFieldException ex)
{ {
@ -1013,7 +1010,6 @@ public class TFM_Util
String packageName = Bukkit.getServer().getClass().getPackage().getName(); String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1); return packageName.substring(packageName.lastIndexOf('.') + 1);
} }
public static class TFM_EntityWiper public static class TFM_EntityWiper

View File

@ -22,6 +22,7 @@ import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
@SuppressWarnings("deprecation")
public class CleanroomBlockPopulator extends BlockPopulator public class CleanroomBlockPopulator extends BlockPopulator
{ {
byte[] layerDataValues; byte[] layerDataValues;

View File

@ -30,6 +30,7 @@ import org.bukkit.World;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@SuppressWarnings("deprecation")
public class CleanroomChunkGenerator extends ChunkGenerator public class CleanroomChunkGenerator extends ChunkGenerator
{ {
private static final Logger log = Bukkit.getLogger(); private static final Logger log = Bukkit.getLogger();