Git Product home page Git Product logo

Comments (5)

coelho avatar coelho commented on August 23, 2024

This is due to the ProtocolLib version you're using not being complete.
Not really something LilyPad can fix.

from bukkit-compatbungee.

dmulloy2 avatar dmulloy2 commented on August 23, 2024

This is an issue with LilyPad. The payload byte array was replaced with the PacketDataSerializer in the payload classes:

private String a;
private PacketDataSerializer b; // Replaced byte array

from bukkit-compatbungee.

coelho avatar coelho commented on August 23, 2024

@dmulloy2

Looking into this further I do not seem to be able to get a PacketDataSerializer (or any of ProtocolLib's wrappers for it) from PacketContainer. Correct me if I'm wrong?

from bukkit-compatbungee.

dmulloy2 avatar dmulloy2 commented on August 23, 2024

There isn't a wrapper for PacketDataSerializer, but something like this would work:

PacketContainer packet = event.getPacket();

// Obtain the data serializer
Class<?> dataSerializerClass = MinecraftReflection.getPacketDataSerializerClass();
StructureModifier<?> dataSerializers = packet.getSpecificModifier(dataSerializerClass);
Object dataSerializer = dataSerializers.read(0);

// Obtain the methods we will need
// You can probably make these static
FuzzyReflection fuzzy = FuzzyReflection.fromClass(dataSerializerClass);
MethodAccessor readableBytes = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("readableBytes", int.class, new Class<?>[0]));
MethodAccessor readBytes = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("readBytes", byte[].class, new Class<?>[] { int.class }));

int i = (int) readableBytes.invoke(dataSerializer);
byte[] bytes = (byte[]) readBytes.invoke(dataSerializer, i);
// Do stuff

from bukkit-compatbungee.

coelho avatar coelho commented on August 23, 2024

Resolved by PR #2

from bukkit-compatbungee.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.