1.17.x Help with class/method name changes

Discussion in 'Spigot Plugin Development' started by Nimblebiter, Jun 16, 2021.

  1. I've been trying to update my plugins but keep running into the same issue, i've updated the spigot.jar countless times and couldn't find anything on the docs.

    Both 'ADD_PLAYER' and 'REMOVE_PLAYER' doesn't exist anymore in PacketPlayOutPlayerInfo.EnumPlayerInfoAction, now only appearing 'a', 'b', 'c', 'd' and 'e'.
    (are these just placeholders? what one does which..)

    Also, this doesn't seem to work anymore:
    Code (Java):
    PlayerConnection connection = (((CraftPlayer)player).getHandle()).playerConnection;

    #1 Nimblebiter, Jun 16, 2021
    Last edited: Jun 16, 2021
  2. This issue isn't related to Spigot, that code is NMS code which changes nearly every update. Sadly to figure it out you just have to play around with the code.
  3. Only thing I can help you with: playerConnection field is now called b
    • Agree Agree x 2
    • Like Like x 1
    • Funny Funny x 1
  4. Same problem LOL
  5. I've used this code:

    PacketPlayOutPlayerInfo addPlayerPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, craftPlayer.getHandle());
    PacketPlayOutPlayerInfo removePlayerPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.b, craftPlayer.getHandle());
    for (Player currentPlayer : Bukkit.getOnlinePlayers()) {
    CraftPlayer currentCraftPlayer = (CraftPlayer) currentPlayer;
  6. Next time, use the Spigot Build tools that are provided for that specific version.
    There you will find the decompiled non-obfuscated NMS classes required for your project.
    In that file you will find the ADD_PLAYER, REMOVE_PLAYER refference.
    At last, in case you get stuck. Take a look at my NPC Util 1.17 Here
    • Useful Useful x 1
  7. In your case, since ProtocolLib can handle packets, you can do your stuff with Wrappers and it will work. For example, I tested this in 1.16.5 and 1.17 (on paper) and both work :
    Code (Java):
    public static void playerVanishTabHook(Player p) {
        final ProtocolManager manager = ProtocolLibrary.getProtocolManager();

        // add player of remove player for the packet, if you want to hide or show things
        EnumWrappers.PlayerInfoAction action = EnumWrappers.PlayerInfoAction.REMOVE_PLAYER;
        EnumWrappers.PlayerInfoAction action = EnumWrappers.PlayerInfoAction.ADD_PLAYER;

        PacketContainer packetPlayOutPlayerInfo = getPacketPlayerInfo(p, action);
        Player player = // player who will receive the packet (or you can do a for loop)
        try {
            manager.sendServerPacket(player, packetPlayOutPlayerInfo);
        } catch (InvocationTargetException e) {
            // Manage the exception

    private static PacketContainer getPacketPlayerInfo(Player player, EnumWrappers.PlayerInfoAction action) {
        List<PlayerInfoData> datas = new ArrayList<>();
        PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
        packet.getPlayerInfoAction().write(0, action);
        packet.getPlayerInfoDataLists().write(0, datas);
        return packet;

    private static PlayerInfoData getPlayerInfoData(Player player) {
        return new PlayerInfoData(WrappedGameProfile.fromPlayer(player),
        // using Paper and Player#playerListName() method :
        return new PlayerInfoData(WrappedGameProfile.fromPlayer(player),
                WrappedChatComponent.fromJson(player.playerListName() == null
                        ? player.getName()
                        : PaperComponents.gsonSerializer().serialize(player.playerListName())));

    It's a great alternative to NMS because you don't have to manually update your plugin and waste your time.
  8. Where is PacketPlayOutPlayerInfo even located now? I can't find it even in the deobfuscated jar.
  9. %buildtoolsfolder%\build\work\decompile-e3c5450d\net\minecraft\network\protocol\game\PacketPlayOutPlayerInfo.java
    • Useful Useful x 1
  10. When I try to use
    Code (Text):
    import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo;
    though, it says it cannot be resolved.
  11. Why don't you just import the downloaded spigot.jar from the download page
  12. Because, when it works, Gradle is easier to manage. I'm using this in my Gradle file right now, but Eclipse insists the file does not exist.

    Code (Text):
    dependencies {
        compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:remapped-mojang'
  13. Look at Spigot gradle

    Code (Text):
    repositories {
      maven {
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
        content {
          includeGroup 'org.bukkit'
          includeGroup 'org.spigotmc'
      maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
      maven { url = 'https://oss.sonatype.org/content/repositories/central' }
      mavenLocal() // This is needed for CraftBukkit and Spigot.

    dependencies {
      compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT' // The full Spigot server with no shadowing. Requires mavenLocal.
  14. This is what I was using at first but I am not sure how to use the Mojang mappings as part of this.
  15. You do know that that site isn't related to the Bukkit project at all and they are illegally redistributing Mojang's code right?
    • Like Like x 1
    • Agree Agree x 1
  16. How is that related to resolving this issue? How is it my concern that spigot is illegally redistributing Mojangs code, if that's the case.
    And no it is not related to the Bukkit Project at all, it is related to the NMS source code.
  17. Please refrain from using this website, they do not update their Jars and are therefore unreliable, use BuildTools, it literally takes 5 minutes... https://www.spigotmc.org/wiki/buildtools/

    I would recommend using buildtools and navigating the Jar a little bit, I believe the code you're looking for is:
    Code (Java):
    ((CraftPlayer) player).getHandle().b.a;