Check if the packets from transformPackets are null before attempting to use them

This commit is contained in:
libraryaddict 2014-03-24 01:45:02 +13:00
parent e7bee27319
commit 1dbe7ad056
2 changed files with 31 additions and 24 deletions

View File

@ -295,7 +295,8 @@ public class DisguiseUtilities {
} }
/** /**
* @param A convidence method for me to refresh trackers in other plugins * @param A
* convidence method for me to refresh trackers in other plugins
*/ */
public static void refreshTrackers(Entity entity) { public static void refreshTrackers(Entity entity) {
try { try {
@ -530,6 +531,9 @@ public class DisguiseUtilities {
private static void sendSelfPacket(Player player, PacketContainer packet, int fakeId) { private static void sendSelfPacket(Player player, PacketContainer packet, int fakeId) {
PacketContainer[] packets = PacketsManager.transformPacket(packet, player, player); PacketContainer[] packets = PacketsManager.transformPacket(packet, player, player);
try { try {
if (packets == null) {
packets = new PacketContainer[] { packet };
}
for (PacketContainer p : packets) { for (PacketContainer p : packets) {
p = p.deepClone(); p = p.deepClone();
p.getIntegers().write(0, fakeId); p.getIntegers().write(0, fakeId);

View File

@ -711,7 +711,9 @@ public class PacketsManager {
if (fakeId > 0) { if (fakeId > 0) {
// Here I grab the packets to convert them to, So I can display them as if the disguise sent them. // Here I grab the packets to convert them to, So I can display them as if the disguise sent them.
PacketContainer[] packets = transformPacket(event.getPacket(), observer, observer); PacketContainer[] packets = transformPacket(event.getPacket(), observer, observer);
final PacketContainer[] delayedPackets = new PacketContainer[packets.length > 0 ? packets.length - 1 : 0]; if (packets != null) {
final PacketContainer[] delayedPackets = new PacketContainer[packets.length > 0 ? packets.length - 1
: 0];
for (int i = 0; i < packets.length; i++) { for (int i = 0; i < packets.length; i++) {
PacketContainer packet = packets[i]; PacketContainer packet = packets[i];
if (packet.equals(event.getPacket())) { if (packet.equals(event.getPacket())) {
@ -741,6 +743,7 @@ public class PacketsManager {
} }
}); });
} }
}
if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) { if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) {
event.setPacket(event.getPacket().deepClone()); event.setPacket(event.getPacket().deepClone());
Iterator<WrappedWatchableObject> itel = event.getPacket().getWatchableCollectionModifier().read(0) Iterator<WrappedWatchableObject> itel = event.getPacket().getWatchableCollectionModifier().read(0)