Add check for null watchable object

This commit is contained in:
libraryaddict 2017-07-25 06:58:58 +12:00
parent 5a2f64bca4
commit 2c7a6e2b43
3 changed files with 19 additions and 16 deletions

View File

@ -1058,7 +1058,8 @@ public class PacketsManager {
WrappedWatchableObject watch = ReflectionManager WrappedWatchableObject watch = ReflectionManager
.createWatchable(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0)); .createWatchable(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0));
list.add(watch); if (watch != null)
list.add(watch);
list = disguise.getWatcher().convert(list); list = disguise.getWatcher().convert(list);
} else { } else {

View File

@ -887,7 +887,9 @@ public class ReflectionManager {
} }
public static WrappedWatchableObject createWatchable(int index, Object obj) { public static WrappedWatchableObject createWatchable(int index, Object obj) {
return new WrappedWatchableObject(createDataWatcherItem(index, obj)); Object watcherItem = createDataWatcherItem(index, obj);
return new WrappedWatchableObject(watcherItem);
} }
public static int getCombinedId(int id, int data) { public static int getCombinedId(int id, int data) {

View File

@ -118,8 +118,7 @@ public class PacketListenerViewDisguises extends PacketAdapter {
watch.setValue(a); watch.setValue(a);
} }
} }
} } else if (event.getPacketType() == Server.NAMED_ENTITY_SPAWN) {
else if (event.getPacketType() == Server.NAMED_ENTITY_SPAWN) {
event.setCancelled(true); event.setCancelled(true);
PacketContainer packet = new PacketContainer(Server.ENTITY_METADATA); PacketContainer packet = new PacketContainer(Server.ENTITY_METADATA);
@ -136,7 +135,9 @@ public class PacketListenerViewDisguises extends PacketAdapter {
WrappedWatchableObject watch = ReflectionManager.createWatchable(0, b); WrappedWatchableObject watch = ReflectionManager.createWatchable(0, b);
watchableList.add(watch); if (watch != null)
watchableList.add(watch);
packet.getWatchableCollectionModifier().write(0, watchableList); packet.getWatchableCollectionModifier().write(0, watchableList);
try { try {
@ -145,21 +146,20 @@ public class PacketListenerViewDisguises extends PacketAdapter {
catch (InvocationTargetException e) { catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
} } else if (event.getPacketType() == Server.ANIMATION) {
else if (event.getPacketType() == Server.ANIMATION) {
if (event.getPacket().getIntegers().read(1) != 2) { if (event.getPacket().getIntegers().read(1) != 2) {
event.setCancelled(true); event.setCancelled(true);
} }
} } else if (event.getPacketType() == Server.ATTACH_ENTITY || event
else if (event.getPacketType() == Server.ATTACH_ENTITY || event.getPacketType() == Server.REL_ENTITY_MOVE .getPacketType() == Server.REL_ENTITY_MOVE || event
|| event.getPacketType() == Server.REL_ENTITY_MOVE_LOOK || event.getPacketType() == Server.ENTITY_LOOK .getPacketType() == Server.REL_ENTITY_MOVE_LOOK || event
|| event.getPacketType() == Server.ENTITY_TELEPORT || event.getPacketType() == Server.ENTITY_HEAD_ROTATION .getPacketType() == Server.ENTITY_LOOK || event.getPacketType() == Server.ENTITY_TELEPORT || event
|| event.getPacketType() == Server.ENTITY_EQUIPMENT) { .getPacketType() == Server.ENTITY_HEAD_ROTATION || event
.getPacketType() == Server.ENTITY_EQUIPMENT) {
event.setCancelled(true); event.setCancelled(true);
} } else if (event.getPacketType() == Server.ENTITY_STATUS) {
else if (event.getPacketType() == Server.ENTITY_STATUS) { if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() && event.getPacket()
if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() .getBytes().read(0) == 2) {
&& event.getPacket().getBytes().read(0) == 2) {
event.setCancelled(true); event.setCancelled(true);
} }
} }