mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-12 01:48:07 +02:00
Check if the packets from transformPackets are null before attempting to use them
This commit is contained in:
parent
e7bee27319
commit
1dbe7ad056
@ -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) {
|
||||
try {
|
||||
@ -530,6 +531,9 @@ public class DisguiseUtilities {
|
||||
private static void sendSelfPacket(Player player, PacketContainer packet, int fakeId) {
|
||||
PacketContainer[] packets = PacketsManager.transformPacket(packet, player, player);
|
||||
try {
|
||||
if (packets == null) {
|
||||
packets = new PacketContainer[] { packet };
|
||||
}
|
||||
for (PacketContainer p : packets) {
|
||||
p = p.deepClone();
|
||||
p.getIntegers().write(0, fakeId);
|
||||
|
@ -711,35 +711,38 @@ public class PacketsManager {
|
||||
if (fakeId > 0) {
|
||||
// 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);
|
||||
final PacketContainer[] delayedPackets = new PacketContainer[packets.length > 0 ? packets.length - 1 : 0];
|
||||
for (int i = 0; i < packets.length; i++) {
|
||||
PacketContainer packet = packets[i];
|
||||
if (packet.equals(event.getPacket())) {
|
||||
packet = packet.deepClone();
|
||||
}
|
||||
packet.getModifier().write(0, fakeId);
|
||||
if (i == 0) {
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
if (packets != null) {
|
||||
final PacketContainer[] delayedPackets = new PacketContainer[packets.length > 0 ? packets.length - 1
|
||||
: 0];
|
||||
for (int i = 0; i < packets.length; i++) {
|
||||
PacketContainer packet = packets[i];
|
||||
if (packet.equals(event.getPacket())) {
|
||||
packet = packet.deepClone();
|
||||
}
|
||||
} else {
|
||||
delayedPackets[i - 1] = packet;
|
||||
}
|
||||
}
|
||||
if (delayedPackets.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
packet.getModifier().write(0, fakeId);
|
||||
if (i == 0) {
|
||||
try {
|
||||
for (PacketContainer packet : delayedPackets) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
}
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
delayedPackets[i - 1] = packet;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (delayedPackets.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
for (PacketContainer packet : delayedPackets) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) {
|
||||
event.setPacket(event.getPacket().deepClone());
|
||||
|
Loading…
Reference in New Issue
Block a user