dmulloy2/PacketWrapper

Advancements Wrapping error

Breci opened this issue · 5 comments

Breci commented

Hello,
I tried to play with the Advancements wrapper to see what I can do with them.

I got errors concerning :

  • the AutoWrapper in WrapperPlayServerAdvancements.
  • getMinecraftKeys() in getTabId() in WrapperPlayClientAdvancements ,

Here are the trace :
Server Advancements : https://pastebin.com/35yFbXPA
Client Advancements : https://pastebin.com/YdzbNbQJ

My code :

public class AdvancementListener implements Listener {

    public AdvancementListener(Plugin plugin) {
        ProtocolLibrary.getProtocolManager().addPacketListener(
                new PacketAdapter(plugin, PacketType.Play.Server.ADVANCEMENTS) {
                    @Override
                    public void onPacketSending(PacketEvent event) {
                        System.out.println("===================SERVER=================");
                        PacketContainer packet = event.getPacket();
                        WrapperPlayServerAdvancements wrapper = new WrapperPlayServerAdvancements(packet);

                        System.out.println(wrapper.getAdvancements());
                        //System.out.println(message);
                        System.out.println("==========================================");

                    }
                });

        ProtocolLibrary.getProtocolManager().addPacketListener(
                new PacketAdapter(plugin, PacketType.Play.Client.ADVANCEMENTS) {
                    @Override
                    public void onPacketReceiving(PacketEvent event) {
                        System.out.println("===================CLIENT=================");
                        PacketContainer packet = event.getPacket();
                        WrapperPlayClientAdvancements wrapper = new WrapperPlayClientAdvancements(packet);

                        System.out.println(wrapper.getAction());
                        System.out.println(wrapper.getTabId().getFullKey());
                        System.out.println(wrapper.getTabId().getKey());
                        System.out.println(wrapper.getTabId().getPrefix());
                        //System.out.println(message);
                        System.out.println("==========================================");

                    }
                });
    }
}

Main class :

public class Main extends JavaPlugin {
    
    @Override
    public void onEnable() {
        System.out.println("------------------------------------");
        System.out.println("Plugin started");
        System.out.println("------------------------------------");
        Bukkit.getPluginManager().registerEvents(new AdvancementListener(this), this);
    }

    @Override
    public void onDisable() {
    }
}

PacketWrapper Build : #66
ProtocolLib Build : 4.3.0
Spigot Build : Generated from BuildTools #70

Also receiving java.lang.NoClassDefFoundError when performing

public class AdvancementsPacketListener extends PacketAdapter {
    public AdvancementsPacketListener(final JavaPlugin plugin) {
        super(plugin, PacketType.Play.Server.ADVANCEMENTS);
    }

    @Override
    public void onPacketSending(final PacketEvent event) {
        // Right here:
        final WrapperPlayServerAdvancements packet = new WrapperPlayServerAdvancements(event.getPacket());
        System.out.println(packet.getHandle().toString());
    }
}

After the research I've discovered that the problem is in com.comphenix.protocol.wrappers.AutoWrapper class being missing in latest published version of ProtocolLib on spigotmc. Fixed by using latest dev build from http://ci.dmulloy2.net/job/ProtocolLib/

@dmulloy2 this issue should be closed and ProtocolLib updated on spigotmc.org

Yet packet.getAdvancements() throws NullPointerException.

java.lang.StackOverflowError thrown when calling packet.getProgress(),

Hello from 2019 @JarvisCraft Do you know about this problem? dmulloy2/ProtocolLib#593 😢