diff --git a/LibsDisguises.jar b/LibsDisguises.jar new file mode 100644 index 00000000..1dc04849 Binary files /dev/null and b/LibsDisguises.jar differ diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java b/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java index d522c411..92456031 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java @@ -105,14 +105,14 @@ public class DisguiseAPI { if (!(toCast.isInstance(value))) { if (toCast == float.class) { if (value instanceof Float) { - value = ((Float) value).floatValue(); + value = ((Float) value); } else { double d = (Double) value; value = (float) d; } } else if (toCast == double.class) { if (value instanceof Double) { - value = ((Double) value).doubleValue(); + value = ((Double) value); } else { float d = (Float) value; value = (double) d; diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java index 309bc647..815ea212 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java @@ -55,6 +55,7 @@ public class DisguiseListener implements Listener { if (plugin.getConfig().getBoolean("NotifyUpdate")) { currentVersion = plugin.getDescription().getVersion(); updaterTask = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { + @Override public void run() { try { UpdateChecker updateChecker = new UpdateChecker(); @@ -63,6 +64,7 @@ public class DisguiseListener implements Listener { if (latestVersion != null) { latestVersion = "v" + latestVersion; Bukkit.getScheduler().runTask(plugin, new Runnable() { + @Override public void run() { for (Player p : Bukkit.getOnlinePlayers()) if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) @@ -300,6 +302,7 @@ public class DisguiseListener implements Listener { if (x1 - (x1 % 8) != x2 - (x2 % 8) || z1 - (z1 % 8) != z2 - (z2 % 8)) { chunkMove(event.getPlayer(), null, from); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override public void run() { if (!event.isCancelled()) { chunkMove(event.getPlayer(), event.getTo(), null); @@ -332,6 +335,7 @@ public class DisguiseListener implements Listener { final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited()); if (disguise != null) { Bukkit.getScheduler().runTask(plugin, new Runnable() { + @Override public void run() { DisguiseUtilities.setupFakeDisguise(disguise); ((Player) disguise.getEntity()).updateInventory(); @@ -360,6 +364,7 @@ public class DisguiseListener implements Listener { run.run(); } BukkitRunnable runnable = new BukkitRunnable() { + @Override public void run() { disguiseClone.remove(player); disguiseRunnable.remove(player); @@ -377,6 +382,7 @@ public class DisguiseListener implements Listener { run.run(); } BukkitRunnable runnable = new BukkitRunnable() { + @Override public void run() { disguiseEntity.remove(player); disguiseRunnable.remove(player); diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java index ae4cfe63..b603bb49 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java @@ -55,6 +55,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand { /** * Send the player the information */ + @Override protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) { sender.sendMessage(ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other disguise commands!"); diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java index 4604c214..9089d00d 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java @@ -56,6 +56,7 @@ public class DisguiseCommand extends BaseDisguiseCommand { /** * Send the player the information */ + @Override protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) { ArrayList allowedDisguises = getAllowedDisguises(map); sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"); diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseHelpCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseHelpCommand.java index 01f0a270..25b7c2a8 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseHelpCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseHelpCommand.java @@ -63,7 +63,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { } } - private ArrayList enumHelp = new ArrayList(); + private ArrayList enumHelp = new ArrayList<>(); public DisguiseHelpCommand() { try { @@ -97,7 +97,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { } catch (Exception ex) { } try { - ArrayList enumReturns = new ArrayList(); + ArrayList enumReturns = new ArrayList<>(); for (PotionEffectType potionType : PotionEffectType.values()) { if (potionType != null) enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId() @@ -159,8 +159,8 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { sender.sendMessage(ChatColor.RED + "You do not have permission for that disguise!"); return true; } - ArrayList methods = new ArrayList(); - HashMap map = new HashMap(); + ArrayList methods = new ArrayList<>(); + HashMap map = new HashMap<>(); Class watcher = type.getWatcherClass(); int ignored = 0; try { @@ -260,6 +260,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { /** * Send the player the information */ + @Override protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) { sender.sendMessage(ChatColor.RED + "/disguisehelp " diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java index 342d8006..f6de152f 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java @@ -79,6 +79,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand { /** * Send the player the information */ + @Override protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) { ArrayList allowedDisguises = getAllowedDisguises(map); sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java index d7941e83..065df282 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java @@ -22,7 +22,7 @@ import org.bukkit.entity.Player; public class DisguiseRadiusCommand extends BaseDisguiseCommand { private int maxRadius = 30; - private ArrayList validClasses = new ArrayList(); + private ArrayList validClasses = new ArrayList<>(); public DisguiseRadiusCommand(int maxRadius) { this.maxRadius = maxRadius; @@ -49,7 +49,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand { return true; } if (args[0].equalsIgnoreCase("entitytype") || args[0].equalsIgnoreCase("entitytypes")) { - ArrayList classes = new ArrayList(); + ArrayList classes = new ArrayList<>(); for (Class c : validClasses) { classes.add(c.getSimpleName()); } @@ -149,6 +149,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand { /** * Send the player the information */ + @Override protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) { ArrayList allowedDisguises = getAllowedDisguises(map); sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at 30 blocks!"); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index 404dbced..2682e5b2 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -183,6 +183,7 @@ public abstract class Disguise { private int deadTicks = 0; private int refreshDisguise = 0; + @Override public void run() { // If entity is no longer valid. Remove it. if (!getEntity().isValid()) { @@ -735,6 +736,7 @@ public abstract class Disguise { DisguiseUtilities.refreshTrackers((TargetedDisguise) this); // If he is a player, then self disguise himself Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.instance, new Runnable() { + @Override public void run() { DisguiseUtilities.setupFakeDisguise(Disguise.this); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index 70d3391b..cee5c6c3 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -42,12 +42,12 @@ public class FlagWatcher { /** * This is the entity values I need to add else it could crash them.. */ - private HashMap backupEntityValues = new HashMap(); + private HashMap backupEntityValues = new HashMap<>(); private TargetedDisguise disguise; - private HashMap entityValues = new HashMap(); + private HashMap entityValues = new HashMap<>(); private boolean hasDied; private ItemStack[] items = new ItemStack[5]; - private HashSet modifiedEntityAnimations = new HashSet(); + private HashSet modifiedEntityAnimations = new HashSet<>(); private List watchableObjects; public FlagWatcher(Disguise disguise) { @@ -81,8 +81,8 @@ public class FlagWatcher { } public List convert(List list) { - List newList = new ArrayList(); - HashSet sentValues = new HashSet(); + List newList = new ArrayList<>(); + HashSet sentValues = new HashSet<>(); boolean sendAllCustom = false; for (WrappedWatchableObject watch : list) { int dataType = watch.getIndex(); @@ -231,7 +231,7 @@ public class FlagWatcher { } public void rebuildWatchableObjects() { - watchableObjects = new ArrayList(); + watchableObjects = new ArrayList<>(); for (int i = 0; i <= 31; i++) { WrappedWatchableObject watchable = null; if (this.entityValues.containsKey(i) && this.entityValues.get(i) != null) { @@ -248,7 +248,7 @@ public class FlagWatcher { protected void sendData(int... dataValues) { if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) return; - List list = new ArrayList(); + List list = new ArrayList<>(); for (int data : dataValues) { if (!entityValues.containsKey(data) || entityValues.get(data) == null) continue; diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java index 1ab7674b..1c1228e1 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java @@ -105,10 +105,12 @@ public class MiscDisguise extends TargetedDisguise { this(DisguiseType.getType(disguiseType), id, data); } + @Override public MiscDisguise addPlayer(Player player) { return (MiscDisguise) super.addPlayer(player); } + @Override public MiscDisguise addPlayer(String playername) { return (MiscDisguise) super.addPlayer(playername); } @@ -153,18 +155,22 @@ public class MiscDisguise extends TargetedDisguise { return id; } + @Override public boolean isMiscDisguise() { return true; } + @Override public MiscDisguise removePlayer(Player player) { return (MiscDisguise) super.removePlayer(player); } + @Override public MiscDisguise removePlayer(String playername) { return (MiscDisguise) super.removePlayer(playername); } + @Override public MiscDisguise setDisguiseTarget(TargetType newTargetType) { return (MiscDisguise) super.setDisguiseTarget(newTargetType); } @@ -174,54 +180,67 @@ public class MiscDisguise extends TargetedDisguise { return (MiscDisguise) super.setEntity(entity); } + @Override public MiscDisguise setHearSelfDisguise(boolean hearSelfDisguise) { return (MiscDisguise) super.setHearSelfDisguise(hearSelfDisguise); } + @Override public MiscDisguise setHideArmorFromSelf(boolean hideArmor) { return (MiscDisguise) super.setHideArmorFromSelf(hideArmor); } + @Override public MiscDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { return (MiscDisguise) super.setHideHeldItemFromSelf(hideHeldItem); } + @Override public MiscDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { return (MiscDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); } + @Override public MiscDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { return (MiscDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); } + @Override public MiscDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { return (MiscDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); } + @Override public MiscDisguise setModifyBoundingBox(boolean modifyBox) { return (MiscDisguise) super.setModifyBoundingBox(modifyBox); } + @Override public MiscDisguise setReplaceSounds(boolean areSoundsReplaced) { return (MiscDisguise) super.setReplaceSounds(areSoundsReplaced); } + @Override public MiscDisguise setVelocitySent(boolean sendVelocity) { return (MiscDisguise) super.setVelocitySent(sendVelocity); } + @Override public MiscDisguise setViewSelfDisguise(boolean viewSelfDisguise) { return (MiscDisguise) super.setViewSelfDisguise(viewSelfDisguise); } + @Override public MiscDisguise setWatcher(FlagWatcher newWatcher) { return (MiscDisguise) super.setWatcher(newWatcher); } + @Override public MiscDisguise silentlyAddPlayer(String playername) { return (MiscDisguise) super.silentlyAddPlayer(playername); } + @Override public MiscDisguise silentlyRemovePlayer(String playername) { return (MiscDisguise) super.silentlyRemovePlayer(playername); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java index 4cbc35f1..a14161a5 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java @@ -50,10 +50,12 @@ public class MobDisguise extends TargetedDisguise { this.setReplaceSounds(replaceSounds); } + @Override public MobDisguise addPlayer(Player player) { return (MobDisguise) super.addPlayer(player); } + @Override public MobDisguise addPlayer(String playername) { return (MobDisguise) super.addPlayer(playername); } @@ -93,18 +95,22 @@ public class MobDisguise extends TargetedDisguise { return isAdult; } + @Override public boolean isMobDisguise() { return true; } + @Override public MobDisguise removePlayer(Player player) { return (MobDisguise) super.removePlayer(player); } + @Override public MobDisguise removePlayer(String playername) { return (MobDisguise) super.removePlayer(playername); } + @Override public MobDisguise setDisguiseTarget(TargetType newTargetType) { return (MobDisguise) super.setDisguiseTarget(newTargetType); } @@ -114,54 +120,67 @@ public class MobDisguise extends TargetedDisguise { return (MobDisguise) super.setEntity(entity); } + @Override public MobDisguise setHearSelfDisguise(boolean hearSelfDisguise) { return (MobDisguise) super.setHearSelfDisguise(hearSelfDisguise); } + @Override public MobDisguise setHideArmorFromSelf(boolean hideArmor) { return (MobDisguise) super.setHideArmorFromSelf(hideArmor); } + @Override public MobDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { return (MobDisguise) super.setHideHeldItemFromSelf(hideHeldItem); } + @Override public MobDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { return (MobDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); } + @Override public MobDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { return (MobDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); } + @Override public MobDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { return (MobDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); } + @Override public MobDisguise setModifyBoundingBox(boolean modifyBox) { return (MobDisguise) super.setModifyBoundingBox(modifyBox); } + @Override public MobDisguise setReplaceSounds(boolean areSoundsReplaced) { return (MobDisguise) super.setReplaceSounds(areSoundsReplaced); } + @Override public MobDisguise setVelocitySent(boolean sendVelocity) { return (MobDisguise) super.setVelocitySent(sendVelocity); } + @Override public MobDisguise setViewSelfDisguise(boolean viewSelfDisguise) { return (MobDisguise) super.setViewSelfDisguise(viewSelfDisguise); } + @Override public MobDisguise setWatcher(FlagWatcher newWatcher) { return (MobDisguise) super.setWatcher(newWatcher); } + @Override public MobDisguise silentlyAddPlayer(String playername) { return (MobDisguise) super.silentlyAddPlayer(playername); } + @Override public MobDisguise silentlyRemovePlayer(String playername) { return (MobDisguise) super.silentlyRemovePlayer(playername); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index f776555c..76005b26 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -41,10 +41,12 @@ public class PlayerDisguise extends TargetedDisguise { this.gameProfile = gameProfile; } + @Override public PlayerDisguise addPlayer(Player player) { return (PlayerDisguise) super.addPlayer(player); } + @Override public PlayerDisguise addPlayer(String playername) { return (PlayerDisguise) super.addPlayer(playername); } @@ -103,14 +105,17 @@ public class PlayerDisguise extends TargetedDisguise { return true; } + @Override public PlayerDisguise removePlayer(Player player) { return (PlayerDisguise) super.removePlayer(player); } + @Override public PlayerDisguise removePlayer(String playername) { return (PlayerDisguise) super.removePlayer(playername); } + @Override public PlayerDisguise setDisguiseTarget(TargetType newTargetType) { return (PlayerDisguise) super.setDisguiseTarget(newTargetType); } @@ -120,34 +125,42 @@ public class PlayerDisguise extends TargetedDisguise { return (PlayerDisguise) super.setEntity(entity); } + @Override public PlayerDisguise setHearSelfDisguise(boolean hearSelfDisguise) { return (PlayerDisguise) super.setHearSelfDisguise(hearSelfDisguise); } + @Override public PlayerDisguise setHideArmorFromSelf(boolean hideArmor) { return (PlayerDisguise) super.setHideArmorFromSelf(hideArmor); } + @Override public PlayerDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { return (PlayerDisguise) super.setHideHeldItemFromSelf(hideHeldItem); } + @Override public PlayerDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { return (PlayerDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); } + @Override public PlayerDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { return (PlayerDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); } + @Override public PlayerDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { return (PlayerDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); } + @Override public PlayerDisguise setModifyBoundingBox(boolean modifyBox) { return (PlayerDisguise) super.setModifyBoundingBox(modifyBox); } + @Override public PlayerDisguise setReplaceSounds(boolean areSoundsReplaced) { return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); } @@ -204,22 +217,27 @@ public class PlayerDisguise extends TargetedDisguise { return this; } + @Override public PlayerDisguise setVelocitySent(boolean sendVelocity) { return (PlayerDisguise) super.setVelocitySent(sendVelocity); } + @Override public PlayerDisguise setViewSelfDisguise(boolean viewSelfDisguise) { return (PlayerDisguise) super.setViewSelfDisguise(viewSelfDisguise); } + @Override public PlayerDisguise setWatcher(FlagWatcher newWatcher) { return (PlayerDisguise) super.setWatcher(newWatcher); } + @Override public PlayerDisguise silentlyAddPlayer(String playername) { return (PlayerDisguise) super.silentlyAddPlayer(playername); } + @Override public PlayerDisguise silentlyRemovePlayer(String playername) { return (PlayerDisguise) super.silentlyRemovePlayer(playername); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java index 235241bf..71486f5e 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java @@ -14,7 +14,7 @@ public abstract class TargetedDisguise extends Disguise { HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; } - private List disguiseViewers = new ArrayList(); + private List disguiseViewers = new ArrayList<>(); private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; public TargetedDisguise addPlayer(Player player) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index 36288cc9..b1b5fff0 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -46,7 +46,7 @@ public class LivingWatcher extends FlagWatcher { } private double maxHealth; private boolean maxHealthSet; - private HashSet potionEffects = new HashSet(); + private HashSet potionEffects = new HashSet<>(); public LivingWatcher(Disguise disguise) { super(disguise); @@ -146,7 +146,7 @@ public class LivingWatcher extends FlagWatcher { this.maxHealthSet = true; if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); - List attributes = new ArrayList(); + List attributes = new ArrayList<>(); Builder builder; builder = WrappedAttribute.newBuilder(); builder.attributeKey("generic.maxHealth"); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 8fe68611..d5b4acad 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -23,6 +23,7 @@ public class PlayerWatcher extends LivingWatcher { super(disguise); } + @Override public PlayerWatcher clone(Disguise disguise) { PlayerWatcher watcher = (PlayerWatcher) super.clone(disguise); watcher.isInBed = isInBed; @@ -126,9 +127,9 @@ public class PlayerWatcher extends LivingWatcher { private void setValue16(int i, boolean flag) { byte b0 = (Byte) getValue(16, (byte) 0); if (flag) { - setValue(16, Byte.valueOf((byte) (b0 | 1 << i))); + setValue(16, (byte) (b0 | 1 << i)); } else { - setValue(16, Byte.valueOf((byte) (b0 & (1 << i ^ 0xFFFFFFFF)))); + setValue(16, (byte) (b0 & (1 << i ^ 0xFFFFFFFF))); } } diff --git a/src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java b/src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java index 0345bfe9..fecd1427 100644 --- a/src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java +++ b/src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java @@ -31,6 +31,7 @@ public class DisguiseEvent extends Event implements Cancellable { return disguised; } + @Override public HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java b/src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java index 5722ba79..d0829389 100644 --- a/src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java +++ b/src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java @@ -31,6 +31,7 @@ public class UndisguiseEvent extends Event implements Cancellable { return disguised; } + @Override public HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java b/src/main/java/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java index d5bc6b69..7c700179 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java @@ -45,7 +45,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { } protected ArrayList getAllowedDisguises(HashMap, Boolean>> hashMap) { - ArrayList allowedDisguises = new ArrayList(); + ArrayList allowedDisguises = new ArrayList<>(); for (DisguiseType type : hashMap.keySet()) { allowedDisguises.add(type.toReadable().replace(" ", "_")); } @@ -65,7 +65,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { case SPLASH_POTION: case FISHING_HOOK: case DROPPED_ITEM: - HashMap returns = new HashMap(); + HashMap returns = new HashMap<>(); String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + "."; for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { String lowerPerm = permission.getPermission().toLowerCase(); @@ -82,7 +82,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { } return returns; default: - return new HashMap(); + return new HashMap<>(); } } @@ -108,8 +108,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { * @return */ protected HashMap, Boolean>> getPermissions(CommandSender sender, String permissionNode) { - - HashMap, Boolean>> singleDisguises = new HashMap, Boolean>>(); + HashMap, Boolean>> singleDisguises = new HashMap<>(); HashMap, Boolean>> rangeDisguises = new HashMap<>(); HashMap perms = new HashMap<>(); @@ -142,7 +141,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { if (singleDisguises.containsKey(dType)) { list = singleDisguises.get(dType); } else { - list = new HashMap, Boolean>(); + list = new HashMap<>(); singleDisguises.put(dType, list); } HashMap, Boolean> map1 = getOptions(perm); @@ -179,7 +178,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { if (rangeDisguises.containsKey(type)) { list = rangeDisguises.get(type); } else { - list = new HashMap, Boolean>(); + list = new HashMap<>(); rangeDisguises.put(type, list); } HashMap, Boolean> map1 = getOptions(perm); @@ -237,9 +236,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { } } } - HashMap, Boolean>> map = new HashMap, Boolean>>(); + HashMap, Boolean>> map = new HashMap<>(); for (DisguiseType type : DisguiseType.values()) { - HashMap, Boolean> temp = new HashMap, Boolean>(); + HashMap, Boolean> temp = new HashMap<>(); if (singleDisguises.containsKey(type)) { temp.putAll(singleDisguises.get(type)); } @@ -254,7 +253,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { } private HashMap, Boolean> getOptions(String perm) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); boolean isRemove = true; String[] split = perm.split("\\."); for (int i = 1; i < split.length; i++) { @@ -268,7 +267,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { option = "setbaby"; list.add(option); } - HashMap, Boolean> options = new HashMap, Boolean>(); + HashMap, Boolean> options = new HashMap<>(); options.put(list, isRemove); return options; } @@ -295,9 +294,15 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { * Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The * commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the * disguise has been feed a proper disguisetype. + * @param sender + * @param args + * @param map + * @return + * @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException + * @throws java.lang.IllegalAccessException + * @throws java.lang.reflect.InvocationTargetException */ - protected Disguise parseDisguise(CommandSender sender, String[] args, - HashMap, Boolean>> map) throws DisguiseParseException, + protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap, Boolean>> map) throws DisguiseParseException, IllegalAccessException, InvocationTargetException { if (map.isEmpty()) { throw new DisguiseParseException(ChatColor.RED + "You are forbidden to use this command."); @@ -310,7 +315,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { // Time to start constructing the disguise. // We will need to check between all 3 kinds of disguises int toSkip = 1; - ArrayList usedOptions = new ArrayList(); + ArrayList usedOptions = new ArrayList<>(); Disguise disguise = null; HashMap, Boolean> optionPermissions; if (args[0].startsWith("@")) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java b/src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java index 6e1f6aa5..d86c2d43 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java @@ -19,7 +19,7 @@ import java.util.jar.JarFile; public class ClassGetter { public static ArrayList> getClassesForPackage(String pkgname) { - ArrayList> classes = new ArrayList>(); + ArrayList> classes = new ArrayList<>(); // String relPath = pkgname.replace('.', '/'); // Get a File object for the package diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java index 58441500..5a7ba40e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java @@ -123,9 +123,9 @@ public enum DisguiseSound { } } - private HashSet cancelSounds = new HashSet(); + private HashSet cancelSounds = new HashSet<>(); private float damageSoundVolume = 1F; - private HashMap disguiseSounds = new HashMap(); + private HashMap disguiseSounds = new HashMap<>(); private DisguiseSound(Object... sounds) { for (int i = 0; i < sounds.length; i++) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index ee323cd7..e6c1e623 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -55,25 +55,25 @@ public class DisguiseUtilities { * This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of * the plugin to do that. */ - private static HashSet addedByPlugins = new HashSet(); + private static HashSet addedByPlugins = new HashSet<>(); private static Object bedChunk; - private static LinkedHashMap clonedDisguises = new LinkedHashMap(); + private static LinkedHashMap clonedDisguises = new LinkedHashMap<>(); /** * A hashmap of the uuid's of entitys, alive and dead. And their disguises in use **/ - private static HashMap> disguisesInUse = new HashMap>(); + private static HashMap> disguisesInUse = new HashMap<>(); /** * Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for * a max of a second. */ - private static HashMap> futureDisguises = new HashMap>(); + private static HashMap> futureDisguises = new HashMap<>(); /** * A hashmap storing the uuid and skin of a playername */ - private static HashMap gameProfiles = new HashMap(); + private static HashMap gameProfiles = new HashMap<>(); private static LibsDisguises libsDisguises; - private static HashMap> runnables = new HashMap>(); - private static HashSet selfDisguised = new HashSet(); + private static HashMap> runnables = new HashMap<>(); + private static HashSet selfDisguised = new HashSet<>(); private static Field xChunk, zChunk; static { @@ -149,6 +149,7 @@ public class DisguiseUtilities { } futureDisguises.get(entityId).add(disguise); final BukkitRunnable runnable = new BukkitRunnable() { + @Override public void run() { if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) { for (World world : Bukkit.getWorlds()) { @@ -210,7 +211,7 @@ public class DisguiseUtilities { d.removePlayer(name); } } else { - for (String playername : new ArrayList(d.getObservers())) { + for (String playername : new ArrayList<>(d.getObservers())) { if (!disguise.getObservers().contains(playername)) { d.silentlyRemovePlayer(playername); } @@ -434,7 +435,7 @@ public class DisguiseUtilities { * Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise. */ public static ArrayList getPerverts(Disguise disguise) { - ArrayList players = new ArrayList(); + ArrayList players = new ArrayList<>(); try { Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); if (entityTrackerEntry != null) { @@ -501,10 +502,12 @@ public class DisguiseUtilities { // Add null so that if this is called again. I already know I'm doing something about it gameProfiles.put(playerName, null); Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() { + @Override public void run() { try { final WrappedGameProfile gameProfile = lookupGameProfile(origName); Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { + @Override public void run() { if (!gameProfile.getProperties().isEmpty()) { if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { @@ -537,7 +540,7 @@ public class DisguiseUtilities { } if (runnable != null) { if (!runnables.containsKey(playerName)) { - runnables.put(playerName, new ArrayList()); + runnables.put(playerName, new ArrayList<>()); } runnables.get(playerName).add(runnable); } @@ -585,8 +588,8 @@ public class DisguiseUtilities { List list) { if (true) // Use for future protocol compatibility return list; - ArrayList rebuiltList = new ArrayList(); - ArrayList backups = new ArrayList(); + ArrayList rebuiltList = new ArrayList<>(); + ArrayList backups = new ArrayList<>(); for (WrappedWatchableObject obj : list) { if (obj.getValue().getClass().getName().startsWith("org.")) { backups.add(obj); @@ -624,6 +627,7 @@ public class DisguiseUtilities { selfDisguised.add(disguise.getEntity().getUniqueId()); ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); @@ -648,6 +652,7 @@ public class DisguiseUtilities { clear.invoke(entityTrackerEntry, p); ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket); Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { updatePlayer.invoke(entityTrackerEntry, p); @@ -689,6 +694,7 @@ public class DisguiseUtilities { clear.invoke(entityTrackerEntry, p); ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { updatePlayer.invoke(entityTrackerEntry, p); @@ -718,6 +724,7 @@ public class DisguiseUtilities { selfDisguised.add(disguise.getEntity().getUniqueId()); ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); @@ -742,6 +749,7 @@ public class DisguiseUtilities { clear.invoke(entityTrackerEntry, p); ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { updatePlayer.invoke(entityTrackerEntry, p); @@ -837,6 +845,7 @@ public class DisguiseUtilities { // Else its going to run in a infinite loop hue hue hue.. // At least until this disguise is discarded Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { + @Override public void run() { if (DisguiseAPI.getDisguise(player, player) == disguise) { sendSelfDisguise(player, disguise); @@ -942,6 +951,7 @@ public class DisguiseUtilities { } if (delayed != null && delayed.length > 0) { Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { for (PacketContainer packet : delayed) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java index 3f773073..ea02dbf1 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java @@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; public class DisguiseValues { - private static HashMap values = new HashMap(); + private static HashMap values = new HashMap<>(); public static DisguiseValues getDisguiseValues(DisguiseType type) { switch (type) { @@ -49,7 +49,7 @@ public class DisguiseValues { private float[] entitySize; private int enumEntitySize; private double maxHealth; - private HashMap metaValues = new HashMap(); + private HashMap metaValues = new HashMap<>(); private Class nmsEntityClass; public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/Metrics.java b/src/main/java/me/libraryaddict/disguise/utilities/Metrics.java index 50e9a063..196c2c0e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/Metrics.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/Metrics.java @@ -176,6 +176,7 @@ public class Metrics { task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { private boolean firstPost = true; + @Override public void run() { try { // This has to be synchronized or it can collide with the disable method. @@ -218,12 +219,7 @@ public class Metrics { try { // Reload the metrics file configuration.load(getConfigFile()); - } catch (IOException ex) { - if (debug) { - Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); - } - return true; - } catch (InvalidConfigurationException ex) { + } catch (IOException | InvalidConfigurationException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); } @@ -389,12 +385,13 @@ public class Metrics { OutputStream os = connection.getOutputStream(); os.write(compressed); os.flush(); - // Now read the response - final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String response = reader.readLine(); - // close resources + String response; + try ( // Now read the response + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + response = reader.readLine(); + // close resources os.close(); - reader.close(); + } if (response == null || response.startsWith("ERR") || response.startsWith("7")) { if (response == null) { response = "null"; @@ -551,7 +548,7 @@ public class Metrics { /** * The set of plotters that are contained within this graph */ - private final Set plotters = new LinkedHashSet(); + private final Set plotters = new LinkedHashSet<>(); private Graph(final String name) { this.name = name; diff --git a/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java index 2df45bc3..4dacd6dc 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -122,7 +122,7 @@ public class PacketsManager { if (disguise.getEntity() == null) disguise.setEntity(disguisedEntity); Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity); - ArrayList packets = new ArrayList(); + ArrayList packets = new ArrayList<>(); // This sends the armor packets so that the player isn't naked. // Please note it only sends the packets that wouldn't be sent normally if (DisguiseConfig.isEquipmentPacketsEnabled()) { @@ -154,7 +154,7 @@ public class PacketsManager { if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { if (disguise.getWatcher() instanceof LivingWatcher) { PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); - List attributes = new ArrayList(); + List attributes = new ArrayList<>(); Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth"); if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth()); @@ -265,11 +265,12 @@ public class PacketsManager { } } - ArrayList newPackets = new ArrayList(); + ArrayList newPackets = new ArrayList<>(); newPackets.add(null); - for (int i = 0; i < spawnPackets.length; i++) { - if (spawnPackets[i] != null) { // Get rid of empty packet '1' if it exists. - newPackets.add(spawnPackets[i]); + for (PacketContainer spawnPacket : spawnPackets) { + if (spawnPacket != null) { + // Get rid of empty packet '1' if it exists. + newPackets.add(spawnPacket); } } spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]); @@ -550,8 +551,7 @@ public class PacketsManager { DisguiseSound entitySound = null; Disguise disguise = null; Entity[] entities = soundLoc.getChunk().getEntities(); - for (int i = 0; i < entities.length; i++) { - Entity entity = entities[i]; + for (Entity entity : entities) { Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity); if (entityDisguise != null) { Location loc = entity.getLocation(); @@ -581,7 +581,7 @@ public class PacketsManager { if (entity instanceof LivingEntity) { hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks").getInt( nmsEntity) == ReflectionManager.getNmsField("EntityLiving", - "maxNoDamageTicks").getInt(nmsEntity); + "maxNoDamageTicks").getInt(nmsEntity); } else { hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable", DamageSource.class) .invoke(nmsEntity, DamageSource.GENERIC); @@ -792,6 +792,7 @@ public class PacketsManager { } if (delayedPackets != null && delayedPackets.length > 0) { Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { for (PacketContainer packet : delayedPackets) { @@ -959,6 +960,7 @@ public class PacketsManager { // Rather than predict the clients actions // Lets just update the entire inventory.. Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { + @Override public void run() { event.getPlayer().updateInventory(); } @@ -1146,7 +1148,7 @@ public class PacketsManager { if (mainListener != null) { ProtocolLibrary.getProtocolManager().removePacketListener(mainListener); } - List packetsToListen = new ArrayList(); + List packetsToListen = new ArrayList<>(); // Add spawn packets { packetsToListen.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN); @@ -1213,6 +1215,7 @@ public class PacketsManager { final PacketContainer[] delayed = packets[1]; if (delayed.length > 0) { Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + @Override public void run() { try { for (PacketContainer packet : delayed) { @@ -1278,7 +1281,7 @@ public class PacketsManager { if (disguise.isMiscDisguise()) { packets = new PacketContainer[0]; } else { - List attributes = new ArrayList(); + List attributes = new ArrayList<>(); for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) { if (attribute.getAttributeKey().equals("generic.maxHealth")) { packets[0] = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); @@ -1426,7 +1429,7 @@ public class PacketsManager { ItemStack heldItem = packets[0].getItemModifier().read(0); if (heldItem != null && heldItem.getType() != Material.AIR) { // Convert the datawatcher - List list = new ArrayList(); + List list = new ArrayList<>(); if (DisguiseConfig.isMetadataPacketsEnabled()) { list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); list = disguise.getWatcher().convert(list); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java index 176d53e8..4a39fecb 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -88,9 +88,9 @@ public class ReflectionManager { if (isForge) { // Initialize the maps by reading the srg file - ForgeClassMappings = new HashMap(); - ForgeFieldMappings = new HashMap>(); - ForgeMethodMappings = new HashMap>>(); + ForgeClassMappings = new HashMap<>(); + ForgeFieldMappings = new HashMap<>(); + ForgeMethodMappings = new HashMap<>(); try { InputStream stream = Class.forName("net.minecraftforge.common.MinecraftForge").getClassLoader() .getResourceAsStream("mappings/" + getBukkitVersion() + "/cb2numpkg.srg"); @@ -131,7 +131,7 @@ public class ReflectionManager { // by CB class name Map innerMap = ForgeFieldMappings.get(dir2fqn(fieldMatcher.group(3))); if (innerMap == null) { - innerMap = new HashMap(); + innerMap = new HashMap<>(); ForgeFieldMappings.put(dir2fqn(fieldMatcher.group(3)), innerMap); } // by CB field name to Forge field name @@ -143,13 +143,13 @@ public class ReflectionManager { // get by CB class name Map> middleMap = ForgeMethodMappings.get(dir2fqn(methodMatcher.group(5))); if (middleMap == null) { - middleMap = new HashMap>(); + middleMap = new HashMap<>(); ForgeMethodMappings.put(dir2fqn(methodMatcher.group(5)), middleMap); } // get by CB method name Map innerMap = middleMap.get(methodMatcher.group(2)); if (innerMap == null) { - innerMap = new HashMap(); + innerMap = new HashMap<>(); middleMap.put(methodMatcher.group(2), innerMap); } // store the parameter strings @@ -161,11 +161,7 @@ public class ReflectionManager { System.out.println("[LibsDisguises] Loaded " + ForgeClassMappings.size() + " Cauldron class mappings"); System.out.println("[LibsDisguises] Loaded " + ForgeFieldMappings.size() + " Cauldron field mappings"); System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings"); - } catch (ClassNotFoundException e) { - e.printStackTrace(System.out); - System.err - .println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!"); - } catch (IOException e) { + } catch (ClassNotFoundException | IOException e) { e.printStackTrace(System.out); System.err .println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!"); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9bde506d..26eaf8e6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: LibsDisguises main: me.libraryaddict.disguise.LibsDisguises -version: 8.3.3 +version: 8.4 author: libraryaddict authors: [Byteflux, Navid K.] depend: [ProtocolLib]