packetevents icon indicating copy to clipboard operation
packetevents copied to clipboard

Wrong client version

Open vytskalt opened this issue 1 year ago • 9 comments

Describe the bug PacketEvents incorrectly identifies the client version of a 1.20.4 client on a 1.8.8 server as V_1_8.

Software brand SportPaper 1.8

Plugins ViaVersion 5.0.3 and test plugin

How To Reproduce

@EventHandler
public void join(PlayerJoinEvent event) {
  event.getPlayer().sendMessage("Your client version: " + PacketEvents.getAPI().getPlayerManager().getClientVersion(event.getPlayer()));
}

Expected behavior It should say Your client version: V_1_20_3

Screenshots image

Additional context n/a

vytskalt avatar Oct 12 '24 10:10 vytskalt

Use the UserLoginEvent from packetevents to ensure correct client version at the right time.

retrooper avatar Oct 12 '24 10:10 retrooper

Thanks, but that isn't possible in my case. I need it to be available in PlayerJoinEvent. Is that really not possible?

vytskalt avatar Oct 12 '24 10:10 vytskalt

Packetevents doesn't track client versions on spigot servers.

AbhigyaKrishna avatar Oct 12 '24 10:10 AbhigyaKrishna

Use the ViaVersion API for determining the client version of a player:

version = serverIsUsingViaVersion
        ? ClientVersion.getById(Via.getAPI().getPlayerVersion(user.getUUID()))
        : user.getClientVersion();

jonesdevelopment avatar Oct 12 '24 11:10 jonesdevelopment

Packetevents doesn't track client versions on spigot servers.

Really? I see code for it in PlayerManagerImpl: image

vytskalt avatar Oct 12 '24 11:10 vytskalt

@EventHandler
public void join(PlayerJoinEvent event) {
  Player player = event.getPlayer();
  ClientVersion viaVersion = ClientVersion.getById(Via.getAPI().getPlayerVersion(player.getUniqueId()));
  ClientVersion packetEvents = PacketEvents.getAPI().getPlayerManager().getClientVersion(player);

  player.sendMessage("Your client version (PacketEvents): " + packetEvents);
  player.sendMessage("Your client version (ViaVersion): " + viaVersion);
}

image Looks like a bug in PacketEvents to me.

vytskalt avatar Oct 12 '24 11:10 vytskalt

Thanks, but that isn't possible in my case. I need it to be available in PlayerJoinEvent. Is that really not possible?

UserLoginEvent is powered by the PlayerJoinEvent.

retrooper avatar Oct 12 '24 12:10 retrooper

I'll look at it in a moment again.

retrooper avatar Oct 12 '24 13:10 retrooper

Thanks, but that isn't possible in my case. I need it to be available in PlayerJoinEvent. Is that really not possible?

UserLoginEvent is powered by the PlayerJoinEvent.

The reason I need it in PlayerJoinEvent is because I want to use getClientVersion inside a library but don't want to force users to switch to UserLoginEvent. It would be unintuitive and also a breaking change.

vytskalt avatar Oct 12 '24 14:10 vytskalt