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,6 +1058,7 @@ public class PacketsManager {
WrappedWatchableObject watch = ReflectionManager
.createWatchable(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0));
if (watch != null)
list.add(watch);
list = disguise.getWatcher().convert(list);

View File

@ -887,7 +887,9 @@ public class ReflectionManager {
}
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) {

View File

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