dmulloy2 / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
1.04k stars 257 forks source link

getProtocolVersion returning wrong number for 1.20 - 1.21 #3187

Closed FroostySnoowman closed 3 months ago

FroostySnoowman commented 3 months ago

Describe the bug getProtocolVersion is giving me "766" despite joining from a variety of different versions. (1.20.X - 1.21.X)

To Reproduce

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        int playerProtocolVersion = protocolManager.getProtocolVersion(event.getPlayer());
        System.out.println(playerProtocolVersion);

        if (playerProtocolVersion < MIN_PROTOCOL_VERSION) {
            event.getPlayer().sendMessage(ChatColor.RED + "Warning: You are using an outdated version of Minecraft. Please update to 1.20.6 or higher for the best experience.");
            event.getPlayer().sendMessage(ChatColor.RED + "Shops will not work properly. Click on the empty box to receive the shop item if it doesn't display!");
        }
    }

Failing to give me the correct protocol version.

Expected behavior It should give me the correct version based on: https://wiki.vg/Protocol_version_numbers

Screenshots N/A

Version Info https://pastebin.com/eSD0dhdY

Additional context N/A

FroostySnoowman commented 3 months ago

As another test, it still persists with 1.19.4. There's something very wrong here 🤔

FroostySnoowman commented 3 months ago

Turns out this might be related to a compatibility issue with ViaVersion. Using their API instead works.