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);
|
clientInteractEntityListener = new PacketListenerClientInteract(libsDisguises);
|
||||||
PacketListener tabListListener = new PacketListenerTabList(libsDisguises);
|
PacketListener tabListListener = new PacketListenerTabList(libsDisguises);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(clientInteractEntityListener)
|
ProtocolLibrary.getProtocolManager().addPacketListener(clientInteractEntityListener);
|
||||||
.syncStart();
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(tabListListener);
|
ProtocolLibrary.getProtocolManager().addPacketListener(tabListListener);
|
||||||
|
|
||||||
// Now I call this and the main listener is registered!
|
// 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);
|
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!
|
// If the entity is the same as the sender. Don't disguise!
|
||||||
// Prevents problems and there is no advantage to be gained.
|
// Prevents problems and there is no advantage to be gained.
|
||||||
// Or if they are null and there's no disguise
|
// Or if they are null and there's no disguise
|
||||||
if (entity == observer || entity == null)
|
if (disguise == null || disguise.getEntity() == observer) {
|
||||||
return;
|
|
||||||
|
|
||||||
final Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
|
||||||
|
|
||||||
if (disguise == null)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LibsPackets packets;
|
LibsPackets packets;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
packets = PacketsManager.getPacketsHandler().transformPacket(event.getPacket(), disguise, observer, entity);
|
packets = PacketsManager.getPacketsHandler()
|
||||||
|
.transformPacket(event.getPacket(), disguise, observer, disguise.getEntity());
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user