Updated for 1.8.6.
Code cleanup. Fixed permissions.
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -55,6 +55,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand { | ||||
|     /** | ||||
|      * Send the player the information | ||||
|      */ | ||||
|     @Override | ||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||
|         sender.sendMessage(ChatColor.DARK_GREEN | ||||
|                 + "Right click a entity to get a disguise reference you can pass to other disguise commands!"); | ||||
|   | ||||
| @@ -56,6 +56,7 @@ public class DisguiseCommand extends BaseDisguiseCommand { | ||||
|     /** | ||||
|      * Send the player the information | ||||
|      */ | ||||
|     @Override | ||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"); | ||||
|   | ||||
| @@ -63,7 +63,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private ArrayList<EnumHelp> enumHelp = new ArrayList<EnumHelp>(); | ||||
|     private ArrayList<EnumHelp> enumHelp = new ArrayList<>(); | ||||
|  | ||||
|     public DisguiseHelpCommand() { | ||||
|         try { | ||||
| @@ -97,7 +97,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { | ||||
|         } catch (Exception ex) { | ||||
|         } | ||||
|         try { | ||||
|             ArrayList<String> enumReturns = new ArrayList<String>(); | ||||
|             ArrayList<String> 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<String> methods = new ArrayList<String>(); | ||||
|                     HashMap<String, ChatColor> map = new HashMap<String, ChatColor>(); | ||||
|                     ArrayList<String> methods = new ArrayList<>(); | ||||
|                     HashMap<String, ChatColor> 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<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||
|         sender.sendMessage(ChatColor.RED | ||||
|                 + "/disguisehelp <DisguiseType> " | ||||
|   | ||||
| @@ -79,6 +79,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand { | ||||
|     /** | ||||
|      * Send the player the information | ||||
|      */ | ||||
|     @Override | ||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ import org.bukkit.entity.Player; | ||||
|  | ||||
| public class DisguiseRadiusCommand extends BaseDisguiseCommand { | ||||
|     private int maxRadius = 30; | ||||
|     private ArrayList<Class> validClasses = new ArrayList<Class>(); | ||||
|     private ArrayList<Class> 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<String> classes = new ArrayList<String>(); | ||||
|             ArrayList<String> 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<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at 30 blocks!"); | ||||
|   | ||||
| @@ -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); | ||||
|                     } | ||||
|   | ||||
| @@ -42,12 +42,12 @@ public class FlagWatcher { | ||||
|     /** | ||||
|      * This is the entity values I need to add else it could crash them.. | ||||
|      */ | ||||
|     private HashMap<Integer, Object> backupEntityValues = new HashMap<Integer, Object>(); | ||||
|     private HashMap<Integer, Object> backupEntityValues = new HashMap<>(); | ||||
|     private TargetedDisguise disguise; | ||||
|     private HashMap<Integer, Object> entityValues = new HashMap<Integer, Object>(); | ||||
|     private HashMap<Integer, Object> entityValues = new HashMap<>(); | ||||
|     private boolean hasDied; | ||||
|     private ItemStack[] items = new ItemStack[5]; | ||||
|     private HashSet<Integer> modifiedEntityAnimations = new HashSet<Integer>(); | ||||
|     private HashSet<Integer> modifiedEntityAnimations = new HashSet<>(); | ||||
|     private List<WrappedWatchableObject> watchableObjects; | ||||
|  | ||||
|     public FlagWatcher(Disguise disguise) { | ||||
| @@ -81,8 +81,8 @@ public class FlagWatcher { | ||||
|     } | ||||
|  | ||||
|     public List<WrappedWatchableObject> convert(List<WrappedWatchableObject> list) { | ||||
|         List<WrappedWatchableObject> newList = new ArrayList<WrappedWatchableObject>(); | ||||
|         HashSet<Integer> sentValues = new HashSet<Integer>(); | ||||
|         List<WrappedWatchableObject> newList = new ArrayList<>(); | ||||
|         HashSet<Integer> 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<WrappedWatchableObject>(); | ||||
|         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<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>(); | ||||
|         List<WrappedWatchableObject> list = new ArrayList<>(); | ||||
|         for (int data : dataValues) { | ||||
|             if (!entityValues.containsKey(data) || entityValues.get(data) == null) | ||||
|                 continue; | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|   | ||||
| @@ -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<String> disguiseViewers = new ArrayList<String>(); | ||||
|     private List<String> disguiseViewers = new ArrayList<>(); | ||||
|     private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; | ||||
|  | ||||
|     public TargetedDisguise addPlayer(Player player) { | ||||
|   | ||||
| @@ -46,7 +46,7 @@ public class LivingWatcher extends FlagWatcher { | ||||
|     } | ||||
|     private double maxHealth; | ||||
|     private boolean maxHealthSet; | ||||
|     private HashSet<Integer> potionEffects = new HashSet<Integer>(); | ||||
|     private HashSet<Integer> 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<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>(); | ||||
|             List<WrappedAttribute> attributes = new ArrayList<>(); | ||||
|             Builder builder; | ||||
|             builder = WrappedAttribute.newBuilder(); | ||||
|             builder.attributeKey("generic.maxHealth"); | ||||
|   | ||||
| @@ -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))); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -31,6 +31,7 @@ public class DisguiseEvent extends Event implements Cancellable { | ||||
|         return disguised; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public HandlerList getHandlers() { | ||||
|         return handlers; | ||||
|     } | ||||
|   | ||||
| @@ -31,6 +31,7 @@ public class UndisguiseEvent extends Event implements Cancellable { | ||||
|         return disguised; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public HandlerList getHandlers() { | ||||
|         return handlers; | ||||
|     } | ||||
|   | ||||
| @@ -45,7 +45,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | ||||
|     } | ||||
|  | ||||
|     protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) { | ||||
|         ArrayList<String> allowedDisguises = new ArrayList<String>(); | ||||
|         ArrayList<String> 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<String, Boolean> returns = new HashMap<String, Boolean>(); | ||||
|             HashMap<String, Boolean> 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<String, Boolean>(); | ||||
|             return new HashMap<>(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -108,8 +108,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | ||||
|      * @return  | ||||
|      */ | ||||
|     protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) { | ||||
|  | ||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>>(); | ||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>(); | ||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> rangeDisguises = new HashMap<>(); | ||||
|         HashMap<String, Boolean> 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<ArrayList<String>, Boolean>(); | ||||
|                         list = new HashMap<>(); | ||||
|                         singleDisguises.put(dType, list); | ||||
|                     } | ||||
|                     HashMap<ArrayList<String>, 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<ArrayList<String>, Boolean>(); | ||||
|                                 list = new HashMap<>(); | ||||
|                                 rangeDisguises.put(type, list); | ||||
|                             } | ||||
|                             HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm); | ||||
| @@ -237,9 +236,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = new HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>>(); | ||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = new HashMap<>(); | ||||
|         for (DisguiseType type : DisguiseType.values()) { | ||||
|             HashMap<ArrayList<String>, Boolean> temp = new HashMap<ArrayList<String>, Boolean>(); | ||||
|             HashMap<ArrayList<String>, 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<ArrayList<String>, Boolean> getOptions(String perm) { | ||||
|         ArrayList<String> list = new ArrayList<String>(); | ||||
|         ArrayList<String> 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<ArrayList<String>, Boolean> options = new HashMap<ArrayList<String>, Boolean>(); | ||||
|         HashMap<ArrayList<String>, 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<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException, | ||||
|     protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, 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<String> usedOptions = new ArrayList<String>(); | ||||
|         ArrayList<String> usedOptions = new ArrayList<>(); | ||||
|         Disguise disguise = null; | ||||
|         HashMap<ArrayList<String>, Boolean> optionPermissions; | ||||
|         if (args[0].startsWith("@")) { | ||||
|   | ||||
| @@ -19,7 +19,7 @@ import java.util.jar.JarFile; | ||||
| public class ClassGetter { | ||||
|  | ||||
|     public static ArrayList<Class<?>> getClassesForPackage(String pkgname) { | ||||
|         ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); | ||||
|         ArrayList<Class<?>> classes = new ArrayList<>(); | ||||
|         // String relPath = pkgname.replace('.', '/'); | ||||
|  | ||||
|         // Get a File object for the package | ||||
|   | ||||
| @@ -123,9 +123,9 @@ public enum DisguiseSound { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private HashSet<String> cancelSounds = new HashSet<String>(); | ||||
|     private HashSet<String> cancelSounds = new HashSet<>(); | ||||
|     private float damageSoundVolume = 1F; | ||||
|     private HashMap<SoundType, String> disguiseSounds = new HashMap<SoundType, String>(); | ||||
|     private HashMap<SoundType, String> disguiseSounds = new HashMap<>(); | ||||
|  | ||||
|     private DisguiseSound(Object... sounds) { | ||||
|         for (int i = 0; i < sounds.length; i++) { | ||||
|   | ||||
| @@ -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<String> addedByPlugins = new HashSet<String>(); | ||||
|     private static HashSet<String> addedByPlugins = new HashSet<>(); | ||||
|     private static Object bedChunk; | ||||
|     private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<String, Disguise>(); | ||||
|     private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>(); | ||||
|     /** | ||||
|      * A hashmap of the uuid's of entitys, alive and dead. And their disguises in use | ||||
|      **/ | ||||
|     private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<UUID, HashSet<TargetedDisguise>>(); | ||||
|     private static HashMap<UUID, HashSet<TargetedDisguise>> 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<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<Integer, HashSet<TargetedDisguise>>(); | ||||
|     private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>(); | ||||
|     /** | ||||
|      * A hashmap storing the uuid and skin of a playername | ||||
|      */ | ||||
|     private static HashMap<String, WrappedGameProfile> gameProfiles = new HashMap<String, WrappedGameProfile>(); | ||||
|     private static HashMap<String, WrappedGameProfile> gameProfiles = new HashMap<>(); | ||||
|     private static LibsDisguises libsDisguises; | ||||
|     private static HashMap<String, ArrayList<Object>> runnables = new HashMap<String, ArrayList<Object>>(); | ||||
|     private static HashSet<UUID> selfDisguised = new HashSet<UUID>(); | ||||
|     private static HashMap<String, ArrayList<Object>> runnables = new HashMap<>(); | ||||
|     private static HashSet<UUID> 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<String>(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<Player> getPerverts(Disguise disguise) { | ||||
|         ArrayList<Player> players = new ArrayList<Player>(); | ||||
|         ArrayList<Player> 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<Object>()); | ||||
|                 runnables.put(playerName, new ArrayList<>()); | ||||
|             } | ||||
|             runnables.get(playerName).add(runnable); | ||||
|         } | ||||
| @@ -585,8 +588,8 @@ public class DisguiseUtilities { | ||||
|             List<WrappedWatchableObject> list) { | ||||
|         if (true) // Use for future protocol compatibility | ||||
|             return list; | ||||
|         ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<WrappedWatchableObject>(); | ||||
|         ArrayList<WrappedWatchableObject> backups = new ArrayList<WrappedWatchableObject>(); | ||||
|         ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>(); | ||||
|         ArrayList<WrappedWatchableObject> 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) { | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
|  | ||||
| public class DisguiseValues { | ||||
|  | ||||
|     private static HashMap<DisguiseType, DisguiseValues> values = new HashMap<DisguiseType, DisguiseValues>(); | ||||
|     private static HashMap<DisguiseType, DisguiseValues> 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<Integer, Object> metaValues = new HashMap<Integer, Object>(); | ||||
|     private HashMap<Integer, Object> metaValues = new HashMap<>(); | ||||
|     private Class nmsEntityClass; | ||||
|  | ||||
|     public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth) { | ||||
|   | ||||
| @@ -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<Plotter> plotters = new LinkedHashSet<Plotter>(); | ||||
| 		private final Set<Plotter> plotters = new LinkedHashSet<>(); | ||||
|  | ||||
| 		private Graph(final String name) { | ||||
| 			this.name = name; | ||||
|   | ||||
| @@ -122,7 +122,7 @@ public class PacketsManager { | ||||
|         if (disguise.getEntity() == null) | ||||
|             disguise.setEntity(disguisedEntity); | ||||
|         Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity); | ||||
|         ArrayList<PacketContainer> packets = new ArrayList<PacketContainer>(); | ||||
|         ArrayList<PacketContainer> 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<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>(); | ||||
|                 List<WrappedAttribute> 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<PacketContainer> newPackets = new ArrayList<PacketContainer>(); | ||||
|             ArrayList<PacketContainer> 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<PacketType> packetsToListen = new ArrayList<PacketType>(); | ||||
|             List<PacketType> 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<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>(); | ||||
|                         List<WrappedAttribute> 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<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>(); | ||||
|                             List<WrappedWatchableObject> list = new ArrayList<>(); | ||||
|                             if (DisguiseConfig.isMetadataPacketsEnabled()) { | ||||
|                                 list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); | ||||
|                                 list = disguise.getWatcher().convert(list); | ||||
|   | ||||
| @@ -88,9 +88,9 @@ public class ReflectionManager { | ||||
|  | ||||
|         if (isForge) { | ||||
|             // Initialize the maps by reading the srg file | ||||
|             ForgeClassMappings = new HashMap<String, String>(); | ||||
|             ForgeFieldMappings = new HashMap<String, Map<String, String>>(); | ||||
|             ForgeMethodMappings = new HashMap<String, Map<String, Map<String, String>>>(); | ||||
|             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<String, String> innerMap = ForgeFieldMappings.get(dir2fqn(fieldMatcher.group(3))); | ||||
|                         if (innerMap == null) { | ||||
|                             innerMap = new HashMap<String, String>(); | ||||
|                             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<String, Map<String, String>> middleMap = ForgeMethodMappings.get(dir2fqn(methodMatcher.group(5))); | ||||
|                         if (middleMap == null) { | ||||
|                             middleMap = new HashMap<String, Map<String, String>>(); | ||||
|                             middleMap = new HashMap<>(); | ||||
|                             ForgeMethodMappings.put(dir2fqn(methodMatcher.group(5)), middleMap); | ||||
|                         } | ||||
|                         // get by CB method name | ||||
|                         Map<String, String> innerMap = middleMap.get(methodMatcher.group(2)); | ||||
|                         if (innerMap == null) { | ||||
|                             innerMap = new HashMap<String, String>(); | ||||
|                             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!"); | ||||
|   | ||||
| @@ -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] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user