Search in sources :

Example 1 with WrappedPacket

use of io.github.retrooper.packetevents.packetwrappers.WrappedPacket in project packetevents by retrooper.

the class AttributeSnapshotWrapper method getKey.

public String getKey() {
    if (stringKeyPresent) {
        return readString(0);
    } else {
        Object attributeBase = readObject(0, attributeBaseClass);
        WrappedPacket attributeBaseWrapper = new WrappedPacket(new NMSPacket(attributeBase), attributeBaseClass);
        return attributeBaseWrapper.readString(0);
    }
}
Also used : WrappedPacket(io.github.retrooper.packetevents.packetwrappers.WrappedPacket) NMSPacket(io.github.retrooper.packetevents.packetwrappers.NMSPacket)

Example 2 with WrappedPacket

use of io.github.retrooper.packetevents.packetwrappers.WrappedPacket in project packetevents by retrooper.

the class WrappedPacketOutCustomPayload method getBuffer.

private Object getBuffer() {
    Object dataSerializer = readObject(0, NMSUtils.packetDataSerializerClass);
    WrappedPacket dataSerializerWrapper = new WrappedPacket(new NMSPacket(dataSerializer));
    return dataSerializerWrapper.readObject(0, NMSUtils.byteBufClass);
}
Also used : WrappedPacket(io.github.retrooper.packetevents.packetwrappers.WrappedPacket) NMSPacket(io.github.retrooper.packetevents.packetwrappers.NMSPacket)

Example 3 with WrappedPacket

use of io.github.retrooper.packetevents.packetwrappers.WrappedPacket in project packetevents by retrooper.

the class WrappedPacketOutMapChunk method setCompressedData.

public void setCompressedData(byte[] data) {
    if (v_1_8_x) {
        if (nmsChunkMap == null) {
            try {
                nmsChunkMap = chunkMapConstructor.newInstance();
            } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
        WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
        nmsChunkMapWrapper.writeByteArray(0, data);
        write(chunkMapClass, 0, nmsChunkMap);
    } else if (v_1_18) {
        new WrappedPacket(new NMSPacket(readObject(0, chunkPacketDataClass))).writeByteArray(0, data);
    } else {
        writeByteArray(0, data);
    }
}
Also used : WrappedPacket(io.github.retrooper.packetevents.packetwrappers.WrappedPacket) InvocationTargetException(java.lang.reflect.InvocationTargetException) NMSPacket(io.github.retrooper.packetevents.packetwrappers.NMSPacket)

Example 4 with WrappedPacket

use of io.github.retrooper.packetevents.packetwrappers.WrappedPacket in project packetevents by retrooper.

the class WrappedPacketOutTabComplete method getMatches.

public String[] getMatches() {
    if (packet != null) {
        if (v_1_13) {
            Object suggestions = readObject(0, suggestionsClass);
            WrappedPacket suggestionsWrapper = new WrappedPacket(new NMSPacket(suggestions));
            List<Object> suggestionList = suggestionsWrapper.readList(0);
            String[] matches = new String[suggestionList.size()];
            for (int i = 0; i < matches.length; i++) {
                Object suggestion = suggestionList.get(i);
                WrappedPacket suggestionWrapper = new WrappedPacket(new NMSPacket(suggestion));
                matches[i] = suggestionWrapper.readString(0);
            }
            return matches;
        } else {
            return readStringArray(0);
        }
    } else {
        return matches;
    }
}
Also used : WrappedPacket(io.github.retrooper.packetevents.packetwrappers.WrappedPacket) NMSPacket(io.github.retrooper.packetevents.packetwrappers.NMSPacket)

Example 5 with WrappedPacket

use of io.github.retrooper.packetevents.packetwrappers.WrappedPacket in project packetevents by retrooper.

the class WrappedWatchableObject method getIndex.

public int getIndex() {
    if (version.isNewerThan(ServerVersion.v_1_8_8)) {
        Object dataWatcherObject = readAnyObject(0);
        WrappedPacket wrappedDataWatcher = new WrappedPacket(new NMSPacket(dataWatcherObject));
        return wrappedDataWatcher.readInt(0);
    } else {
        return readInt(0);
    }
}
Also used : WrappedPacket(io.github.retrooper.packetevents.packetwrappers.WrappedPacket) NMSPacket(io.github.retrooper.packetevents.packetwrappers.NMSPacket)

Aggregations

WrappedPacket (io.github.retrooper.packetevents.packetwrappers.WrappedPacket)50 NMSPacket (io.github.retrooper.packetevents.packetwrappers.NMSPacket)43 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 ArrayList (java.util.ArrayList)5 GrimPlayer (ac.grim.grimac.player.GrimPlayer)3 Vector3d (io.github.retrooper.packetevents.utils.vector.Vector3d)3 Field (java.lang.reflect.Field)3 List (java.util.List)3 Column (ac.grim.grimac.utils.chunks.Column)2 PacketEntity (ac.grim.grimac.utils.data.packetentity.PacketEntity)2 PacketEntityHorse (ac.grim.grimac.utils.data.packetentity.PacketEntityHorse)2 WrappedPacketOutEntityMetadata (io.github.retrooper.packetevents.packetwrappers.play.out.entitymetadata.WrappedPacketOutEntityMetadata)2 WrappedPacketOutSetSlot (io.github.retrooper.packetevents.packetwrappers.play.out.setslot.WrappedPacketOutSetSlot)2 WrappedPacketOutWindowItems (io.github.retrooper.packetevents.packetwrappers.play.out.windowitems.WrappedPacketOutWindowItems)2 ListWrapper (io.github.retrooper.packetevents.utils.list.ListWrapper)2 Vector3i (io.github.retrooper.packetevents.utils.vector.Vector3i)2 EpollSocketChannel (io.netty.channel.epoll.EpollSocketChannel)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 Player (org.bukkit.entity.Player)2