mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-11-04 08:59:47 +01:00
Register client interact async, use unsafe disguise from entity id for main listener
This commit is contained in:
parent
a46178b04c
commit
5e1ed00434
@ -35,8 +35,7 @@ public class PacketsManager {
|
||||
clientInteractEntityListener = new PacketListenerClientInteract(libsDisguises);
|
||||
PacketListener tabListListener = new PacketListenerTabList(libsDisguises);
|
||||
|
||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(clientInteractEntityListener)
|
||||
.syncStart();
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(clientInteractEntityListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(tabListListener);
|
||||
|
||||
// Now I call this and the main listener is registered!
|
||||
|
@ -40,23 +40,20 @@ public class PacketListenerMain extends PacketAdapter {
|
||||
|
||||
int entityId = event.getPacket().getIntegers().read(Server.COLLECT == event.getPacketType() ? 1 : 0);
|
||||
|
||||
Entity entity = DisguiseUtilities.getEntity(observer.getWorld(), entityId);
|
||||
final Disguise disguise = DisguiseUtilities.getDisguise(observer, entityId);
|
||||
|
||||
// If the entity is the same as the sender. Don't disguise!
|
||||
// Prevents problems and there is no advantage to be gained.
|
||||
// Or if they are null and there's no disguise
|
||||
if (entity == observer || entity == null)
|
||||
return;
|
||||
|
||||
final Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null || disguise.getEntity() == observer) {
|
||||
return;
|
||||
}
|
||||
|
||||
LibsPackets packets;
|
||||
|
||||
try {
|
||||
packets = PacketsManager.getPacketsHandler().transformPacket(event.getPacket(), disguise, observer, entity);
|
||||
packets = PacketsManager.getPacketsHandler()
|
||||
.transformPacket(event.getPacket(), disguise, observer, disguise.getEntity());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user