mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2025-01-05 18:58:59 +01:00
Wrap inventory packet lisetner in a try{}
This commit is contained in:
parent
d602793339
commit
410c53c18d
@ -33,6 +33,7 @@ public class PacketListenerInventory extends SimplePacketListenerAbstract {
|
||||
|
||||
@Override
|
||||
public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
|
||||
try {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@ -40,7 +41,6 @@ public class PacketListenerInventory extends SimplePacketListenerAbstract {
|
||||
if (event.getPacketType() != Client.CLICK_WINDOW && event.getPacketType() != Client.CREATIVE_INVENTORY_ACTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
PacketPlayReceiveEvent cloned = event.clone();
|
||||
new BukkitRunnable() {
|
||||
@ -84,8 +84,8 @@ public class PacketListenerInventory extends SimplePacketListenerAbstract {
|
||||
if (DisguiseUtilities.shouldBeHiddenSelfDisguise(item) && item.getType() != Material.ELYTRA) {
|
||||
int stateId = NmsVersion.v1_17.isSupported() ? ReflectionManager.getIncrementedStateId(player) : 0;
|
||||
|
||||
WrapperPlayServerSetSlot packet =
|
||||
new WrapperPlayServerSetSlot(0, stateId, slot, com.github.retrooper.packetevents.protocol.item.ItemStack.EMPTY);
|
||||
WrapperPlayServerSetSlot packet = new WrapperPlayServerSetSlot(0, stateId, slot,
|
||||
com.github.retrooper.packetevents.protocol.item.ItemStack.EMPTY);
|
||||
|
||||
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, packet);
|
||||
}
|
||||
@ -148,8 +148,8 @@ public class PacketListenerInventory extends SimplePacketListenerAbstract {
|
||||
if (disguise.isHidingArmorFromSelf()) {
|
||||
int stateId = NmsVersion.v1_17.isSupported() ? ReflectionManager.getIncrementedStateId(player) : 0;
|
||||
|
||||
WrapperPlayServerSetSlot newPacket =
|
||||
new WrapperPlayServerSetSlot(0, stateId, slot, com.github.retrooper.packetevents.protocol.item.ItemStack.EMPTY);
|
||||
WrapperPlayServerSetSlot newPacket = new WrapperPlayServerSetSlot(0, stateId, slot,
|
||||
com.github.retrooper.packetevents.protocol.item.ItemStack.EMPTY);
|
||||
|
||||
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, newPacket);
|
||||
}
|
||||
@ -171,10 +171,15 @@ public class PacketListenerInventory extends SimplePacketListenerAbstract {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketPlaySend(PacketPlaySendEvent event) {
|
||||
try {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@ -283,5 +288,9 @@ public class PacketListenerInventory extends SimplePacketListenerAbstract {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user