From f3a81a84a45c27f8866ee452e2da304a84c35e72 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 May 2014 15:11:20 +1200 Subject: [PATCH] Don't bother checking if watcher is null. If they have a entity, they can't have a null watcher --- .../disguise/disguisetypes/FlagWatcher.java | 32 +++++++++---------- .../disguisetypes/watchers/LivingWatcher.java | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index efe8a45c..5a7dc6bb 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -230,7 +230,7 @@ public class FlagWatcher { } protected void sendData(int data) { - if (getDisguise().getWatcher() == null || !DisguiseAPI.isDisguiseInUse(getDisguise())) + if (!DisguiseAPI.isDisguiseInUse(getDisguise())) return; if (!entityValues.containsKey(data) || entityValues.get(data) == null) return; @@ -307,21 +307,21 @@ public class FlagWatcher { if (itemStack != null && itemStack.getTypeId() != 0) itemToSend = ReflectionManager.getNmsItem(itemStack); items[slot] = itemStack; - if (!DisguiseAPI.isDisguiseInUse(getDisguise())) - return; - slot++; - if (slot > 4) - slot = 0; - PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT); - StructureModifier mods = packet.getModifier(); - mods.write(0, getDisguise().getEntity().getEntityId()); - mods.write(1, slot); - mods.write(2, itemToSend); - for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); - } catch (InvocationTargetException e) { - e.printStackTrace(); + if (DisguiseAPI.isDisguiseInUse(getDisguise())) { + slot++; + if (slot > 4) + slot = 0; + PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT); + StructureModifier mods = packet.getModifier(); + mods.write(0, getDisguise().getEntity().getEntityId()); + mods.write(1, slot); + mods.write(2, itemToSend); + for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { + try { + ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } } } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index 3841385a..16b354c6 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -168,7 +168,7 @@ public class LivingWatcher extends FlagWatcher { public void setMaxHealth(double newHealth) { this.maxHealth = newHealth; this.maxHealthSet = true; - if (getDisguise().getWatcher() != null && DisguiseAPI.isDisguiseInUse(getDisguise())) { + if (DisguiseAPI.isDisguiseInUse(getDisguise())) { PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); List attributes = new ArrayList(); Builder builder;