Skip to content

Commit

Permalink
shorten packetlistener
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 9, 2024
1 parent 5922c64 commit 621ae98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
import com.github.retrooper.packetevents.event.PacketListenerPriority;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.PacketSide;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
import me.xginko.aef.modules.AEFModule;
Expand Down Expand Up @@ -81,17 +80,16 @@ public void run() {

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType().getSide() != PacketSide.CLIENT) return;
if (event.getUser() == null) return;
UUID player = event.getUser().getUUID();
if (player == null || !playerDataMap.containsKey(event.getUser().getUUID())) return;
if (event.isCancelled() || event.getUser() == null) return;
if (event.getUser().getUUID() == null || !playerDataMap.containsKey(event.getUser().getUUID())) return;

if (
event.getPacketType() == PacketType.Play.Client.PLAYER_FLYING
|| event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION
|| event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION
) {
playerDataMap.get(player).updateLatestPosition(new WrapperPlayClientPlayerFlying(event).getLocation());
playerDataMap.get(event.getUser().getUUID())
.updateLatestPosition(new WrapperPlayClientPlayerFlying(event).getLocation());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
import com.github.retrooper.packetevents.event.PacketListenerPriority;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.PacketSide;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
import me.xginko.aef.modules.AEFModule;
Expand Down Expand Up @@ -89,17 +88,16 @@ public void run() {

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType().getSide() != PacketSide.CLIENT) return;
if (event.getUser() == null) return;
UUID player = event.getUser().getUUID();
if (player == null || !playerDataMap.containsKey(event.getUser().getUUID())) return;
if (event.isCancelled() || event.getUser() == null) return;
if (event.getUser().getUUID() == null || !playerDataMap.containsKey(event.getUser().getUUID())) return;

if (
event.getPacketType() == PacketType.Play.Client.PLAYER_FLYING
|| event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION
|| event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION
) {
playerDataMap.get(player).updateLatestPosition(new WrapperPlayClientPlayerFlying(event).getLocation());
playerDataMap.get(event.getUser().getUUID())
.updateLatestPosition(new WrapperPlayClientPlayerFlying(event).getLocation());
}
}

Expand Down

0 comments on commit 621ae98

Please sign in to comment.