Updated for 1.8.6.
Code cleanup. Fixed permissions.
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								LibsDisguises.jar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								LibsDisguises.jar
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -105,14 +105,14 @@ public class DisguiseAPI { | |||||||
|                                             if (!(toCast.isInstance(value))) { |                                             if (!(toCast.isInstance(value))) { | ||||||
|                                                 if (toCast == float.class) { |                                                 if (toCast == float.class) { | ||||||
|                                                     if (value instanceof Float) { |                                                     if (value instanceof Float) { | ||||||
|                                                         value = ((Float) value).floatValue(); |                                                         value = ((Float) value); | ||||||
|                                                     } else { |                                                     } else { | ||||||
|                                                         double d = (Double) value; |                                                         double d = (Double) value; | ||||||
|                                                         value = (float) d; |                                                         value = (float) d; | ||||||
|                                                     } |                                                     } | ||||||
|                                                 } else if (toCast == double.class) { |                                                 } else if (toCast == double.class) { | ||||||
|                                                     if (value instanceof Double) { |                                                     if (value instanceof Double) { | ||||||
|                                                         value = ((Double) value).doubleValue(); |                                                         value = ((Double) value); | ||||||
|                                                     } else { |                                                     } else { | ||||||
|                                                         float d = (Float) value; |                                                         float d = (Float) value; | ||||||
|                                                         value = (double) d; |                                                         value = (double) d; | ||||||
|   | |||||||
| @@ -55,6 +55,7 @@ public class DisguiseListener implements Listener { | |||||||
|         if (plugin.getConfig().getBoolean("NotifyUpdate")) { |         if (plugin.getConfig().getBoolean("NotifyUpdate")) { | ||||||
|             currentVersion = plugin.getDescription().getVersion(); |             currentVersion = plugin.getDescription().getVersion(); | ||||||
|             updaterTask = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { |             updaterTask = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { | ||||||
|  |                 @Override | ||||||
|                 public void run() { |                 public void run() { | ||||||
|                     try { |                     try { | ||||||
|                         UpdateChecker updateChecker = new UpdateChecker(); |                         UpdateChecker updateChecker = new UpdateChecker(); | ||||||
| @@ -63,6 +64,7 @@ public class DisguiseListener implements Listener { | |||||||
|                         if (latestVersion != null) { |                         if (latestVersion != null) { | ||||||
|                             latestVersion = "v" + latestVersion; |                             latestVersion = "v" + latestVersion; | ||||||
|                             Bukkit.getScheduler().runTask(plugin, new Runnable() { |                             Bukkit.getScheduler().runTask(plugin, new Runnable() { | ||||||
|  |                                 @Override | ||||||
|                                 public void run() { |                                 public void run() { | ||||||
|                                     for (Player p : Bukkit.getOnlinePlayers()) |                                     for (Player p : Bukkit.getOnlinePlayers()) | ||||||
|                                         if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) |                                         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)) { |             if (x1 - (x1 % 8) != x2 - (x2 % 8) || z1 - (z1 % 8) != z2 - (z2 % 8)) { | ||||||
|                 chunkMove(event.getPlayer(), null, from); |                 chunkMove(event.getPlayer(), null, from); | ||||||
|                 Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { |                 Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { | ||||||
|  |                     @Override | ||||||
|                     public void run() { |                     public void run() { | ||||||
|                         if (!event.isCancelled()) { |                         if (!event.isCancelled()) { | ||||||
|                             chunkMove(event.getPlayer(), event.getTo(), null); |                             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()); |             final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited()); | ||||||
|             if (disguise != null) { |             if (disguise != null) { | ||||||
|                 Bukkit.getScheduler().runTask(plugin, new Runnable() { |                 Bukkit.getScheduler().runTask(plugin, new Runnable() { | ||||||
|  |                     @Override | ||||||
|                     public void run() { |                     public void run() { | ||||||
|                         DisguiseUtilities.setupFakeDisguise(disguise); |                         DisguiseUtilities.setupFakeDisguise(disguise); | ||||||
|                         ((Player) disguise.getEntity()).updateInventory(); |                         ((Player) disguise.getEntity()).updateInventory(); | ||||||
| @@ -360,6 +364,7 @@ public class DisguiseListener implements Listener { | |||||||
|             run.run(); |             run.run(); | ||||||
|         } |         } | ||||||
|         BukkitRunnable runnable = new BukkitRunnable() { |         BukkitRunnable runnable = new BukkitRunnable() { | ||||||
|  |             @Override | ||||||
|             public void run() { |             public void run() { | ||||||
|                 disguiseClone.remove(player); |                 disguiseClone.remove(player); | ||||||
|                 disguiseRunnable.remove(player); |                 disguiseRunnable.remove(player); | ||||||
| @@ -377,6 +382,7 @@ public class DisguiseListener implements Listener { | |||||||
|             run.run(); |             run.run(); | ||||||
|         } |         } | ||||||
|         BukkitRunnable runnable = new BukkitRunnable() { |         BukkitRunnable runnable = new BukkitRunnable() { | ||||||
|  |             @Override | ||||||
|             public void run() { |             public void run() { | ||||||
|                 disguiseEntity.remove(player); |                 disguiseEntity.remove(player); | ||||||
|                 disguiseRunnable.remove(player); |                 disguiseRunnable.remove(player); | ||||||
|   | |||||||
| @@ -55,6 +55,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand { | |||||||
|     /** |     /** | ||||||
|      * Send the player the information |      * Send the player the information | ||||||
|      */ |      */ | ||||||
|  |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { |     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         sender.sendMessage(ChatColor.DARK_GREEN |         sender.sendMessage(ChatColor.DARK_GREEN | ||||||
|                 + "Right click a entity to get a disguise reference you can pass to other disguise commands!"); |                 + "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 |      * Send the player the information | ||||||
|      */ |      */ | ||||||
|  |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { |     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"); |         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() { |     public DisguiseHelpCommand() { | ||||||
|         try { |         try { | ||||||
| @@ -97,7 +97,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { | |||||||
|         } catch (Exception ex) { |         } catch (Exception ex) { | ||||||
|         } |         } | ||||||
|         try { |         try { | ||||||
|             ArrayList<String> enumReturns = new ArrayList<String>(); |             ArrayList<String> enumReturns = new ArrayList<>(); | ||||||
|             for (PotionEffectType potionType : PotionEffectType.values()) { |             for (PotionEffectType potionType : PotionEffectType.values()) { | ||||||
|                 if (potionType != null) |                 if (potionType != null) | ||||||
|                     enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId() |                     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!"); |                         sender.sendMessage(ChatColor.RED + "You do not have permission for that disguise!"); | ||||||
|                         return true; |                         return true; | ||||||
|                     } |                     } | ||||||
|                     ArrayList<String> methods = new ArrayList<String>(); |                     ArrayList<String> methods = new ArrayList<>(); | ||||||
|                     HashMap<String, ChatColor> map = new HashMap<String, ChatColor>(); |                     HashMap<String, ChatColor> map = new HashMap<>(); | ||||||
|                     Class watcher = type.getWatcherClass(); |                     Class watcher = type.getWatcherClass(); | ||||||
|                     int ignored = 0; |                     int ignored = 0; | ||||||
|                     try { |                     try { | ||||||
| @@ -260,6 +260,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand { | |||||||
|     /** |     /** | ||||||
|      * Send the player the information |      * Send the player the information | ||||||
|      */ |      */ | ||||||
|  |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { |     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         sender.sendMessage(ChatColor.RED |         sender.sendMessage(ChatColor.RED | ||||||
|                 + "/disguisehelp <DisguiseType> " |                 + "/disguisehelp <DisguiseType> " | ||||||
|   | |||||||
| @@ -79,6 +79,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand { | |||||||
|     /** |     /** | ||||||
|      * Send the player the information |      * Send the player the information | ||||||
|      */ |      */ | ||||||
|  |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { |     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); |         sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import org.bukkit.entity.Player; | |||||||
|  |  | ||||||
| public class DisguiseRadiusCommand extends BaseDisguiseCommand { | public class DisguiseRadiusCommand extends BaseDisguiseCommand { | ||||||
|     private int maxRadius = 30; |     private int maxRadius = 30; | ||||||
|     private ArrayList<Class> validClasses = new ArrayList<Class>(); |     private ArrayList<Class> validClasses = new ArrayList<>(); | ||||||
|  |  | ||||||
|     public DisguiseRadiusCommand(int maxRadius) { |     public DisguiseRadiusCommand(int maxRadius) { | ||||||
|         this.maxRadius = maxRadius; |         this.maxRadius = maxRadius; | ||||||
| @@ -49,7 +49,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand { | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|         if (args[0].equalsIgnoreCase("entitytype") || args[0].equalsIgnoreCase("entitytypes")) { |         if (args[0].equalsIgnoreCase("entitytype") || args[0].equalsIgnoreCase("entitytypes")) { | ||||||
|             ArrayList<String> classes = new ArrayList<String>(); |             ArrayList<String> classes = new ArrayList<>(); | ||||||
|             for (Class c : validClasses) { |             for (Class c : validClasses) { | ||||||
|                 classes.add(c.getSimpleName()); |                 classes.add(c.getSimpleName()); | ||||||
|             } |             } | ||||||
| @@ -149,6 +149,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand { | |||||||
|     /** |     /** | ||||||
|      * Send the player the information |      * Send the player the information | ||||||
|      */ |      */ | ||||||
|  |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { |     protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at 30 blocks!"); |         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 deadTicks = 0; | ||||||
|             private int refreshDisguise = 0; |             private int refreshDisguise = 0; | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|             public void run() { |             public void run() { | ||||||
|                 // If entity is no longer valid. Remove it. |                 // If entity is no longer valid. Remove it. | ||||||
|                 if (!getEntity().isValid()) { |                 if (!getEntity().isValid()) { | ||||||
| @@ -735,6 +736,7 @@ public abstract class Disguise { | |||||||
|                 DisguiseUtilities.refreshTrackers((TargetedDisguise) this); |                 DisguiseUtilities.refreshTrackers((TargetedDisguise) this); | ||||||
|                 // If he is a player, then self disguise himself |                 // If he is a player, then self disguise himself | ||||||
|                 Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.instance, new Runnable() { |                 Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.instance, new Runnable() { | ||||||
|  |                     @Override | ||||||
|                     public void run() { |                     public void run() { | ||||||
|                         DisguiseUtilities.setupFakeDisguise(Disguise.this); |                         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.. |      * 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 TargetedDisguise disguise; | ||||||
|     private HashMap<Integer, Object> entityValues = new HashMap<Integer, Object>(); |     private HashMap<Integer, Object> entityValues = new HashMap<>(); | ||||||
|     private boolean hasDied; |     private boolean hasDied; | ||||||
|     private ItemStack[] items = new ItemStack[5]; |     private ItemStack[] items = new ItemStack[5]; | ||||||
|     private HashSet<Integer> modifiedEntityAnimations = new HashSet<Integer>(); |     private HashSet<Integer> modifiedEntityAnimations = new HashSet<>(); | ||||||
|     private List<WrappedWatchableObject> watchableObjects; |     private List<WrappedWatchableObject> watchableObjects; | ||||||
|  |  | ||||||
|     public FlagWatcher(Disguise disguise) { |     public FlagWatcher(Disguise disguise) { | ||||||
| @@ -81,8 +81,8 @@ public class FlagWatcher { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public List<WrappedWatchableObject> convert(List<WrappedWatchableObject> list) { |     public List<WrappedWatchableObject> convert(List<WrappedWatchableObject> list) { | ||||||
|         List<WrappedWatchableObject> newList = new ArrayList<WrappedWatchableObject>(); |         List<WrappedWatchableObject> newList = new ArrayList<>(); | ||||||
|         HashSet<Integer> sentValues = new HashSet<Integer>(); |         HashSet<Integer> sentValues = new HashSet<>(); | ||||||
|         boolean sendAllCustom = false; |         boolean sendAllCustom = false; | ||||||
|         for (WrappedWatchableObject watch : list) { |         for (WrappedWatchableObject watch : list) { | ||||||
|             int dataType = watch.getIndex(); |             int dataType = watch.getIndex(); | ||||||
| @@ -231,7 +231,7 @@ public class FlagWatcher { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void rebuildWatchableObjects() { |     public void rebuildWatchableObjects() { | ||||||
|         watchableObjects = new ArrayList<WrappedWatchableObject>(); |         watchableObjects = new ArrayList<>(); | ||||||
|         for (int i = 0; i <= 31; i++) { |         for (int i = 0; i <= 31; i++) { | ||||||
|             WrappedWatchableObject watchable = null; |             WrappedWatchableObject watchable = null; | ||||||
|             if (this.entityValues.containsKey(i) && this.entityValues.get(i) != null) { |             if (this.entityValues.containsKey(i) && this.entityValues.get(i) != null) { | ||||||
| @@ -248,7 +248,7 @@ public class FlagWatcher { | |||||||
|     protected void sendData(int... dataValues) { |     protected void sendData(int... dataValues) { | ||||||
|         if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) |         if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) | ||||||
|             return; |             return; | ||||||
|         List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>(); |         List<WrappedWatchableObject> list = new ArrayList<>(); | ||||||
|         for (int data : dataValues) { |         for (int data : dataValues) { | ||||||
|             if (!entityValues.containsKey(data) || entityValues.get(data) == null) |             if (!entityValues.containsKey(data) || entityValues.get(data) == null) | ||||||
|                 continue; |                 continue; | ||||||
|   | |||||||
| @@ -105,10 +105,12 @@ public class MiscDisguise extends TargetedDisguise { | |||||||
|         this(DisguiseType.getType(disguiseType), id, data); |         this(DisguiseType.getType(disguiseType), id, data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise addPlayer(Player player) { |     public MiscDisguise addPlayer(Player player) { | ||||||
|         return (MiscDisguise) super.addPlayer(player); |         return (MiscDisguise) super.addPlayer(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise addPlayer(String playername) { |     public MiscDisguise addPlayer(String playername) { | ||||||
|         return (MiscDisguise) super.addPlayer(playername); |         return (MiscDisguise) super.addPlayer(playername); | ||||||
|     } |     } | ||||||
| @@ -153,18 +155,22 @@ public class MiscDisguise extends TargetedDisguise { | |||||||
|         return id; |         return id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public boolean isMiscDisguise() { |     public boolean isMiscDisguise() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise removePlayer(Player player) { |     public MiscDisguise removePlayer(Player player) { | ||||||
|         return (MiscDisguise) super.removePlayer(player); |         return (MiscDisguise) super.removePlayer(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise removePlayer(String playername) { |     public MiscDisguise removePlayer(String playername) { | ||||||
|         return (MiscDisguise) super.removePlayer(playername); |         return (MiscDisguise) super.removePlayer(playername); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setDisguiseTarget(TargetType newTargetType) { |     public MiscDisguise setDisguiseTarget(TargetType newTargetType) { | ||||||
|         return (MiscDisguise) super.setDisguiseTarget(newTargetType); |         return (MiscDisguise) super.setDisguiseTarget(newTargetType); | ||||||
|     } |     } | ||||||
| @@ -174,54 +180,67 @@ public class MiscDisguise extends TargetedDisguise { | |||||||
|         return (MiscDisguise) super.setEntity(entity); |         return (MiscDisguise) super.setEntity(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setHearSelfDisguise(boolean hearSelfDisguise) { |     public MiscDisguise setHearSelfDisguise(boolean hearSelfDisguise) { | ||||||
|         return (MiscDisguise) super.setHearSelfDisguise(hearSelfDisguise); |         return (MiscDisguise) super.setHearSelfDisguise(hearSelfDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setHideArmorFromSelf(boolean hideArmor) { |     public MiscDisguise setHideArmorFromSelf(boolean hideArmor) { | ||||||
|         return (MiscDisguise) super.setHideArmorFromSelf(hideArmor); |         return (MiscDisguise) super.setHideArmorFromSelf(hideArmor); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { |     public MiscDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { | ||||||
|         return (MiscDisguise) super.setHideHeldItemFromSelf(hideHeldItem); |         return (MiscDisguise) super.setHideHeldItemFromSelf(hideHeldItem); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { |     public MiscDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { | ||||||
|         return (MiscDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); |         return (MiscDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { |     public MiscDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { | ||||||
|         return (MiscDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); |         return (MiscDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { |     public MiscDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { | ||||||
|         return (MiscDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); |         return (MiscDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setModifyBoundingBox(boolean modifyBox) { |     public MiscDisguise setModifyBoundingBox(boolean modifyBox) { | ||||||
|         return (MiscDisguise) super.setModifyBoundingBox(modifyBox); |         return (MiscDisguise) super.setModifyBoundingBox(modifyBox); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setReplaceSounds(boolean areSoundsReplaced) { |     public MiscDisguise setReplaceSounds(boolean areSoundsReplaced) { | ||||||
|         return (MiscDisguise) super.setReplaceSounds(areSoundsReplaced); |         return (MiscDisguise) super.setReplaceSounds(areSoundsReplaced); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setVelocitySent(boolean sendVelocity) { |     public MiscDisguise setVelocitySent(boolean sendVelocity) { | ||||||
|         return (MiscDisguise) super.setVelocitySent(sendVelocity); |         return (MiscDisguise) super.setVelocitySent(sendVelocity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setViewSelfDisguise(boolean viewSelfDisguise) { |     public MiscDisguise setViewSelfDisguise(boolean viewSelfDisguise) { | ||||||
|         return (MiscDisguise) super.setViewSelfDisguise(viewSelfDisguise); |         return (MiscDisguise) super.setViewSelfDisguise(viewSelfDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise setWatcher(FlagWatcher newWatcher) { |     public MiscDisguise setWatcher(FlagWatcher newWatcher) { | ||||||
|         return (MiscDisguise) super.setWatcher(newWatcher); |         return (MiscDisguise) super.setWatcher(newWatcher); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise silentlyAddPlayer(String playername) { |     public MiscDisguise silentlyAddPlayer(String playername) { | ||||||
|         return (MiscDisguise) super.silentlyAddPlayer(playername); |         return (MiscDisguise) super.silentlyAddPlayer(playername); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MiscDisguise silentlyRemovePlayer(String playername) { |     public MiscDisguise silentlyRemovePlayer(String playername) { | ||||||
|         return (MiscDisguise) super.silentlyRemovePlayer(playername); |         return (MiscDisguise) super.silentlyRemovePlayer(playername); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -50,10 +50,12 @@ public class MobDisguise extends TargetedDisguise { | |||||||
|         this.setReplaceSounds(replaceSounds); |         this.setReplaceSounds(replaceSounds); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise addPlayer(Player player) { |     public MobDisguise addPlayer(Player player) { | ||||||
|         return (MobDisguise) super.addPlayer(player); |         return (MobDisguise) super.addPlayer(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise addPlayer(String playername) { |     public MobDisguise addPlayer(String playername) { | ||||||
|         return (MobDisguise) super.addPlayer(playername); |         return (MobDisguise) super.addPlayer(playername); | ||||||
|     } |     } | ||||||
| @@ -93,18 +95,22 @@ public class MobDisguise extends TargetedDisguise { | |||||||
|         return isAdult; |         return isAdult; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public boolean isMobDisguise() { |     public boolean isMobDisguise() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise removePlayer(Player player) { |     public MobDisguise removePlayer(Player player) { | ||||||
|         return (MobDisguise) super.removePlayer(player); |         return (MobDisguise) super.removePlayer(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise removePlayer(String playername) { |     public MobDisguise removePlayer(String playername) { | ||||||
|         return (MobDisguise) super.removePlayer(playername); |         return (MobDisguise) super.removePlayer(playername); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setDisguiseTarget(TargetType newTargetType) { |     public MobDisguise setDisguiseTarget(TargetType newTargetType) { | ||||||
|         return (MobDisguise) super.setDisguiseTarget(newTargetType); |         return (MobDisguise) super.setDisguiseTarget(newTargetType); | ||||||
|     } |     } | ||||||
| @@ -114,54 +120,67 @@ public class MobDisguise extends TargetedDisguise { | |||||||
|         return (MobDisguise) super.setEntity(entity); |         return (MobDisguise) super.setEntity(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setHearSelfDisguise(boolean hearSelfDisguise) { |     public MobDisguise setHearSelfDisguise(boolean hearSelfDisguise) { | ||||||
|         return (MobDisguise) super.setHearSelfDisguise(hearSelfDisguise); |         return (MobDisguise) super.setHearSelfDisguise(hearSelfDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setHideArmorFromSelf(boolean hideArmor) { |     public MobDisguise setHideArmorFromSelf(boolean hideArmor) { | ||||||
|         return (MobDisguise) super.setHideArmorFromSelf(hideArmor); |         return (MobDisguise) super.setHideArmorFromSelf(hideArmor); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { |     public MobDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { | ||||||
|         return (MobDisguise) super.setHideHeldItemFromSelf(hideHeldItem); |         return (MobDisguise) super.setHideHeldItemFromSelf(hideHeldItem); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { |     public MobDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { | ||||||
|         return (MobDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); |         return (MobDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { |     public MobDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { | ||||||
|         return (MobDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); |         return (MobDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { |     public MobDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { | ||||||
|         return (MobDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); |         return (MobDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setModifyBoundingBox(boolean modifyBox) { |     public MobDisguise setModifyBoundingBox(boolean modifyBox) { | ||||||
|         return (MobDisguise) super.setModifyBoundingBox(modifyBox); |         return (MobDisguise) super.setModifyBoundingBox(modifyBox); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setReplaceSounds(boolean areSoundsReplaced) { |     public MobDisguise setReplaceSounds(boolean areSoundsReplaced) { | ||||||
|         return (MobDisguise) super.setReplaceSounds(areSoundsReplaced); |         return (MobDisguise) super.setReplaceSounds(areSoundsReplaced); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setVelocitySent(boolean sendVelocity) { |     public MobDisguise setVelocitySent(boolean sendVelocity) { | ||||||
|         return (MobDisguise) super.setVelocitySent(sendVelocity); |         return (MobDisguise) super.setVelocitySent(sendVelocity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setViewSelfDisguise(boolean viewSelfDisguise) { |     public MobDisguise setViewSelfDisguise(boolean viewSelfDisguise) { | ||||||
|         return (MobDisguise) super.setViewSelfDisguise(viewSelfDisguise); |         return (MobDisguise) super.setViewSelfDisguise(viewSelfDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise setWatcher(FlagWatcher newWatcher) { |     public MobDisguise setWatcher(FlagWatcher newWatcher) { | ||||||
|         return (MobDisguise) super.setWatcher(newWatcher); |         return (MobDisguise) super.setWatcher(newWatcher); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise silentlyAddPlayer(String playername) { |     public MobDisguise silentlyAddPlayer(String playername) { | ||||||
|         return (MobDisguise) super.silentlyAddPlayer(playername); |         return (MobDisguise) super.silentlyAddPlayer(playername); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public MobDisguise silentlyRemovePlayer(String playername) { |     public MobDisguise silentlyRemovePlayer(String playername) { | ||||||
|         return (MobDisguise) super.silentlyRemovePlayer(playername); |         return (MobDisguise) super.silentlyRemovePlayer(playername); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -41,10 +41,12 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         this.gameProfile = gameProfile; |         this.gameProfile = gameProfile; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise addPlayer(Player player) { |     public PlayerDisguise addPlayer(Player player) { | ||||||
|         return (PlayerDisguise) super.addPlayer(player); |         return (PlayerDisguise) super.addPlayer(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise addPlayer(String playername) { |     public PlayerDisguise addPlayer(String playername) { | ||||||
|         return (PlayerDisguise) super.addPlayer(playername); |         return (PlayerDisguise) super.addPlayer(playername); | ||||||
|     } |     } | ||||||
| @@ -103,14 +105,17 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise removePlayer(Player player) { |     public PlayerDisguise removePlayer(Player player) { | ||||||
|         return (PlayerDisguise) super.removePlayer(player); |         return (PlayerDisguise) super.removePlayer(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise removePlayer(String playername) { |     public PlayerDisguise removePlayer(String playername) { | ||||||
|         return (PlayerDisguise) super.removePlayer(playername); |         return (PlayerDisguise) super.removePlayer(playername); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setDisguiseTarget(TargetType newTargetType) { |     public PlayerDisguise setDisguiseTarget(TargetType newTargetType) { | ||||||
|         return (PlayerDisguise) super.setDisguiseTarget(newTargetType); |         return (PlayerDisguise) super.setDisguiseTarget(newTargetType); | ||||||
|     } |     } | ||||||
| @@ -120,34 +125,42 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         return (PlayerDisguise) super.setEntity(entity); |         return (PlayerDisguise) super.setEntity(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setHearSelfDisguise(boolean hearSelfDisguise) { |     public PlayerDisguise setHearSelfDisguise(boolean hearSelfDisguise) { | ||||||
|         return (PlayerDisguise) super.setHearSelfDisguise(hearSelfDisguise); |         return (PlayerDisguise) super.setHearSelfDisguise(hearSelfDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setHideArmorFromSelf(boolean hideArmor) { |     public PlayerDisguise setHideArmorFromSelf(boolean hideArmor) { | ||||||
|         return (PlayerDisguise) super.setHideArmorFromSelf(hideArmor); |         return (PlayerDisguise) super.setHideArmorFromSelf(hideArmor); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { |     public PlayerDisguise setHideHeldItemFromSelf(boolean hideHeldItem) { | ||||||
|         return (PlayerDisguise) super.setHideHeldItemFromSelf(hideHeldItem); |         return (PlayerDisguise) super.setHideHeldItemFromSelf(hideHeldItem); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { |     public PlayerDisguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { | ||||||
|         return (PlayerDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); |         return (PlayerDisguise) super.setKeepDisguiseOnEntityDespawn(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { |     public PlayerDisguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { | ||||||
|         return (PlayerDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); |         return (PlayerDisguise) super.setKeepDisguiseOnPlayerDeath(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { |     public PlayerDisguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { | ||||||
|         return (PlayerDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); |         return (PlayerDisguise) super.setKeepDisguiseOnPlayerLogout(keepDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setModifyBoundingBox(boolean modifyBox) { |     public PlayerDisguise setModifyBoundingBox(boolean modifyBox) { | ||||||
|         return (PlayerDisguise) super.setModifyBoundingBox(modifyBox); |         return (PlayerDisguise) super.setModifyBoundingBox(modifyBox); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setReplaceSounds(boolean areSoundsReplaced) { |     public PlayerDisguise setReplaceSounds(boolean areSoundsReplaced) { | ||||||
|         return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); |         return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); | ||||||
|     } |     } | ||||||
| @@ -204,22 +217,27 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|         return this; |         return this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setVelocitySent(boolean sendVelocity) { |     public PlayerDisguise setVelocitySent(boolean sendVelocity) { | ||||||
|         return (PlayerDisguise) super.setVelocitySent(sendVelocity); |         return (PlayerDisguise) super.setVelocitySent(sendVelocity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setViewSelfDisguise(boolean viewSelfDisguise) { |     public PlayerDisguise setViewSelfDisguise(boolean viewSelfDisguise) { | ||||||
|         return (PlayerDisguise) super.setViewSelfDisguise(viewSelfDisguise); |         return (PlayerDisguise) super.setViewSelfDisguise(viewSelfDisguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise setWatcher(FlagWatcher newWatcher) { |     public PlayerDisguise setWatcher(FlagWatcher newWatcher) { | ||||||
|         return (PlayerDisguise) super.setWatcher(newWatcher); |         return (PlayerDisguise) super.setWatcher(newWatcher); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise silentlyAddPlayer(String playername) { |     public PlayerDisguise silentlyAddPlayer(String playername) { | ||||||
|         return (PlayerDisguise) super.silentlyAddPlayer(playername); |         return (PlayerDisguise) super.silentlyAddPlayer(playername); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerDisguise silentlyRemovePlayer(String playername) { |     public PlayerDisguise silentlyRemovePlayer(String playername) { | ||||||
|         return (PlayerDisguise) super.silentlyRemovePlayer(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; |         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; |     private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; | ||||||
|  |  | ||||||
|     public TargetedDisguise addPlayer(Player player) { |     public TargetedDisguise addPlayer(Player player) { | ||||||
|   | |||||||
| @@ -46,7 +46,7 @@ public class LivingWatcher extends FlagWatcher { | |||||||
|     } |     } | ||||||
|     private double maxHealth; |     private double maxHealth; | ||||||
|     private boolean maxHealthSet; |     private boolean maxHealthSet; | ||||||
|     private HashSet<Integer> potionEffects = new HashSet<Integer>(); |     private HashSet<Integer> potionEffects = new HashSet<>(); | ||||||
|  |  | ||||||
|     public LivingWatcher(Disguise disguise) { |     public LivingWatcher(Disguise disguise) { | ||||||
|         super(disguise); |         super(disguise); | ||||||
| @@ -146,7 +146,7 @@ public class LivingWatcher extends FlagWatcher { | |||||||
|         this.maxHealthSet = true; |         this.maxHealthSet = true; | ||||||
|         if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { |         if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { | ||||||
|             PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); |             PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); | ||||||
|             List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>(); |             List<WrappedAttribute> attributes = new ArrayList<>(); | ||||||
|             Builder builder; |             Builder builder; | ||||||
|             builder = WrappedAttribute.newBuilder(); |             builder = WrappedAttribute.newBuilder(); | ||||||
|             builder.attributeKey("generic.maxHealth"); |             builder.attributeKey("generic.maxHealth"); | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ public class PlayerWatcher extends LivingWatcher { | |||||||
|         super(disguise); |         super(disguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public PlayerWatcher clone(Disguise disguise) { |     public PlayerWatcher clone(Disguise disguise) { | ||||||
|         PlayerWatcher watcher = (PlayerWatcher) super.clone(disguise); |         PlayerWatcher watcher = (PlayerWatcher) super.clone(disguise); | ||||||
|         watcher.isInBed = isInBed; |         watcher.isInBed = isInBed; | ||||||
| @@ -126,9 +127,9 @@ public class PlayerWatcher extends LivingWatcher { | |||||||
|     private void setValue16(int i, boolean flag) { |     private void setValue16(int i, boolean flag) { | ||||||
|         byte b0 = (Byte) getValue(16, (byte) 0); |         byte b0 = (Byte) getValue(16, (byte) 0); | ||||||
|         if (flag) { |         if (flag) { | ||||||
|             setValue(16, Byte.valueOf((byte) (b0 | 1 << i))); |             setValue(16, (byte) (b0 | 1 << i)); | ||||||
|         } else { |         } 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; |         return disguised; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public HandlerList getHandlers() { |     public HandlerList getHandlers() { | ||||||
|         return handlers; |         return handlers; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -31,6 +31,7 @@ public class UndisguiseEvent extends Event implements Cancellable { | |||||||
|         return disguised; |         return disguised; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public HandlerList getHandlers() { |     public HandlerList getHandlers() { | ||||||
|         return handlers; |         return handlers; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) { |     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()) { |         for (DisguiseType type : hashMap.keySet()) { | ||||||
|             allowedDisguises.add(type.toReadable().replace(" ", "_")); |             allowedDisguises.add(type.toReadable().replace(" ", "_")); | ||||||
|         } |         } | ||||||
| @@ -65,7 +65,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|         case SPLASH_POTION: |         case SPLASH_POTION: | ||||||
|         case FISHING_HOOK: |         case FISHING_HOOK: | ||||||
|         case DROPPED_ITEM: |         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", "") + "."; |             String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + "."; | ||||||
|             for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { |             for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { | ||||||
|                 String lowerPerm = permission.getPermission().toLowerCase(); |                 String lowerPerm = permission.getPermission().toLowerCase(); | ||||||
| @@ -82,7 +82,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|             } |             } | ||||||
|             return returns; |             return returns; | ||||||
|         default: |         default: | ||||||
|             return new HashMap<String, Boolean>(); |             return new HashMap<>(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -108,8 +108,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|      * @return  |      * @return  | ||||||
|      */ |      */ | ||||||
|     protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) { |     protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) { | ||||||
|  |         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>(); | ||||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>>(); |  | ||||||
|         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> rangeDisguises = new HashMap<>(); |         HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> rangeDisguises = new HashMap<>(); | ||||||
|         HashMap<String, Boolean> perms = new HashMap<>(); |         HashMap<String, Boolean> perms = new HashMap<>(); | ||||||
|  |  | ||||||
| @@ -142,7 +141,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|                     if (singleDisguises.containsKey(dType)) { |                     if (singleDisguises.containsKey(dType)) { | ||||||
|                         list = singleDisguises.get(dType); |                         list = singleDisguises.get(dType); | ||||||
|                     } else { |                     } else { | ||||||
|                         list = new HashMap<ArrayList<String>, Boolean>(); |                         list = new HashMap<>(); | ||||||
|                         singleDisguises.put(dType, list); |                         singleDisguises.put(dType, list); | ||||||
|                     } |                     } | ||||||
|                     HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm); |                     HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm); | ||||||
| @@ -179,7 +178,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|                             if (rangeDisguises.containsKey(type)) { |                             if (rangeDisguises.containsKey(type)) { | ||||||
|                                 list = rangeDisguises.get(type); |                                 list = rangeDisguises.get(type); | ||||||
|                             } else { |                             } else { | ||||||
|                                 list = new HashMap<ArrayList<String>, Boolean>(); |                                 list = new HashMap<>(); | ||||||
|                                 rangeDisguises.put(type, list); |                                 rangeDisguises.put(type, list); | ||||||
|                             } |                             } | ||||||
|                             HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm); |                             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()) { |         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)) { |             if (singleDisguises.containsKey(type)) { | ||||||
|                 temp.putAll(singleDisguises.get(type)); |                 temp.putAll(singleDisguises.get(type)); | ||||||
|             } |             } | ||||||
| @@ -254,7 +253,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private HashMap<ArrayList<String>, Boolean> getOptions(String perm) { |     private HashMap<ArrayList<String>, Boolean> getOptions(String perm) { | ||||||
|         ArrayList<String> list = new ArrayList<String>(); |         ArrayList<String> list = new ArrayList<>(); | ||||||
|         boolean isRemove = true; |         boolean isRemove = true; | ||||||
|         String[] split = perm.split("\\."); |         String[] split = perm.split("\\."); | ||||||
|         for (int i = 1; i < split.length; i++) { |         for (int i = 1; i < split.length; i++) { | ||||||
| @@ -268,7 +267,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | |||||||
|                 option = "setbaby"; |                 option = "setbaby"; | ||||||
|             list.add(option); |             list.add(option); | ||||||
|         } |         } | ||||||
|         HashMap<ArrayList<String>, Boolean> options = new HashMap<ArrayList<String>, Boolean>(); |         HashMap<ArrayList<String>, Boolean> options = new HashMap<>(); | ||||||
|         options.put(list, isRemove); |         options.put(list, isRemove); | ||||||
|         return options; |         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 |      * 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 |      * commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the | ||||||
|      * disguise has been feed a proper disguisetype. |      * 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, |     protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException, | ||||||
|             HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException, |  | ||||||
|             IllegalAccessException, InvocationTargetException { |             IllegalAccessException, InvocationTargetException { | ||||||
|         if (map.isEmpty()) { |         if (map.isEmpty()) { | ||||||
|             throw new DisguiseParseException(ChatColor.RED + "You are forbidden to use this command."); |             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. |         // Time to start constructing the disguise. | ||||||
|         // We will need to check between all 3 kinds of disguises |         // We will need to check between all 3 kinds of disguises | ||||||
|         int toSkip = 1; |         int toSkip = 1; | ||||||
|         ArrayList<String> usedOptions = new ArrayList<String>(); |         ArrayList<String> usedOptions = new ArrayList<>(); | ||||||
|         Disguise disguise = null; |         Disguise disguise = null; | ||||||
|         HashMap<ArrayList<String>, Boolean> optionPermissions; |         HashMap<ArrayList<String>, Boolean> optionPermissions; | ||||||
|         if (args[0].startsWith("@")) { |         if (args[0].startsWith("@")) { | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ import java.util.jar.JarFile; | |||||||
| public class ClassGetter { | public class ClassGetter { | ||||||
|  |  | ||||||
|     public static ArrayList<Class<?>> getClassesForPackage(String pkgname) { |     public static ArrayList<Class<?>> getClassesForPackage(String pkgname) { | ||||||
|         ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); |         ArrayList<Class<?>> classes = new ArrayList<>(); | ||||||
|         // String relPath = pkgname.replace('.', '/'); |         // String relPath = pkgname.replace('.', '/'); | ||||||
|  |  | ||||||
|         // Get a File object for the package |         // 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 float damageSoundVolume = 1F; | ||||||
|     private HashMap<SoundType, String> disguiseSounds = new HashMap<SoundType, String>(); |     private HashMap<SoundType, String> disguiseSounds = new HashMap<>(); | ||||||
|  |  | ||||||
|     private DisguiseSound(Object... sounds) { |     private DisguiseSound(Object... sounds) { | ||||||
|         for (int i = 0; i < sounds.length; i++) { |         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 |      * 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. |      * 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 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 |      * 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 |      * 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. |      * 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 |      * 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 LibsDisguises libsDisguises; | ||||||
|     private static HashMap<String, ArrayList<Object>> runnables = new HashMap<String, ArrayList<Object>>(); |     private static HashMap<String, ArrayList<Object>> runnables = new HashMap<>(); | ||||||
|     private static HashSet<UUID> selfDisguised = new HashSet<UUID>(); |     private static HashSet<UUID> selfDisguised = new HashSet<>(); | ||||||
|     private static Field xChunk, zChunk; |     private static Field xChunk, zChunk; | ||||||
|  |  | ||||||
|     static { |     static { | ||||||
| @@ -149,6 +149,7 @@ public class DisguiseUtilities { | |||||||
|         } |         } | ||||||
|         futureDisguises.get(entityId).add(disguise); |         futureDisguises.get(entityId).add(disguise); | ||||||
|         final BukkitRunnable runnable = new BukkitRunnable() { |         final BukkitRunnable runnable = new BukkitRunnable() { | ||||||
|  |             @Override | ||||||
|             public void run() { |             public void run() { | ||||||
|                 if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) { |                 if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) { | ||||||
|                     for (World world : Bukkit.getWorlds()) { |                     for (World world : Bukkit.getWorlds()) { | ||||||
| @@ -210,7 +211,7 @@ public class DisguiseUtilities { | |||||||
|                                     d.removePlayer(name); |                                     d.removePlayer(name); | ||||||
|                                 } |                                 } | ||||||
|                             } else { |                             } else { | ||||||
|                                 for (String playername : new ArrayList<String>(d.getObservers())) { |                                 for (String playername : new ArrayList<>(d.getObservers())) { | ||||||
|                                     if (!disguise.getObservers().contains(playername)) { |                                     if (!disguise.getObservers().contains(playername)) { | ||||||
|                                         d.silentlyRemovePlayer(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. |      * 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) { |     public static ArrayList<Player> getPerverts(Disguise disguise) { | ||||||
|         ArrayList<Player> players = new ArrayList<Player>(); |         ArrayList<Player> players = new ArrayList<>(); | ||||||
|         try { |         try { | ||||||
|             Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); |             Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); | ||||||
|             if (entityTrackerEntry != null) { |             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 |             // Add null so that if this is called again. I already know I'm doing something about it | ||||||
|             gameProfiles.put(playerName, null); |             gameProfiles.put(playerName, null); | ||||||
|             Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() { |             Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() { | ||||||
|  |                 @Override | ||||||
|                 public void run() { |                 public void run() { | ||||||
|                     try { |                     try { | ||||||
|                         final WrappedGameProfile gameProfile = lookupGameProfile(origName); |                         final WrappedGameProfile gameProfile = lookupGameProfile(origName); | ||||||
|                         Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { |                         Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { | ||||||
|  |                             @Override | ||||||
|                             public void run() { |                             public void run() { | ||||||
|                                 if (!gameProfile.getProperties().isEmpty()) { |                                 if (!gameProfile.getProperties().isEmpty()) { | ||||||
|                                     if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { |                                     if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { | ||||||
| @@ -537,7 +540,7 @@ public class DisguiseUtilities { | |||||||
|         } |         } | ||||||
|         if (runnable != null) { |         if (runnable != null) { | ||||||
|             if (!runnables.containsKey(playerName)) { |             if (!runnables.containsKey(playerName)) { | ||||||
|                 runnables.put(playerName, new ArrayList<Object>()); |                 runnables.put(playerName, new ArrayList<>()); | ||||||
|             } |             } | ||||||
|             runnables.get(playerName).add(runnable); |             runnables.get(playerName).add(runnable); | ||||||
|         } |         } | ||||||
| @@ -585,8 +588,8 @@ public class DisguiseUtilities { | |||||||
|             List<WrappedWatchableObject> list) { |             List<WrappedWatchableObject> list) { | ||||||
|         if (true) // Use for future protocol compatibility |         if (true) // Use for future protocol compatibility | ||||||
|             return list; |             return list; | ||||||
|         ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<WrappedWatchableObject>(); |         ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>(); | ||||||
|         ArrayList<WrappedWatchableObject> backups = new ArrayList<WrappedWatchableObject>(); |         ArrayList<WrappedWatchableObject> backups = new ArrayList<>(); | ||||||
|         for (WrappedWatchableObject obj : list) { |         for (WrappedWatchableObject obj : list) { | ||||||
|             if (obj.getValue().getClass().getName().startsWith("org.")) { |             if (obj.getValue().getClass().getName().startsWith("org.")) { | ||||||
|                 backups.add(obj); |                 backups.add(obj); | ||||||
| @@ -624,6 +627,7 @@ public class DisguiseUtilities { | |||||||
|                         selfDisguised.add(disguise.getEntity().getUniqueId()); |                         selfDisguised.add(disguise.getEntity().getUniqueId()); | ||||||
|                     ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); |                     ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); | ||||||
|                     Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                     Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                         @Override | ||||||
|                         public void run() { |                         public void run() { | ||||||
|                             try { |                             try { | ||||||
|                                 DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); |                                 DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); | ||||||
| @@ -648,6 +652,7 @@ public class DisguiseUtilities { | |||||||
|                                 clear.invoke(entityTrackerEntry, p); |                                 clear.invoke(entityTrackerEntry, p); | ||||||
|                                 ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket); |                                 ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket); | ||||||
|                                 Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                                 Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                                     @Override | ||||||
|                                     public void run() { |                                     public void run() { | ||||||
|                                         try { |                                         try { | ||||||
|                                             updatePlayer.invoke(entityTrackerEntry, p); |                                             updatePlayer.invoke(entityTrackerEntry, p); | ||||||
| @@ -689,6 +694,7 @@ public class DisguiseUtilities { | |||||||
|                             clear.invoke(entityTrackerEntry, p); |                             clear.invoke(entityTrackerEntry, p); | ||||||
|                             ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); |                             ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); | ||||||
|                             Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                             Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                                 @Override | ||||||
|                                 public void run() { |                                 public void run() { | ||||||
|                                     try { |                                     try { | ||||||
|                                         updatePlayer.invoke(entityTrackerEntry, p); |                                         updatePlayer.invoke(entityTrackerEntry, p); | ||||||
| @@ -718,6 +724,7 @@ public class DisguiseUtilities { | |||||||
|                     selfDisguised.add(disguise.getEntity().getUniqueId()); |                     selfDisguised.add(disguise.getEntity().getUniqueId()); | ||||||
|                     ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); |                     ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); | ||||||
|                     Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                     Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                         @Override | ||||||
|                         public void run() { |                         public void run() { | ||||||
|                             try { |                             try { | ||||||
|                                 DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); |                                 DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); | ||||||
| @@ -742,6 +749,7 @@ public class DisguiseUtilities { | |||||||
|                             clear.invoke(entityTrackerEntry, p); |                             clear.invoke(entityTrackerEntry, p); | ||||||
|                             ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); |                             ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); | ||||||
|                             Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                             Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                                 @Override | ||||||
|                                 public void run() { |                                 public void run() { | ||||||
|                                     try { |                                     try { | ||||||
|                                         updatePlayer.invoke(entityTrackerEntry, p); |                                         updatePlayer.invoke(entityTrackerEntry, p); | ||||||
| @@ -837,6 +845,7 @@ public class DisguiseUtilities { | |||||||
|                 // Else its going to run in a infinite loop hue hue hue.. |                 // Else its going to run in a infinite loop hue hue hue.. | ||||||
|                 // At least until this disguise is discarded |                 // At least until this disguise is discarded | ||||||
|                 Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { |                 Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { | ||||||
|  |                     @Override | ||||||
|                     public void run() { |                     public void run() { | ||||||
|                         if (DisguiseAPI.getDisguise(player, player) == disguise) { |                         if (DisguiseAPI.getDisguise(player, player) == disguise) { | ||||||
|                             sendSelfDisguise(player, disguise); |                             sendSelfDisguise(player, disguise); | ||||||
| @@ -942,6 +951,7 @@ public class DisguiseUtilities { | |||||||
|             } |             } | ||||||
|             if (delayed != null && delayed.length > 0) { |             if (delayed != null && delayed.length > 0) { | ||||||
|                 Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                 Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                     @Override | ||||||
|                     public void run() { |                     public void run() { | ||||||
|                         try { |                         try { | ||||||
|                             for (PacketContainer packet : delayed) { |                             for (PacketContainer packet : delayed) { | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; | |||||||
|  |  | ||||||
| public class DisguiseValues { | 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) { |     public static DisguiseValues getDisguiseValues(DisguiseType type) { | ||||||
|         switch (type) { |         switch (type) { | ||||||
| @@ -49,7 +49,7 @@ public class DisguiseValues { | |||||||
|     private float[] entitySize; |     private float[] entitySize; | ||||||
|     private int enumEntitySize; |     private int enumEntitySize; | ||||||
|     private double maxHealth; |     private double maxHealth; | ||||||
|     private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>(); |     private HashMap<Integer, Object> metaValues = new HashMap<>(); | ||||||
|     private Class nmsEntityClass; |     private Class nmsEntityClass; | ||||||
|  |  | ||||||
|     public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth) { |     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() { | 			task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { | ||||||
| 				private boolean firstPost = true; | 				private boolean firstPost = true; | ||||||
|  |  | ||||||
|  |                                 @Override | ||||||
| 				public void run() { | 				public void run() { | ||||||
| 					try { | 					try { | ||||||
| 						// This has to be synchronized or it can collide with the disable method. | 						// This has to be synchronized or it can collide with the disable method. | ||||||
| @@ -218,12 +219,7 @@ public class Metrics { | |||||||
| 			try { | 			try { | ||||||
| 				// Reload the metrics file | 				// Reload the metrics file | ||||||
| 				configuration.load(getConfigFile()); | 				configuration.load(getConfigFile()); | ||||||
| 			} catch (IOException ex) { | 			} catch (IOException | InvalidConfigurationException ex) { | ||||||
| 				if (debug) { |  | ||||||
| 					Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); |  | ||||||
| 				} |  | ||||||
| 				return true; |  | ||||||
| 			} catch (InvalidConfigurationException ex) { |  | ||||||
| 				if (debug) { | 				if (debug) { | ||||||
| 					Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); | 					Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); | ||||||
| 				} | 				} | ||||||
| @@ -389,12 +385,13 @@ public class Metrics { | |||||||
| 		OutputStream os = connection.getOutputStream(); | 		OutputStream os = connection.getOutputStream(); | ||||||
| 		os.write(compressed); | 		os.write(compressed); | ||||||
| 		os.flush(); | 		os.flush(); | ||||||
| 		// Now read the response |                 String response; | ||||||
| 		final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); |             try ( // Now read the response | ||||||
| 		String response = reader.readLine(); |             BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { | ||||||
|  |                 response = reader.readLine(); | ||||||
|                 // close resources |                 // close resources | ||||||
| 		os.close(); | 		os.close(); | ||||||
| 		reader.close(); |             } | ||||||
| 		if (response == null || response.startsWith("ERR") || response.startsWith("7")) { | 		if (response == null || response.startsWith("ERR") || response.startsWith("7")) { | ||||||
| 			if (response == null) { | 			if (response == null) { | ||||||
| 				response = "null"; | 				response = "null"; | ||||||
| @@ -551,7 +548,7 @@ public class Metrics { | |||||||
| 		/** | 		/** | ||||||
| 		 * The set of plotters that are contained within this graph | 		 * 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) { | 		private Graph(final String name) { | ||||||
| 			this.name = name; | 			this.name = name; | ||||||
|   | |||||||
| @@ -122,7 +122,7 @@ public class PacketsManager { | |||||||
|         if (disguise.getEntity() == null) |         if (disguise.getEntity() == null) | ||||||
|             disguise.setEntity(disguisedEntity); |             disguise.setEntity(disguisedEntity); | ||||||
|         Object nmsEntity = ReflectionManager.getNmsEntity(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. |         // 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 |         // Please note it only sends the packets that wouldn't be sent normally | ||||||
|         if (DisguiseConfig.isEquipmentPacketsEnabled()) { |         if (DisguiseConfig.isEquipmentPacketsEnabled()) { | ||||||
| @@ -154,7 +154,7 @@ public class PacketsManager { | |||||||
|         if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { |         if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { | ||||||
|             if (disguise.getWatcher() instanceof LivingWatcher) { |             if (disguise.getWatcher() instanceof LivingWatcher) { | ||||||
|                 PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); |                 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"); |                 Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth"); | ||||||
|                 if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { |                 if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { | ||||||
|                     builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth()); |                     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); |             newPackets.add(null); | ||||||
|             for (int i = 0; i < spawnPackets.length; i++) { |             for (PacketContainer spawnPacket : spawnPackets) { | ||||||
|                 if (spawnPackets[i] != null) { // Get rid of empty packet '1' if it exists. |                 if (spawnPacket != null) { | ||||||
|                     newPackets.add(spawnPackets[i]); |                     // Get rid of empty packet '1' if it exists. | ||||||
|  |                     newPackets.add(spawnPacket); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]); |             spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]); | ||||||
| @@ -550,8 +551,7 @@ public class PacketsManager { | |||||||
|                     DisguiseSound entitySound = null; |                     DisguiseSound entitySound = null; | ||||||
|                     Disguise disguise = null; |                     Disguise disguise = null; | ||||||
|                     Entity[] entities = soundLoc.getChunk().getEntities(); |                     Entity[] entities = soundLoc.getChunk().getEntities(); | ||||||
|                     for (int i = 0; i < entities.length; i++) { |                     for (Entity entity : entities) { | ||||||
|                         Entity entity = entities[i]; |  | ||||||
|                         Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity); |                         Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity); | ||||||
|                         if (entityDisguise != null) { |                         if (entityDisguise != null) { | ||||||
|                             Location loc = entity.getLocation(); |                             Location loc = entity.getLocation(); | ||||||
| @@ -792,6 +792,7 @@ public class PacketsManager { | |||||||
|                         } |                         } | ||||||
|                         if (delayedPackets != null && delayedPackets.length > 0) { |                         if (delayedPackets != null && delayedPackets.length > 0) { | ||||||
|                             Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                             Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                                 @Override | ||||||
|                                 public void run() { |                                 public void run() { | ||||||
|                                     try { |                                     try { | ||||||
|                                         for (PacketContainer packet : delayedPackets) { |                                         for (PacketContainer packet : delayedPackets) { | ||||||
| @@ -959,6 +960,7 @@ public class PacketsManager { | |||||||
|                                     // Rather than predict the clients actions |                                     // Rather than predict the clients actions | ||||||
|                                     // Lets just update the entire inventory.. |                                     // Lets just update the entire inventory.. | ||||||
|                                     Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { |                                     Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { | ||||||
|  |                                         @Override | ||||||
|                                         public void run() { |                                         public void run() { | ||||||
|                                             event.getPlayer().updateInventory(); |                                             event.getPlayer().updateInventory(); | ||||||
|                                         } |                                         } | ||||||
| @@ -1146,7 +1148,7 @@ public class PacketsManager { | |||||||
|             if (mainListener != null) { |             if (mainListener != null) { | ||||||
|                 ProtocolLibrary.getProtocolManager().removePacketListener(mainListener); |                 ProtocolLibrary.getProtocolManager().removePacketListener(mainListener); | ||||||
|             } |             } | ||||||
|             List<PacketType> packetsToListen = new ArrayList<PacketType>(); |             List<PacketType> packetsToListen = new ArrayList<>(); | ||||||
|             // Add spawn packets |             // Add spawn packets | ||||||
|             { |             { | ||||||
|                 packetsToListen.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN); |                 packetsToListen.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN); | ||||||
| @@ -1213,6 +1215,7 @@ public class PacketsManager { | |||||||
|                             final PacketContainer[] delayed = packets[1]; |                             final PacketContainer[] delayed = packets[1]; | ||||||
|                             if (delayed.length > 0) { |                             if (delayed.length > 0) { | ||||||
|                                 Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { |                                 Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { | ||||||
|  |                                     @Override | ||||||
|                                     public void run() { |                                     public void run() { | ||||||
|                                         try { |                                         try { | ||||||
|                                             for (PacketContainer packet : delayed) { |                                             for (PacketContainer packet : delayed) { | ||||||
| @@ -1278,7 +1281,7 @@ public class PacketsManager { | |||||||
|                     if (disguise.isMiscDisguise()) { |                     if (disguise.isMiscDisguise()) { | ||||||
|                         packets = new PacketContainer[0]; |                         packets = new PacketContainer[0]; | ||||||
|                     } else { |                     } else { | ||||||
|                         List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>(); |                         List<WrappedAttribute> attributes = new ArrayList<>(); | ||||||
|                         for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) { |                         for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) { | ||||||
|                             if (attribute.getAttributeKey().equals("generic.maxHealth")) { |                             if (attribute.getAttributeKey().equals("generic.maxHealth")) { | ||||||
|                                 packets[0] = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); |                                 packets[0] = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); | ||||||
| @@ -1426,7 +1429,7 @@ public class PacketsManager { | |||||||
|                         ItemStack heldItem = packets[0].getItemModifier().read(0); |                         ItemStack heldItem = packets[0].getItemModifier().read(0); | ||||||
|                         if (heldItem != null && heldItem.getType() != Material.AIR) { |                         if (heldItem != null && heldItem.getType() != Material.AIR) { | ||||||
|                             // Convert the datawatcher |                             // Convert the datawatcher | ||||||
|                             List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>(); |                             List<WrappedWatchableObject> list = new ArrayList<>(); | ||||||
|                             if (DisguiseConfig.isMetadataPacketsEnabled()) { |                             if (DisguiseConfig.isMetadataPacketsEnabled()) { | ||||||
|                                 list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); |                                 list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); | ||||||
|                                 list = disguise.getWatcher().convert(list); |                                 list = disguise.getWatcher().convert(list); | ||||||
|   | |||||||
| @@ -88,9 +88,9 @@ public class ReflectionManager { | |||||||
|  |  | ||||||
|         if (isForge) { |         if (isForge) { | ||||||
|             // Initialize the maps by reading the srg file |             // Initialize the maps by reading the srg file | ||||||
|             ForgeClassMappings = new HashMap<String, String>(); |             ForgeClassMappings = new HashMap<>(); | ||||||
|             ForgeFieldMappings = new HashMap<String, Map<String, String>>(); |             ForgeFieldMappings = new HashMap<>(); | ||||||
|             ForgeMethodMappings = new HashMap<String, Map<String, Map<String, String>>>(); |             ForgeMethodMappings = new HashMap<>(); | ||||||
|             try { |             try { | ||||||
|                 InputStream stream = Class.forName("net.minecraftforge.common.MinecraftForge").getClassLoader() |                 InputStream stream = Class.forName("net.minecraftforge.common.MinecraftForge").getClassLoader() | ||||||
|                         .getResourceAsStream("mappings/" + getBukkitVersion() + "/cb2numpkg.srg"); |                         .getResourceAsStream("mappings/" + getBukkitVersion() + "/cb2numpkg.srg"); | ||||||
| @@ -131,7 +131,7 @@ public class ReflectionManager { | |||||||
|                         // by CB class name |                         // by CB class name | ||||||
|                         Map<String, String> innerMap = ForgeFieldMappings.get(dir2fqn(fieldMatcher.group(3))); |                         Map<String, String> innerMap = ForgeFieldMappings.get(dir2fqn(fieldMatcher.group(3))); | ||||||
|                         if (innerMap == null) { |                         if (innerMap == null) { | ||||||
|                             innerMap = new HashMap<String, String>(); |                             innerMap = new HashMap<>(); | ||||||
|                             ForgeFieldMappings.put(dir2fqn(fieldMatcher.group(3)), innerMap); |                             ForgeFieldMappings.put(dir2fqn(fieldMatcher.group(3)), innerMap); | ||||||
|                         } |                         } | ||||||
|                         // by CB field name to Forge field name |                         // by CB field name to Forge field name | ||||||
| @@ -143,13 +143,13 @@ public class ReflectionManager { | |||||||
|                         // get by CB class name |                         // get by CB class name | ||||||
|                         Map<String, Map<String, String>> middleMap = ForgeMethodMappings.get(dir2fqn(methodMatcher.group(5))); |                         Map<String, Map<String, String>> middleMap = ForgeMethodMappings.get(dir2fqn(methodMatcher.group(5))); | ||||||
|                         if (middleMap == null) { |                         if (middleMap == null) { | ||||||
|                             middleMap = new HashMap<String, Map<String, String>>(); |                             middleMap = new HashMap<>(); | ||||||
|                             ForgeMethodMappings.put(dir2fqn(methodMatcher.group(5)), middleMap); |                             ForgeMethodMappings.put(dir2fqn(methodMatcher.group(5)), middleMap); | ||||||
|                         } |                         } | ||||||
|                         // get by CB method name |                         // get by CB method name | ||||||
|                         Map<String, String> innerMap = middleMap.get(methodMatcher.group(2)); |                         Map<String, String> innerMap = middleMap.get(methodMatcher.group(2)); | ||||||
|                         if (innerMap == null) { |                         if (innerMap == null) { | ||||||
|                             innerMap = new HashMap<String, String>(); |                             innerMap = new HashMap<>(); | ||||||
|                             middleMap.put(methodMatcher.group(2), innerMap); |                             middleMap.put(methodMatcher.group(2), innerMap); | ||||||
|                         } |                         } | ||||||
|                         // store the parameter strings |                         // 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 " + ForgeClassMappings.size() + " Cauldron class mappings"); | ||||||
|                 System.out.println("[LibsDisguises] Loaded " + ForgeFieldMappings.size() + " Cauldron field mappings"); |                 System.out.println("[LibsDisguises] Loaded " + ForgeFieldMappings.size() + " Cauldron field mappings"); | ||||||
|                 System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings"); |                 System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings"); | ||||||
|             } catch (ClassNotFoundException 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!"); |  | ||||||
|             } catch (IOException e) { |  | ||||||
|                 e.printStackTrace(System.out); |                 e.printStackTrace(System.out); | ||||||
|                 System.err |                 System.err | ||||||
|                         .println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!"); |                         .println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!"); | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| name: LibsDisguises | name: LibsDisguises | ||||||
| main: me.libraryaddict.disguise.LibsDisguises | main: me.libraryaddict.disguise.LibsDisguises | ||||||
| version: 8.3.3 | version: 8.4 | ||||||
| author: libraryaddict | author: libraryaddict | ||||||
| authors: [Byteflux, Navid K.] | authors: [Byteflux, Navid K.] | ||||||
| depend: [ProtocolLib] | depend: [ProtocolLib] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user