Don't bother checking if watcher is null. If they have a entity, they can't have a null watcher

This commit is contained in:
libraryaddict 2014-05-23 15:11:20 +12:00
parent 567a84b8dc
commit f3a81a84a4
2 changed files with 17 additions and 17 deletions

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

@ -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<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>();
Builder builder;