Try use sync task

Former-commit-id: 7dd6e2782dd9177cebbf2c28f56b50bed11ada9a [formerly 1347f2cce27cf6aec093bd4951d912fc3653dc4a]
Former-commit-id: 28bd9c85a99aa23e3f5ac0477f0387b1b2a856cf
This commit is contained in:
Ghost_chu committed 2018-11-21 22:42:20 +08:00
1 parent 3bedbe9f68
commit f4f32d9382
147 files changed
+14597 -22

No files matched your search

@@ -0,0 +1,114 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.entity.Player;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.google.common.base.Objects;
public abstract class AbstractPacket {
// The packet we will be modifying
protected PacketContainer handle;
/**
* Constructs a new strongly typed wrapper for the given packet.
*
* @param handle - handle to the raw packet data.
* @param type - the packet type.
*/
protected AbstractPacket(PacketContainer handle, PacketType type) {
// Make sure we're given a valid packet
if (handle == null)
throw new IllegalArgumentException("Packet handle cannot be NULL.");
if (!Objects.equal(handle.getType(), type))
throw new IllegalArgumentException(handle.getHandle()
+ " is not a packet of type " + type);
this.handle = handle;
}
/**
* Retrieve a handle to the raw packet data.
*
* @return Raw packet data.
*/
public PacketContainer getHandle() {
return handle;
}
/**
* Send the current packet to the given receiver.
*
* @param receiver - the receiver.
* @throws RuntimeException If the packet cannot be sent.
*/
public void sendPacket(Player receiver) {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
getHandle());
} catch (InvocationTargetException e) {
throw new RuntimeException("Cannot send packet.", e);
}
}
/**
* Send the current packet to all online players.
*/
public void broadcastPacket() {
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle());
}
/**
* Simulate receiving the current packet from the given sender.
*
* @param sender - the sender.
* @throws RuntimeException If the packet cannot be received.
* @deprecated Misspelled. recieve to receive
* @see #receivePacket(Player)
*/
@Deprecated
public void recievePacket(Player sender) {
try {
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
getHandle());
} catch (Exception e) {
throw new RuntimeException("Cannot recieve packet.", e);
}
}
/**
* Simulate receiving the current packet from the given sender.
*
* @param sender - the sender.
* @throws RuntimeException if the packet cannot be received.
*/
public void receivePacket(Player sender) {
try {
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
getHandle());
} catch (Exception e) {
throw new RuntimeException("Cannot receive packet.", e);
}
}
}
@@ -0,0 +1,401 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
/**
* Used to process a chunk.
*
* @author Kristian
*/
public class ChunkPacketProcessor {
/**
* Contains the offset of the different block data in a chunk packet.
*
* @author Kristian
*/
public static class ChunkOffsets {
private int blockIdOffset;
private int dataOffset;
private int lightOffset;
private int skylightOffset;
private int extraOffset;
private ChunkOffsets(int blockIdOffset, int dataOffset,
int lightOffset, int skylightOffset, int extraOffset) {
this.blockIdOffset = blockIdOffset;
this.dataOffset = dataOffset;
this.lightOffset = lightOffset;
this.skylightOffset = skylightOffset;
this.extraOffset = extraOffset;
}
private void incrementIdIndex() {
blockIdOffset += ChunkPacketProcessor.BLOCK_ID_LENGTH;
dataOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART;
dataOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART;
if (skylightOffset >= 0) {
skylightOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART;
}
}
private void incrementExtraIndex() {
if (extraOffset >= 0) {
extraOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART;
}
}
/**
* Retrieve the starting index of the block ID data.
* <p>
* This will be 4096 bytes in length, one byte for each block in the
* 16x16x16 chunklet.
*
* @return The starting location of the block ID data.
*/
public int getBlockIdOffset() {
return blockIdOffset;
}
/**
* Retrieve the starting index of the meta data (4 bit per block).
* <p>
* This will be 2048 bytes in length, one nibblet for each block in the
* 16x16x16 chunklet.
*
* @return The starting location of the block meta data.
*/
public int getDataOffset() {
return dataOffset;
}
/**
* Retrieve the starting index of the torch light data (4 bit per
* block).
* <p>
* This will be 2048 bytes in length, one nibblet for each block in the
* 16x16x16 chunklet.
*
* @return The starting location of the torch light data.
*/
public int getLightOffset() {
return lightOffset;
}
/**
* Retrieve the starting index of the skylight data (4 bit per block).
* <p>
* This will be 2048 bytes in length if the skylight data exists (see
* {@link #hasSkylightOffset()}), no bytes if not.
*
* @return The starting location of the skylight data.
*/
public int getSkylightOffset() {
return skylightOffset;
}
/**
* Determine if the current chunklet contains skylight data.
*
* @return TRUE if it does, FALSE otherwise.
*/
public boolean hasSkylightOffset() {
return skylightOffset >= 0;
}
/**
* Retrieve the extra 4 bits in each block ID, if necessary.
* <p>
* This will be 2048 bytes in length if the extra data exists, no bytes
* if not.
*
* @return The starting location of the extra data.
*/
public int getExtraOffset() {
return extraOffset;
}
/**
* Determine if the current chunklet contains any extra block ID data.
*
* @return TRUE if it does, FALSE otherwise.
*/
public boolean hasExtraOffset() {
return extraOffset > 0;
}
}
/**
* Process the content of a single 16x16x16 chunklet in a 16x256x16 chunk.
*
* @author Kristian
*/
public interface ChunkletProcessor {
/**
* Process a given chunklet (16x16x16).
*
* @param origin - the block with the lowest x, y and z coordinate in
* the chunklet.
* @param data - the data array.
* @param offsets - the offsets with the data for the given chunklet.
*/
public void processChunklet(Location origin, byte[] data,
ChunkOffsets offsets);
/**
* Process the biome array for a chunk (16x256x16).
* <p>
* This method will not be called if the chunk is missing biome
* information.
*
* @param origin - the block with the lowest x, y and z coordinate in
* the chunk.
* @param data - the data array.
* @param biomeIndex - the starting index of the biome data (256 bytes
* in lenght).
*/
public void processBiomeArray(Location origin, byte[] data,
int biomeIndex);
}
// Useful Minecraft constants
protected static final int BYTES_PER_NIBBLE_PART = 2048;
protected static final int CHUNK_SEGMENTS = 16;
protected static final int NIBBLES_REQUIRED = 4;
/**Misspelled.
* @see #BLOCK_ID_LENGTH
*/
@Deprecated
public static final int BLOCK_ID_LENGHT = 4096;
public static final int BLOCK_ID_LENGTH = 4096;
/**Misspelled.
* @see #DATA_LENGTH
*/
@Deprecated
public static final int DATA_LENGHT = 2048;
public static final int DATA_LENGTH = 2048;
public static final int BIOME_ARRAY_LENGTH = 256;
private int chunkX;
private int chunkZ;
private int chunkMask;
private int extraMask;
private int chunkSectionNumber;
private int extraSectionNumber;
private boolean hasContinuous = true;
private int startIndex;
private int size;
private byte[] data;
private World world;
private ChunkPacketProcessor() {
// Use factory methods
}
/**
* Construct a chunk packet processor from a given MAP_CHUNK packet.
*
* @param packet - the map chunk packet.
* @return The chunk packet processor.
*/
public static ChunkPacketProcessor fromMapPacket(PacketContainer packet,
World world) {
if (!packet.getType().equals(PacketType.Play.Server.MAP_CHUNK))
throw new IllegalArgumentException(packet
+ " must be a MAP_CHUNK packet.");
StructureModifier<Integer> ints = packet.getIntegers();
StructureModifier<byte[]> byteArray = packet.getByteArrays();
// Create an info objects
ChunkPacketProcessor processor = new ChunkPacketProcessor();
processor.world = world;
processor.chunkX = ints.read(0); // packet.a;
processor.chunkZ = ints.read(1); // packet.b;
processor.chunkMask = ints.read(2); // packet.c;
processor.extraMask = ints.read(3); // packet.d;
processor.data = byteArray.read(1); // packet.inflatedBuffer;
processor.startIndex = 0;
if (packet.getBooleans().size() > 0) {
processor.hasContinuous = packet.getBooleans().read(0);
}
return processor;
}
/**
* Construct an array of chunk packet processors from a given MAP_CHUNK_BULK
* packet.
*
* @param packet - the map chunk bulk packet.
* @return The chunk packet processors.
*/
// The MAP_CHUNK_BULK packet no longer exists
/*
* public static ChunkPacketProcessor[] fromMapBulkPacket(PacketContainer
* packet, World world) {
* if (!packet.getType().equals(PacketType.Play.Server.MAP_CHUNK_BULK))
* throw new IllegalArgumentException(packet +
* " must be a MAP_CHUNK_BULK packet.");
* StructureModifier<int[]> intArrays = packet.getIntegerArrays();
* StructureModifier<byte[]> byteArrays = packet.getByteArrays();
* int[] x = intArrays.read(0); // packet.c;
* int[] z = intArrays.read(1); // packet.d;
* ChunkPacketProcessor[] processors = new ChunkPacketProcessor[x.length];
* int[] chunkMask = intArrays.read(2); // packet.a;
* int[] extraMask = intArrays.read(3); // packet.b;
* int dataStartIndex = 0;
* for (int chunkNum = 0; chunkNum < processors.length; chunkNum++) {
* // Create an info objects
* ChunkPacketProcessor processor = new ChunkPacketProcessor();
* processors[chunkNum] = processor;
* processor.world = world;
* processor.chunkX = x[chunkNum];
* processor.chunkZ = z[chunkNum];
* processor.chunkMask = chunkMask[chunkNum];
* processor.extraMask = extraMask[chunkNum];
* processor.hasContinuous = true; // Always true
* processor.data = byteArrays.read(1); //packet.buildBuffer;
* // Check for Spigot
* if (processor.data == null || processor.data.length == 0) {
* processor.data =
* packet.getSpecificModifier(byte[][].class).read(0)[chunkNum];
* } else {
* processor.startIndex = dataStartIndex;
* }
* dataStartIndex += processor.size;
* }
* return processors;
* }
*/
/**
* Begin processing the current chunk with the provided processor.
*
* @param processor - the processor that will process the chunk.
*/
public void process(ChunkletProcessor processor) {
// Compute chunk number
for (int i = 0; i < CHUNK_SEGMENTS; i++) {
if ((chunkMask & (1 << i)) > 0) {
chunkSectionNumber++;
}
if ((extraMask & (1 << i)) > 0) {
extraSectionNumber++;
}
}
int skylightCount = getSkylightCount();
// The total size of a chunk is the number of blocks sent (depends on the number of sections) multiplied by the
// amount of bytes per block. This last figure can be calculated by adding together all the data parts:
// For any block:
// * Block ID - 8 bits per block (byte)
// * Block metadata - 4 bits per block (nibble)
// * Block light array - 4 bits per block
// If 'worldProvider.skylight' is TRUE
// * Sky light array - 4 bits per block
// If the segment has extra data:
// * Add array - 4 bits per block
// Biome array - only if the entire chunk (has continous) is sent:
// * Biome array - 256 bytes
//
// A section has 16 * 16 * 16 = 4096 blocks.
size =
BYTES_PER_NIBBLE_PART
* ((NIBBLES_REQUIRED + skylightCount)
* chunkSectionNumber + extraSectionNumber)
+ (hasContinuous ? BIOME_ARRAY_LENGTH : 0);
if ((getOffset(2) - startIndex) > data.length) {
return;
}
// Make sure the chunk is loaded
if (isChunkLoaded(world, chunkX, chunkZ)) {
translate(processor);
}
}
/**
* Retrieve the number of 2048 byte segments per chunklet.
* <p<
* This is usually one for The Overworld, and zero for both The End and The
* Nether.
*
* @return Number of skylight byte segments.
*/
protected int getSkylightCount() {
// There's no sun/moon in the end or in the nether, so Minecraft doesn't sent any skylight information
// This optimization was added in 1.4.6. Note that ideally you should get this from the "f" (skylight) field.
return world.getEnvironment() == Environment.NORMAL ? 1 : 0;
}
private int getOffset(int nibbles) {
return startIndex
+ (nibbles * chunkSectionNumber * ChunkPacketProcessor.BYTES_PER_NIBBLE_PART);
}
private void translate(ChunkletProcessor processor) {
// Loop over 16x16x16 chunks in the 16x256x16 column
int current = 4;
ChunkOffsets offsets =
new ChunkOffsets(getOffset(0), getOffset(2), getOffset(3),
getSkylightCount() > 0 ? getOffset(current++) : -1,
extraSectionNumber > 0 ? getOffset(current++) : -1);
for (int i = 0; i < 16; i++) {
// If the bitmask indicates this chunk is sent
if ((chunkMask & 1 << i) > 0) {
// The lowest block (in x, y, z) in this chunklet
Location origin =
new Location(world, chunkX << 4, i * 16, chunkZ << 4);
processor.processChunklet(origin, data, offsets);
offsets.incrementIdIndex();
}
if ((extraMask & 1 << i) > 0) {
offsets.incrementExtraIndex();
}
}
if (hasContinuous) {
processor.processBiomeArray(new Location(world, chunkX << 4, 0,
chunkZ << 4), data, startIndex + size - BIOME_ARRAY_LENGTH);
}
}
private boolean isChunkLoaded(World world, int x, int z) {
return world.isChunkLoaded(x, z);
}
}
@@ -0,0 +1,28 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.plugin.java.JavaPlugin;
public class PacketWrapper extends JavaPlugin {
@Override
public void onEnable() {
// We don't really do much ...
}
}
@@ -0,0 +1,118 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperHandshakingClientSetProtocol extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Handshake.Client.SET_PROTOCOL;
public WrapperHandshakingClientSetProtocol() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperHandshakingClientSetProtocol(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Protocol Version.
* <p>
* Notes: (4 as of 1.7.2)
*
* @return The current Protocol Version
*/
public int getProtocolVersion() {
return handle.getIntegers().read(0);
}
/**
* Set Protocol Version.
*
* @param value - new value.
*/
public void setProtocolVersion(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Server Address (hostname or IP).
* <p>
* Notes: localhost
*
* @return The current Server Address (hostname or IP)
*/
public String getServerAddressHostnameOrIp() {
return handle.getStrings().read(0);
}
/**
* Set Server Address (hostname or IP).
*
* @param value - new value.
*/
public void setServerAddressHostnameOrIp(String value) {
handle.getStrings().write(0, value);
}
/**
* Retrieve Server Port.
* <p>
* Notes: 25565
*
* @return The current Server Port
*/
public int getServerPort() {
return handle.getIntegers().read(1);
}
/**
* Set Server Port.
*
* @param value - new value.
*/
public void setServerPort(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Next state.
* <p>
* Notes: 1 for status, 2 for login
*
* @return The current Next state
*/
public Protocol getNextState() {
return handle.getProtocols().read(0);
}
/**
* Set Next state.
*
* @param value - new value.
*/
public void setNextState(Protocol value) {
handle.getProtocols().write(0, value);
}
}
@@ -0,0 +1,57 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperLoginClientCustomPayload extends AbstractPacket {
public static final PacketType TYPE = PacketType.Login.Client.CUSTOM_PAYLOAD;
public WrapperLoginClientCustomPayload() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginClientCustomPayload(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Message ID.
* <p>
* Notes: should match ID from server.
* @return The current Message ID
*/
public int getMessageId() {
return handle.getIntegers().read(0);
}
/**
* Set Message ID.
* @param value - new value.
*/
public void setMessageId(int value) {
handle.getIntegers().write(0, value);
}
// Cannot find type for b
// Cannot find type for b
}
@@ -0,0 +1,72 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperLoginClientEncryptionBegin extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Login.Client.ENCRYPTION_BEGIN;
public WrapperLoginClientEncryptionBegin() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginClientEncryptionBegin(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Shared Secret.
*
* @return The current Shared Secret
*/
public byte[] getSharedSecret() {
return handle.getByteArrays().read(0);
}
/**
* Set Shared Secret.
*
* @param value - new value.
*/
public void setSharedSecret(byte[] value) {
handle.getByteArrays().write(0, value);
}
/**
* Retrieve Verify Token.
*
* @return The current Verify Token
*/
public byte[] getVerifyToken() {
return handle.getByteArrays().read(1);
}
/**
* Set Verify Token.
*
* @param value - new value.
*/
public void setVerifyToken(byte[] value) {
handle.getByteArrays().write(1, value);
}
}
@@ -0,0 +1,54 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
public class WrapperLoginClientStart extends AbstractPacket {
public static final PacketType TYPE = PacketType.Login.Client.START;
public WrapperLoginClientStart() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginClientStart(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Profile.
*
* @return The current Profile
*/
public WrappedGameProfile getProfile() {
return handle.getGameProfiles().read(0);
}
/**
* Set Name.
*
* @param value - new value.
*/
public void setProfile(WrappedGameProfile value) {
handle.getGameProfiles().write(0, value);
}
}
@@ -0,0 +1,57 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperLoginServerCustomPayload extends AbstractPacket {
public static final PacketType TYPE = PacketType.Login.Server.CUSTOM_PAYLOAD;
public WrapperLoginServerCustomPayload() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginServerCustomPayload(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Message ID.
* <p>
* Notes: generated by the server - should be unique to the connection.
* @return The current Message ID
*/
public int getMessageId() {
return handle.getIntegers().read(0);
}
/**
* Set Message ID.
* @param value - new value.
*/
public void setMessageId(int value) {
handle.getIntegers().write(0, value);
}
// Cannot find type for b
// Cannot find type for b
}
@@ -0,0 +1,64 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
public class WrapperLoginServerDisconnect extends AbstractPacket {
public static final PacketType TYPE = PacketType.Login.Server.DISCONNECT;
public WrapperLoginServerDisconnect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginServerDisconnect(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve reason.
*
* @return The current reason
*/
public WrappedChatComponent getReason() {
return handle.getChatComponents().read(0);
}
@Deprecated
public WrappedChatComponent getJsonData() {
return getReason();
}
/**
* Set reason.
*
* @param value - new value.
*/
public void setReason(WrappedChatComponent value) {
handle.getChatComponents().write(0, value);
}
@Deprecated
public void setJsonData(WrappedChatComponent value) {
setReason(value);
}
}
@@ -0,0 +1,94 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.security.PublicKey;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperLoginServerEncryptionBegin extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Login.Server.ENCRYPTION_BEGIN;
public WrapperLoginServerEncryptionBegin() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginServerEncryptionBegin(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Server ID.
* <p>
* Notes: appears to be empty as of 1.7.x
*
* @return The current Server ID
*/
public String getServerId() {
return handle.getStrings().read(0);
}
/**
* Set Server ID.
*
* @param value - new value.
*/
public void setServerId(String value) {
handle.getStrings().write(0, value);
}
/**
* Retrieve Public Key.
*
* @return The current Public Key
*/
public PublicKey getPublicKey() {
return handle.getSpecificModifier(PublicKey.class).read(0);
}
/**
* Set Public Key.
*
* @param value - new value.
*/
public void setPublicKey(PublicKey value) {
handle.getSpecificModifier(PublicKey.class).write(0, value);
}
/**
* Retrieve Verify Token.
*
* @return The current Verify Token
*/
public byte[] getVerifyToken() {
return handle.getByteArrays().read(0);
}
/**
* Set Verify Token.
*
* @param value - new value.
*/
public void setVerifyToken(byte[] value) {
handle.getByteArrays().write(0, value);
}
}
@@ -0,0 +1,57 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperLoginServerSetCompression extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Login.Server.SET_COMPRESSION;
public WrapperLoginServerSetCompression() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginServerSetCompression(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Threshold.
* <p>
* Notes: threshold is the max size of a packet before its compressed
*
* @return The current Threshold
*/
public int getThreshold() {
return handle.getIntegers().read(0);
}
/**
* Set Threshold.
*
* @param value - new value.
*/
public void setThreshold(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,54 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
public class WrapperLoginServerSuccess extends AbstractPacket {
public static final PacketType TYPE = PacketType.Login.Server.SUCCESS;
public WrapperLoginServerSuccess() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperLoginServerSuccess(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve the UUID and player name of the connected client.
*
* @return The current client profile.
*/
public WrappedGameProfile getProfile() {
return handle.getGameProfiles().read(0);
}
/**
* Set the UUID and player name of the connected client as a game profile.
*
* @param value - new profile.
*/
public void setProfile(WrappedGameProfile value) {
handle.getGameProfiles().write(0, value);
}
}
@@ -0,0 +1,99 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientAbilities extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ABILITIES;
public WrapperPlayClientAbilities() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientAbilities(PacketContainer packet) {
super(packet, TYPE);
}
public boolean isInvulnerable() {
return handle.getBooleans().read(0);
}
public void setInvulnerable(boolean value) {
handle.getBooleans().write(0, value);
}
/**Misspelled.
* @see #isInvulnerable()
*/
@Deprecated
public boolean isInvulnurable() {
return handle.getBooleans().read(0);
}
/**Misspelled.
* @see #setInvulnerable(boolean)
*/
@Deprecated
public void setInvulnurable(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean isFlying() {
return handle.getBooleans().read(1);
}
public void setFlying(boolean value) {
handle.getBooleans().write(1, value);
}
public boolean canFly() {
return handle.getBooleans().read(2);
}
public void setCanFly(boolean value) {
handle.getBooleans().write(2, value);
}
public boolean canInstantlyBuild() {
return handle.getBooleans().read(3);
}
public void setCanInstantlyBuild(boolean value) {
handle.getBooleans().write(3, value);
}
public float getFlyingSpeed() {
return handle.getFloat().read(0);
}
public void setFlyingSpeed(float value) {
handle.getFloat().write(0, value);
}
public float getWalkingSpeed() {
return handle.getFloat().read(1);
}
public void setWalkingSpeed(float value) {
handle.getFloat().write(1, value);
}
}
@@ -0,0 +1,77 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.MinecraftKey;
public class WrapperPlayClientAdvancements extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ADVANCEMENTS;
public WrapperPlayClientAdvancements() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientAdvancements(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Action.
* <p>
* Notes: 0: Opened tab, 1: Closed screen
* @return The current Action
*/
public Status getAction() {
return handle.getEnumModifier(Status.class, 0).readSafely(0);
}
/**
* Set Action.
* @param value - new value.
*/
public void setAction(Status value) {
handle.getEnumModifier(Status.class, 0).writeSafely(0, value);
}
/**
* Retrieve Tab ID.
* <p>
* Notes: only present if action is Opened tab
* @return The current Tab ID
*/
public MinecraftKey getTabId() {
return handle.getMinecraftKeys().readSafely(0);
}
/**
* Set Tab ID.
* @param value - new value.
*/
public void setTabId(MinecraftKey value) {
handle.getMinecraftKeys().writeSafely(0, value);
}
public enum Status {
OPENED_TAB,
CLOSED_SCREEN;
}
}
@@ -0,0 +1,35 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientArmAnimation extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ARM_ANIMATION;
public WrapperPlayClientArmAnimation() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientArmAnimation(PacketContainer packet) {
super(packet, TYPE);
}
}
@@ -0,0 +1,64 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientAutoRecipe extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.AUTO_RECIPE;
public WrapperPlayClientAutoRecipe() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientAutoRecipe(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window ID.
* <p>
* Notes: the window id.
* @return The current Window ID
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window ID.
* @param value - new value.
*/
public void setWindowId(int value) {
handle.getIntegers().write(0, value);
}
// Modifier for recipe can be created upon request
public boolean isMakeAll() {
return handle.getBooleans().read(0);
}
public void setMakeAll(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,73 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientBeacon extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.BEACON;
public WrapperPlayClientBeacon() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientBeacon(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Primary Effect.
* <p>
* Notes: a Potion ID. (Was a full Integer for the plugin message)
* @return The current Primary Effect
*/
public int getPrimaryEffect() {
return handle.getIntegers().read(0);
}
/**
* Set Primary Effect.
* @param value - new value.
*/
public void setPrimaryEffect(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Secondary Effect.
* <p>
* Notes: a Potion ID. (Was a full Integer for the plugin message)
* @return The current Secondary Effect
*/
public int getSecondaryEffect() {
return handle.getIntegers().read(1);
}
/**
* Set Secondary Effect.
* @param value - new value.
*/
public void setSecondaryEffect(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,86 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
public class WrapperPlayClientBlockDig extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.BLOCK_DIG;
public WrapperPlayClientBlockDig() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientBlockDig(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
* <p>
* Notes: block position
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
public Direction getDirection() {
return handle.getDirections().read(0);
}
public void setDirection(Direction value) {
handle.getDirections().write(0, value);
}
/**
* Retrieve Status.
* <p>
* Notes: the action the player is taking against the block (see below)
*
* @return The current Status
*/
public PlayerDigType getStatus() {
return handle.getPlayerDigTypes().read(0);
}
/**
* Set Status.
*
* @param value - new value.
*/
public void setStatus(PlayerDigType value) {
handle.getPlayerDigTypes().write(0, value);
}
}
@@ -0,0 +1,53 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.Hand;
public class WrapperPlayClientBlockPlace extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.BLOCK_PLACE;
public WrapperPlayClientBlockPlace() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientBlockPlace(PacketContainer packet) {
super(packet, TYPE);
}
public Hand getHand() {
return handle.getHands().read(0);
}
public void setHand(Hand value) {
handle.getHands().write(0, value);
}
public long getTimestamp() {
return handle.getLongs().read(0);
}
public void setTimestamp(long value) {
handle.getLongs().write(0, value);
}
}
@@ -0,0 +1,53 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientBoatMove extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.BOAT_MOVE;
public WrapperPlayClientBoatMove() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientBoatMove(PacketContainer packet) {
super(packet, TYPE);
}
public boolean getLeftOar() {
return handle.getBooleans().read(0);
}
public void setLeftOar(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean getRightOar() {
return handle.getBooleans().read(1);
}
public void setRightOar(boolean value) {
handle.getBooleans().write(1, value);
}
}
@@ -0,0 +1,72 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import org.bukkit.inventory.ItemStack;
public class WrapperPlayClientBookEdit extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.BOOK_EDIT;
public WrapperPlayClientBookEdit() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientBookEdit(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve New book.
* @return The current New book
*/
public ItemStack getNewBook() {
return handle.getItemModifier().read(0);
}
/**
* Set New book.
* @param value - new value.
*/
public void setNewBook(ItemStack value) {
handle.getItemModifier().write(0, value);
}
/**
* Retrieve Is signing.
* <p>
* Notes: true if the player is signing the book; false if the player is saving a draft.
* @return The current Is signing
*/
public boolean getIsSigning() {
return handle.getBooleans().read(0);
}
/**
* Set Is signing.
* @param value - new value.
*/
public void setIsSigning(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,54 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientChat extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.CHAT;
public WrapperPlayClientChat() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientChat(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Message.
*
* @return The current Message
*/
public String getMessage() {
return handle.getStrings().read(0);
}
/**
* Set Message.
*
* @param value - new value.
*/
public void setMessage(String value) {
handle.getStrings().write(0, value);
}
}
@@ -0,0 +1,57 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand;
public class WrapperPlayClientClientCommand extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.CLIENT_COMMAND;
public WrapperPlayClientClientCommand() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientClientCommand(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Action ID.
* <p>
* Notes: see below
*
* @return The current Action ID
*/
public ClientCommand getAction() {
return handle.getClientCommands().read(0);
}
/**
* Set Action ID.
*
* @param value - new value.
*/
public void setAction(ClientCommand value) {
handle.getClientCommands().write(0, value);
}
}
@@ -0,0 +1,56 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientCloseWindow extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.CLOSE_WINDOW;
public WrapperPlayClientCloseWindow() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientCloseWindow(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window id.
* <p>
* Notes: this is the id of the window that was closed. 0 for inventory.
*
* @return The current Window id
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window id.
*
* @param value - new value.
*/
public void setWindowId(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,96 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.MinecraftKey;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class WrapperPlayClientCustomPayload extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.CUSTOM_PAYLOAD;
public WrapperPlayClientCustomPayload() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientCustomPayload(PacketContainer packet) {
super(packet, TYPE);
}
public MinecraftKey getChannel() {
return handle.getMinecraftKeys().readSafely(0);
}
/**
* Starting in 1.13, channel names need to be lower case, in the new identifier format,
* i.e. {@code minecraft:brand}. The previously standard {@code |} is no longer allowed.
*/
public void setChannel(MinecraftKey value) {
handle.getMinecraftKeys().writeSafely(0, value);
}
/**
* Retrieve payload contents as a raw Netty buffer
*
* @return Payload contents as a Netty buffer
*/
public ByteBuf getContentsBuffer() {
return (ByteBuf) handle.getModifier().withType(ByteBuf.class).read(0);
}
/**
* Retrieve payload contents
*
* @return Payload contents as a byte array
*/
public byte[] getContents() {
ByteBuf buffer = getContentsBuffer();
byte[] array = new byte[buffer.readableBytes()];
buffer.readBytes(array);
return array;
}
/**
* Update payload contents with a Netty buffer
*
* @param contents - new payload contents
*/
public void setContentsBuffer(ByteBuf contents) {
if (MinecraftReflection.is(MinecraftReflection.getPacketDataSerializerClass(), contents)) {
handle.getModifier().withType(ByteBuf.class).write(0, contents);
} else {
Object serializer = MinecraftReflection.getPacketDataSerializer(contents);
handle.getModifier().withType(ByteBuf.class).write(0, serializer);
}
}
/**
* Update payload contents with a byte array
*
* @param content - new payload content
*/
public void setContents(byte[] content) {
setContentsBuffer(Unpooled.copiedBuffer(content));
}
}
@@ -0,0 +1,77 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientEnchantItem extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ENCHANT_ITEM;
public WrapperPlayClientEnchantItem() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientEnchantItem(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window ID.
* <p>
* Notes: the ID sent by Open Window
*
* @return The current Window ID
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window ID.
*
* @param value - new value.
*/
public void setWindowId(byte value) {
handle.getIntegers().write(0, (int) value);
}
/**
* Retrieve Enchantment.
* <p>
* Notes: the position of the enchantment on the enchantment table window,
* starting with 0 as the topmost one.
*
* @return The current Enchantment
*/
public int getEnchantment() {
return handle.getIntegers().read(1);
}
/**
* Set Enchantment.
*
* @param value - new value.
*/
public void setEnchantment(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,121 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerAction;
public class WrapperPlayClientEntityAction extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ENTITY_ACTION;
public WrapperPlayClientEntityAction() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientEntityAction(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Action ID.
* <p>
* Notes: the ID of the action, see below.
*
* @return The current Action ID
*/
public PlayerAction getAction() {
return handle.getPlayerActions().read(0);
}
/**
* Set Action ID.
*
* @param value - new value.
*/
public void setAction(PlayerAction value) {
handle.getPlayerActions().write(0, value);
}
/**
* Retrieve Jump Boost.
* <p>
* Notes: horse jump boost. Ranged from 0 -> 100.
*
* @return The current Jump Boost
*/
public int getJumpBoost() {
return handle.getIntegers().read(1);
}
/**
* Set Jump Boost.
*
* @param value - new value.
*/
public void setJumpBoost(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,95 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.World;
import org.bukkit.entity.Entity;
public class WrapperPlayClientEntityNbtQuery extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ENTITY_NBT_QUERY;
public WrapperPlayClientEntityNbtQuery() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientEntityNbtQuery(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Transaction ID.
* <p>
* Notes: an incremental ID so that the client can verify that the response matches.
* @return The current Transaction ID
*/
public int getTransactionId() {
return handle.getIntegers().read(0);
}
/**
* Set Transaction ID.
* @param value - new value.
*/
public void setTransactionId(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: the ID of the entity to query.
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(1);
}
/**
* Retrieve the entity involved in this event.
* @param world - the current world of the entity.
* @return The involved entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(1);
}
/**
* Retrieve the entity involved in this event.
* @param event - the packet event.
* @return The involved entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Set Entity ID.
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,56 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientFlying extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.FLYING;
public WrapperPlayClientFlying() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientFlying(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve On Ground.
* <p>
* Notes: true if the client is on the ground, False otherwise
*
* @return The current On Ground
*/
public boolean getOnGround() {
return handle.getBooleans().read(0);
}
/**
* Set On Ground.
*
* @param value - new value.
*/
public void setOnGround(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,56 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientHeldItemSlot extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.HELD_ITEM_SLOT;
public WrapperPlayClientHeldItemSlot() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientHeldItemSlot(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Slot.
* <p>
* Notes: the slot which the player has selected (0-8)
*
* @return The current Slot
*/
public int getSlot() {
return handle.getIntegers().read(0);
}
/**
* Set Slot.
*
* @param value - new value.
*/
public void setSlot(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,55 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientItemName extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.ITEM_NAME;
public WrapperPlayClientItemName() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientItemName(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Item name.
* <p>
* Notes: the new name of the item
* @return The current Item name
*/
public String getItemName() {
return handle.getStrings().read(0);
}
/**
* Set Item name.
* @param value - new value.
*/
public void setItemName(String value) {
handle.getStrings().write(0, value);
}
}
@@ -0,0 +1,54 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientKeepAlive extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.KEEP_ALIVE;
public WrapperPlayClientKeepAlive() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientKeepAlive(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Keep Alive ID.
*
* @return The current Keep Alive ID
*/
public long getKeepAliveId() {
return handle.getLongs().read(0);
}
/**
* Set Keep Alive ID.
*
* @param value - new value.
*/
public void setKeepAliveId(long value) {
handle.getLongs().write(0, value);
}
}
@@ -0,0 +1,96 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientLook extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.LOOK;
public WrapperPlayClientLook() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientLook(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Yaw.
* <p>
* Notes: absolute rotation on the X Axis, in degrees
*
* @return The current Yaw
*/
public float getYaw() {
return handle.getFloat().read(0);
}
/**
* Set Yaw.
*
* @param value - new value.
*/
public void setYaw(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Pitch.
* <p>
* Notes: absolute rotation on the Y Axis, in degrees
*
* @return The current Pitch
*/
public float getPitch() {
return handle.getFloat().read(1);
}
/**
* Set Pitch.
*
* @param value - new value.
*/
public void setPitch(float value) {
handle.getFloat().write(1, value);
}
/**
* Retrieve On Ground.
* <p>
* Notes: true if the client is on the ground, False otherwise
*
* @return The current On Ground
*/
public boolean getOnGround() {
return handle.getBooleans().read(0);
}
/**
* Set On Ground.
*
* @param value - new value.
*/
public void setOnGround(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,55 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientPickItem extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.PICK_ITEM;
public WrapperPlayClientPickItem() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientPickItem(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Slot to use.
* <p>
* Notes: see Inventory
* @return The current Slot to use
*/
public int getSlotToUse() {
return handle.getIntegers().read(0);
}
/**
* Set Slot to use.
* @param value - new value.
*/
public void setSlotToUse(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,117 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientPosition extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.POSITION;
public WrapperPlayClientPosition() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientPosition(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve X.
* <p>
* Notes: absolute position
*
* @return The current X
*/
public double getX() {
return handle.getDoubles().read(0);
}
/**
* Set X.
*
* @param value - new value.
*/
public void setX(double value) {
handle.getDoubles().write(0, value);
}
/**
* Retrieve FeetY.
* <p>
* Notes: absolute feet position, normally HeadY - 1.62. Used to modify the
* players bounding box when going up stairs, crouching, etc…
*
* @return The current FeetY
*/
public double getY() {
return handle.getDoubles().read(1);
}
/**
* Set FeetY.
*
* @param value - new value.
*/
public void setY(double value) {
handle.getDoubles().write(1, value);
}
/**
* Retrieve Z.
* <p>
* Notes: absolute position
*
* @return The current Z
*/
public double getZ() {
return handle.getDoubles().read(2);
}
/**
* Set Z.
*
* @param value - new value.
*/
public void setZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve On Ground.
* <p>
* Notes: true if the client is on the ground, False otherwise
*
* @return The current On Ground
*/
public boolean getOnGround() {
return handle.getBooleans().read(0);
}
/**
* Set On Ground.
*
* @param value - new value.
*/
public void setOnGround(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,157 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientPositionLook extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.POSITION_LOOK;
public WrapperPlayClientPositionLook() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientPositionLook(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve X.
* <p>
* Notes: absolute position
*
* @return The current X
*/
public double getX() {
return handle.getDoubles().read(0);
}
/**
* Set X.
*
* @param value - new value.
*/
public void setX(double value) {
handle.getDoubles().write(0, value);
}
/**
* Retrieve Feet Y.
* <p>
* Notes: absolute feet position. Is normally HeadY - 1.62. Used to modify
* the players bounding box when going up stairs, crouching, etc…
*
* @return The current FeetY
*/
public double getY() {
return handle.getDoubles().read(1);
}
/**
* Set Feet Y.
*
* @param value - new value.
*/
public void setY(double value) {
handle.getDoubles().write(1, value);
}
/**
* Retrieve Z.
* <p>
* Notes: absolute position
*
* @return The current Z
*/
public double getZ() {
return handle.getDoubles().read(2);
}
/**
* Set Z.
*
* @param value - new value.
*/
public void setZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve Yaw.
* <p>
* Notes: absolute rotation on the X Axis, in degrees
*
* @return The current Yaw
*/
public float getYaw() {
return handle.getFloat().read(0);
}
/**
* Set Yaw.
*
* @param value - new value.
*/
public void setYaw(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Pitch.
* <p>
* Notes: absolute rotation on the Y Axis, in degrees
*
* @return The current Pitch
*/
public float getPitch() {
return handle.getFloat().read(1);
}
/**
* Set Pitch.
*
* @param value - new value.
*/
public void setPitch(float value) {
handle.getFloat().write(1, value);
}
/**
* Retrieve On Ground.
* <p>
* Notes: true if the client is on the ground, False otherwise
*
* @return The current On Ground
*/
public boolean getOnGround() {
return handle.getBooleans().read(0);
}
/**
* Set On Ground.
*
* @param value - new value.
*/
public void setOnGround(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,66 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientRecipeDisplayed extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.RECIPE_DISPLAYED;
public WrapperPlayClientRecipeDisplayed() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientRecipeDisplayed(PacketContainer packet) {
super(packet, TYPE);
}
public Status getStatus() {
return handle.getEnumModifier(Status.class, 0).readSafely(0);
}
public void setStatus(Status value) {
handle.getEnumModifier(Status.class, 0).writeSafely(0, value);
}
// Modifier for recipe can be created upon request
public boolean isBookOpen() {
return handle.getBooleans().read(0);
}
public void setBookOpen(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean isFilterActive() {
return handle.getBooleans().read(1);
}
public void setFilterActive(boolean value) {
handle.getBooleans().write(1, value);
}
public enum Status {
SHOWN,
SETTINGS;
}
}
@@ -0,0 +1,58 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus;
public class WrapperPlayClientResourcePackStatus extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Client.RESOURCE_PACK_STATUS;
public WrapperPlayClientResourcePackStatus() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientResourcePackStatus(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Result.
* <p>
* Notes: successfully loaded: 0, Declined: 1, Failed download: 2, Accepted:
* 3
*
* @return The current Result
*/
public ResourcePackStatus getResult() {
return handle.getResourcePackStatus().read(0);
}
/**
* Set Result.
*
* @param value - new value.
*/
public void setResult(ResourcePackStatus value) {
handle.getResourcePackStatus().write(0, value);
}
}
@@ -0,0 +1,111 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayClientSetCommandBlock extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.SET_COMMAND_BLOCK;
public WrapperPlayClientSetCommandBlock() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientSetCommandBlock(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().readSafely(0);
}
/**
* Set Location.
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().writeSafely(0, value);
}
/**
* Retrieve Command.
* @return The current Command
*/
public String getCommand() {
return handle.getStrings().read(0);
}
/**
* Set Command.
* @param value - new value.
*/
public void setCommand(String value) {
handle.getStrings().write(0, value);
}
/**
* if false, the output of the previous command will not be stored within the command block
*/
public boolean isTrackOutput() {
return handle.getBooleans().read(0);
}
public void setTrackOutput(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean isConditional() {
return handle.getBooleans().read(1);
}
public void setConditional(boolean value) {
handle.getBooleans().write(1, value);
}
public boolean isAutomatic() {
return handle.getBooleans().read(2);
}
public void setAutomatic(boolean value) {
handle.getBooleans().write(2, value);
}
public Mode getMode() {
return handle.getEnumModifier(Mode.class, MinecraftReflection.getMinecraftClass("TileEntityCommand$Type")).readSafely(0);
}
public void setMode(Mode mode) {
handle.getEnumModifier(Mode.class, MinecraftReflection.getMinecraftClass("TileEntityCommand$Type")).writeSafely(0, mode);
}
public enum Mode {
SEQUENCE,
AUTO,
REDSTONE
}
}
@@ -0,0 +1,109 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.World;
import org.bukkit.entity.Entity;
public class WrapperPlayClientSetCommandMinecart extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.SET_COMMAND_MINECART;
public WrapperPlayClientSetCommandMinecart() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientSetCommandMinecart(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Retrieve the entity involved in this event.
* @param world - the current world of the entity.
* @return The involved entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity involved in this event.
* @param event - the packet event.
* @return The involved entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Set Entity ID.
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Command.
* @return The current Command
*/
public String getCommand() {
return handle.getStrings().read(0);
}
/**
* Set Command.
* @param value - new value.
*/
public void setCommand(String value) {
handle.getStrings().write(0, value);
}
/**
* Retrieve Track Output.
* <p>
* Notes: if false, the output of the previous command will not be stored within the command block.
* @return The current Track Output
*/
public boolean getTrackOutput() {
return handle.getBooleans().read(0);
}
/**
* Set Track Output.
* @param value - new value.
*/
public void setTrackOutput(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,77 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.inventory.ItemStack;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientSetCreativeSlot extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Client.SET_CREATIVE_SLOT;
public WrapperPlayClientSetCreativeSlot() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientSetCreativeSlot(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Slot.
* <p>
* Notes: inventory slot
*
* @return The current Slot
*/
public int getSlot() {
return handle.getIntegers().read(0);
}
/**
* Set Slot.
*
* @param value - new value.
*/
public void setSlot(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Clicked item.
*
* @return The current Clicked item
*/
public ItemStack getClickedItem() {
return handle.getItemModifier().read(0);
}
/**
* Set Clicked item.
*
* @param value - new value.
*/
public void setClickedItem(ItemStack value) {
handle.getItemModifier().write(0, value);
}
}
@@ -0,0 +1,137 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility;
public class WrapperPlayClientSettings extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.SETTINGS;
public WrapperPlayClientSettings() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientSettings(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Locale.
* <p>
* Notes: en_GB
*
* @return The current Locale
*/
public String getLocale() {
return handle.getStrings().read(0);
}
/**
* Set Locale.
*
* @param value - new value.
*/
public void setLocale(String value) {
handle.getStrings().write(0, value);
}
/**
* Retrieve View distance.
* <p>
* Notes: client-side render distance(chunks)
*
* @return The current View distance
*/
public int getViewDistance() {
return handle.getIntegers().read(0);
}
/**
* Set View distance.
*
* @param value - new value.
*/
public void setViewDistance(byte value) {
handle.getIntegers().write(0, (int) value);
}
/**
* Retrieve Chat flags.
* <p>
* Notes: chat settings. See notes below.
*
* @return The current Chat flags
*/
public ChatVisibility getChatFlags() {
return handle.getChatVisibilities().read(0);
}
/**
* Set Chat flags.
*
* @param value - new value.
*/
public void setChatFlags(ChatVisibility value) {
handle.getChatVisibilities().write(0, value);
}
/**
* Retrieve Chat colours.
* <p>
* Notes: "Colours" multiplayer setting
*
* @return The current Chat colours
*/
public boolean getChatColours() {
return handle.getBooleans().read(0);
}
/**
* Set Chat colours.
*
* @param value - new value.
*/
public void setChatColours(boolean value) {
handle.getBooleans().write(0, value);
}
/**
* Retrieve Displayed skin parts.
* <p>
* Notes: skin parts. See note below
*
* @return The current Displayed skin parts
*/
public int getDisplayedSkinParts() {
return handle.getIntegers().read(1);
}
/**
* Set Displayed skin parts.
*
* @param value - new value.
*/
public void setDisplayedSkinParts(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,56 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.UUID;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientSpectate extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.SPECTATE;
public WrapperPlayClientSpectate() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientSpectate(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Target Player.
*
* @return The current Target Player
*/
public UUID getTargetPlayer() {
return handle.getUUIDs().read(0);
}
/**
* Set Target Player.
*
* @param value - new value.
*/
public void setTargetPlayer(UUID value) {
handle.getUUIDs().write(0, value);
}
}
@@ -0,0 +1,92 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientSteerVehicle extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.STEER_VEHICLE;
public WrapperPlayClientSteerVehicle() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientSteerVehicle(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Sideways.
* <p>
* Notes: positive to the left of the player
*
* @return The current Sideways
*/
public float getSideways() {
return handle.getFloat().read(0);
}
/**
* Set Sideways.
*
* @param value - new value.
*/
public void setSideways(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Forward.
* <p>
* Notes: positive forward
*
* @return The current Forward
*/
public float getForward() {
return handle.getFloat().read(1);
}
/**
* Set Forward.
*
* @param value - new value.
*/
public void setForward(float value) {
handle.getFloat().write(1, value);
}
public boolean isJump() {
return handle.getBooleans().read(0);
}
public void setJump(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean isUnmount() {
return handle.getBooleans().read(1);
}
public void setUnmount(boolean value) {
handle.getBooleans().write(1, value);
}
}
@@ -0,0 +1,39 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayClientStructureBlock extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.STRUCTURE_BLOCK;
public WrapperPlayClientStructureBlock() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientStructureBlock(PacketContainer packet) {
super(packet, TYPE);
}
// TODO manually upon request
}
@@ -0,0 +1,53 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.mojang.brigadier.suggestion.Suggestions;
public class WrapperPlayClientTabComplete extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.TAB_COMPLETE;
public WrapperPlayClientTabComplete() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientTabComplete(PacketContainer packet) {
super(packet, TYPE);
}
public int getTransactionId() {
return handle.getIntegers().read(0);
}
public void setTransactionId(int value) {
handle.getIntegers().write(0, value);
}
public String getInput() {
return handle.getStrings().read(0);
}
public void setInput(String value) {
handle.getStrings().write(0, value);
}
}
@@ -0,0 +1,58 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientTeleportAccept extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Client.TELEPORT_ACCEPT;
public WrapperPlayClientTeleportAccept() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientTeleportAccept(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Teleport ID.
* <p>
* Notes: the ID given by the Player Position And Look packet
*
* @return The current Teleport ID
*/
public int getTeleportId() {
return handle.getIntegers().read(0);
}
/**
* Set Teleport ID.
*
* @param value - new value.
*/
public void setTeleportId(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,74 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayClientTileNbtQuery extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.TILE_NBT_QUERY;
public WrapperPlayClientTileNbtQuery() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientTileNbtQuery(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Transaction ID.
* <p>
* Notes: an incremental ID so that the client can verify that the response matches.
* @return The current Transaction ID
*/
public int getTransactionId() {
return handle.getIntegers().read(0);
}
/**
* Set Transaction ID.
* @param value - new value.
*/
public void setTransactionId(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Location.
* <p>
* Notes: the location of the block to check.
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
}
@@ -0,0 +1,21 @@
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientTradeSelect extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.TRADE_SELECT;
public WrapperPlayClientTradeSelect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public int getSlot() {
return handle.getIntegers().read(0);
}
public void setSlot(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,97 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientTransaction extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.TRANSACTION;
public WrapperPlayClientTransaction() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientTransaction(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window ID.
* <p>
* Notes: the id of the window that the action occurred in.
*
* @return The current Window ID
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window ID.
*
* @param value - new value.
*/
public void setWindowId(byte value) {
handle.getIntegers().write(0, (int) value);
}
/**
* Retrieve Action number.
* <p>
* Notes: every action that is to be accepted has a unique number. This
* field corresponds to that number.
*
* @return The current Action number
*/
public short getActionNumber() {
return handle.getShorts().read(0);
}
/**
* Set Action number.
*
* @param value - new value.
*/
public void setActionNumber(short value) {
handle.getShorts().write(0, value);
}
/**
* Retrieve Accepted.
* <p>
* Notes: whether the action was accepted.
*
* @return The current Accepted
*/
public boolean getAccepted() {
return handle.getBooleans().read(0);
}
/**
* Set Accepted.
*
* @param value - new value.
*/
public void setAccepted(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,79 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayClientUpdateSign extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.UPDATE_SIGN;
public WrapperPlayClientUpdateSign() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientUpdateSign(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
* <p>
* Notes: block Coordinates
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
/**
* Retrieve this sign's lines of text.
*
* @return The current lines
*/
public String[] getLines() {
return handle.getStringArrays().read(0);
}
/**
* Set this sign's lines of text.
*
* @param value - Lines, must be 4 elements long
*/
public void setLines(String[] value) {
if (value == null)
throw new IllegalArgumentException("value cannot be null!");
if (value.length != 4)
throw new IllegalArgumentException("value must have 4 elements!");
handle.getStringArrays().write(0, value);
}
}
@@ -0,0 +1,117 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
public class WrapperPlayClientUseEntity extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.USE_ENTITY;
public WrapperPlayClientUseEntity() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientUseEntity(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve entity ID of the target.
*
* @return The current entity ID
*/
public int getTargetID() {
return handle.getIntegers().read(0);
}
/**
* Retrieve the entity that was targeted.
*
* @param world - the current world of the entity.
* @return The targeted entity.
*/
public Entity getTarget(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity that was targeted.
*
* @param event - the packet event.
* @return The targeted entity.
*/
public Entity getTarget(PacketEvent event) {
return getTarget(event.getPlayer().getWorld());
}
/**
* Set entity ID of the target.
*
* @param value - new value.
*/
public void setTargetID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Type.
*
* @return The current Type
*/
public EntityUseAction getType() {
return handle.getEntityUseActions().read(0);
}
/**
* Set Type.
*
* @param value - new value.
*/
public void setType(EntityUseAction value) {
handle.getEntityUseActions().write(0, value);
}
/**
* Retrieve the target vector.
* <p>
* Notes: Only if {@link #getType()} is {@link EntityUseAction#INTERACT_AT}.
*
* @return The target vector or null
*/
public Vector getTargetVector() {
return handle.getVectors().read(0);
}
/**
* Set the target vector.
*
* @param value - new value.
*/
public void setTargetVector(Vector value) {
handle.getVectors().write(0, value);
}
}
@@ -0,0 +1,138 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import com.comphenix.protocol.wrappers.EnumWrappers.Hand;
public class WrapperPlayClientUseItem extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.USE_ITEM;
public WrapperPlayClientUseItem() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientUseItem(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
* <p>
* Notes: block position
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
public Direction getFace() {
return handle.getDirections().read(0);
}
public void setFace(Direction value) {
handle.getDirections().write(0, value);
}
public Hand getHand() {
return handle.getHands().read(0);
}
public void setHand(Hand value) {
handle.getHands().write(0, value);
}
/**
* Retrieve Cursor Position X.
* <p>
* Notes: the position of the crosshair on the block, from 0 to 15
* increasing from west to east
*
* @return The current Cursor Position X
*/
public float getCursorPositionX() {
return handle.getFloat().read(0);
}
/**
* Set Cursor Position X.
*
* @param value - new value.
*/
public void setCursorPositionX(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Cursor Position Y.
* <p>
* Notes: the position of the crosshair on the block, from 0 to 15
* increasing from bottom to top
*
* @return The current Cursor Position Y
*/
public float getCursorPositionY() {
return handle.getFloat().read(1);
}
/**
* Set Cursor Position Y.
*
* @param value - new value.
*/
public void setCursorPositionY(float value) {
handle.getFloat().write(1, value);
}
/**
* Retrieve Cursor Position Z.
* <p>
* Notes: the position of the crosshair on the block, from 0 to 15
* increasing from north to south
*
* @return The current Cursor Position Z
*/
public float getCursorPositionZ() {
return handle.getFloat().read(2);
}
/**
* Set Cursor Position Z.
*
* @param value - new value.
*/
public void setCursorPositionZ(float value) {
handle.getFloat().write(2, value);
}
}
@@ -0,0 +1,137 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientVehicleMove extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.VEHICLE_MOVE;
public WrapperPlayClientVehicleMove() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientVehicleMove(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve X.
* <p>
* Notes: absolute position (X coordinate)
*
* @return The current X
*/
public double getX() {
return handle.getDoubles().read(0);
}
/**
* Set X.
*
* @param value - new value.
*/
public void setX(double value) {
handle.getDoubles().write(0, value);
}
/**
* Retrieve Y.
* <p>
* Notes: absolute position (Y coordinate)
*
* @return The current Y
*/
public double getY() {
return handle.getDoubles().read(1);
}
/**
* Set Y.
*
* @param value - new value.
*/
public void setY(double value) {
handle.getDoubles().write(1, value);
}
/**
* Retrieve Z.
* <p>
* Notes: absolute position (Z coordinate)
*
* @return The current Z
*/
public double getZ() {
return handle.getDoubles().read(2);
}
/**
* Set Z.
*
* @param value - new value.
*/
public void setZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve Yaw.
* <p>
* Notes: absolute rotation on the vertical axis, in degrees
*
* @return The current Yaw
*/
public float getYaw() {
return handle.getFloat().read(0);
}
/**
* Set Yaw.
*
* @param value - new value.
*/
public void setYaw(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Pitch.
* <p>
* Notes: absolute rotation on the horizontal axis, in degrees
*
* @return The current Pitch
*/
public float getPitch() {
return handle.getFloat().read(1);
}
/**
* Set Pitch.
*
* @param value - new value.
*/
public void setPitch(float value) {
handle.getFloat().write(1, value);
}
}
@@ -0,0 +1,148 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.inventory.ItemStack;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayClientWindowClick extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Client.WINDOW_CLICK;
public WrapperPlayClientWindowClick() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayClientWindowClick(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window ID.
* <p>
* Notes: the id of the window which was clicked. 0 for player inventory.
*
* @return The current Window ID
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window ID.
*
* @param value - new value.
*/
public void setWindowId(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Slot.
* <p>
* Notes: the clicked slot. See below.
*
* @return The current Slot
*/
public int getSlot() {
return handle.getIntegers().read(1);
}
/**
* Set Slot.
*
* @param value - new value.
*/
public void setSlot(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Button.
* <p>
* Notes: the button used in the click. See below.
*
* @return The current Button
*/
public int getButton() {
return handle.getIntegers().read(2);
}
/**
* Set Button.
*
* @param value - new value.
*/
public void setButton(int value) {
handle.getIntegers().write(2, value);
}
/**
* Retrieve Action number.
* <p>
* Notes: a unique number for the action, used for transaction handling (See
* the Transaction packet).
*
* @return The current Action number
*/
public short getActionNumber() {
return handle.getShorts().read(0);
}
/**
* Set Action number.
*
* @param value - new value.
*/
public void setActionNumber(short value) {
handle.getShorts().write(0, value);
}
/**
* Retrieve Clicked item.
*
* @return The current Clicked item
*/
public ItemStack getClickedItem() {
return handle.getItemModifier().read(0);
}
/**
* Set Clicked item.
*
* @param value - new value.
*/
public void setClickedItem(ItemStack value) {
handle.getItemModifier().write(0, value);
}
public InventoryClickType getShift() {
return handle.getEnumModifier(InventoryClickType.class, 5).read(0);
}
public void setShift(InventoryClickType value) {
handle.getEnumModifier(InventoryClickType.class, 5).write(0, value);
}
public enum InventoryClickType {
PICKUP, QUICK_MOVE, SWAP, CLONE, THROW, QUICK_CRAFT, PICKUP_ALL;
}
}
@@ -0,0 +1,99 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerAbilities extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ABILITIES;
public WrapperPlayServerAbilities() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerAbilities(PacketContainer packet) {
super(packet, TYPE);
}
public boolean isInvulnerable() {
return handle.getBooleans().read(0);
}
public void setInvulnerable(boolean value) {
handle.getBooleans().write(0, value);
}
/**Misspelled.
* @see #isInvulnerable()
*/
@Deprecated
public boolean isInvulnurable() {
return handle.getBooleans().read(0);
}
/**Misspelled.
* @see #setInvulnerable(boolean)
*/
@Deprecated
public void setInvulnurable(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean isFlying() {
return handle.getBooleans().read(1);
}
public void setFlying(boolean value) {
handle.getBooleans().write(1, value);
}
public boolean canFly() {
return handle.getBooleans().read(2);
}
public void setCanFly(boolean value) {
handle.getBooleans().write(2, value);
}
public boolean canInstantlyBuild() {
return handle.getBooleans().read(3);
}
public void setCanInstantlyBuild(boolean value) {
handle.getBooleans().write(3, value);
}
public float getFlyingSpeed() {
return handle.getFloat().read(0);
}
public void setFlyingSpeed(float value) {
handle.getFloat().write(0, value);
}
public float getWalkingSpeed() {
return handle.getFloat().read(1);
}
public void setWalkingSpeed(float value) {
handle.getFloat().write(1, value);
}
}
@@ -0,0 +1,148 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.*;
import org.bukkit.advancement.Advancement;
import org.bukkit.inventory.ItemStack;
import static com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass;
public class WrapperPlayServerAdvancements extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ADVANCEMENTS;
public WrapperPlayServerAdvancements() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerAdvancements(PacketContainer packet) {
super(packet, TYPE);
}
public static class SerializedAdvancement {
public MinecraftKey key;
public Advancement advancement;
public AdvancementDisplay display;
public Object rewards;
public Map<String, Object> criteria;
public String[][] requirements;
}
public static class AdvancementDisplay {
public WrappedChatComponent title;
public WrappedChatComponent description;
public ItemStack icon;
public MinecraftKey background;
public FrameType frame;
public boolean showToast;
public boolean announceToChat;
public boolean hidden;
public float xCoord;
public float yCoord;
}
public enum FrameType {
TASK,
CHALLENGE,
GOAL
}
public static class AdvancementProgress {
public Map<String, CriterionProgress> progress;
public String[][] array2d;
}
public static class CriterionProgress {
public AdvancementProgress progress;
public Date date;
}
private static final AutoWrapper<AdvancementDisplay> DISPLAY = AutoWrapper
.wrap(AdvancementDisplay.class, "AdvancementDisplay")
.field(0, BukkitConverters.getWrappedChatComponentConverter())
.field(1, BukkitConverters.getWrappedChatComponentConverter())
.field(2, BukkitConverters.getItemStackConverter())
.field(3, MinecraftKey.getConverter())
.field(4, EnumWrappers.getGenericConverter(getMinecraftClass("AdvancementFrameType"), FrameType.class));
private static final AutoWrapper<SerializedAdvancement> WRAPPER = AutoWrapper
.wrap(SerializedAdvancement.class,"Advancement$SerializedAdvancement")
.field(0, MinecraftKey.getConverter())
.field(1, BukkitConverters.getAdvancementConverter())
.field(2, DISPLAY);
private static final AutoWrapper<CriterionProgress> CRITERION = AutoWrapper
.wrap(CriterionProgress.class, "CriterionProgress");
private static final AutoWrapper<AdvancementProgress> PROGRESS = AutoWrapper
.wrap(AdvancementProgress.class, "AdvancementProgress")
.field(0, BukkitConverters.getMapConverter(Converters.passthrough(String.class), CRITERION));
static {
CRITERION.field(0, PROGRESS);
}
/**
* Retrieve Reset/Clear.
* <p>
* Notes: whether to reset/clear the current advancements
* @return The current Reset/Clear
*/
public boolean isReset() {
return handle.getBooleans().read(0);
}
/**
* Set Reset/Clear.
* @param value - new value.
*/
public void setReset(boolean value) {
handle.getBooleans().write(0, value);
}
public Optional<Map<MinecraftKey, SerializedAdvancement>> getAdvancements() {
return handle.getMaps(MinecraftKey.getConverter(), WRAPPER).optionRead(0);
}
public void setAdvancements(Map<MinecraftKey, SerializedAdvancement> value) {
handle.getMaps(MinecraftKey.getConverter(), WRAPPER).writeSafely(0, value);
}
public Optional<Set<MinecraftKey>> getKeys() {
return handle.getSets(MinecraftKey.getConverter()).optionRead(0);
}
public void setKeys(Set<MinecraftKey> value) {
handle.getSets(MinecraftKey.getConverter()).writeSafely(0, value);
}
public Optional<Map<MinecraftKey, AdvancementProgress>> getProgress() {
return handle.getMaps(MinecraftKey.getConverter(), PROGRESS).optionRead(1);
}
}
@@ -0,0 +1,100 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerAnimation extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ANIMATION;
public WrapperPlayServerAnimation() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerAnimation(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Animation.
* <p>
* Notes: animation ID
*
* @return The current Animation
*/
public int getAnimation() {
return handle.getIntegers().read(1);
}
/**
* Set Animation.
*
* @param value - new value.
*/
public void setAnimation(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,99 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerAttachEntity extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ATTACH_ENTITY;
public WrapperPlayServerAttachEntity() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerAttachEntity(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Vehicle ID.
* <p>
* Notes: vehicle's Entity ID
*
* @return The current Vehicle ID
*/
public int getVehicleId() {
return handle.getIntegers().read(1);
}
/**
* Set Vehicle ID.
*
* @param value - new value.
*/
public void setVehicleId(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,54 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerAutoRecipe extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.AUTO_RECIPE;
public WrapperPlayServerAutoRecipe() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerAutoRecipe(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window ID.
* @return The current Window ID
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window ID.
* @param value - new value.
*/
public void setWindowId(int value) {
handle.getIntegers().write(0, value);
}
// Wrapper for recipe can be created upon request
}
@@ -0,0 +1,101 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayServerBed extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.BED;
public WrapperPlayServerBed() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerBed(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Location.
* <p>
* Notes: block location of the head part of the bed
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
}
@@ -0,0 +1,119 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.Material;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayServerBlockAction extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.BLOCK_ACTION;
public WrapperPlayServerBlockAction() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerBlockAction(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
* <p>
* Notes: block Coordinates
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
/**
* Retrieve Byte 1.
* <p>
* Notes: varies depending on block - see Block_Actions
*
* @return The current Byte 1
*/
public int getByte1() {
return handle.getIntegers().read(0);
}
/**
* Set Byte 1.
*
* @param value - new value.
*/
public void setByte1(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Byte 2.
* <p>
* Notes: varies depending on block - see Block_Actions
*
* @return The current Byte 2
*/
public int getByte2() {
return handle.getIntegers().read(1);
}
/**
* Set Byte 2.
*
* @param value - new value.
*/
public void setByte2(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Block Type.
* <p>
* Notes: the block type for the block
*
* @return The current Block Type
*/
public Material getBlockType() {
return handle.getBlocks().read(0);
}
/**
* Set Block Type.
*
* @param value - new value.
*/
public void setBlockType(Material value) {
handle.getBlocks().write(0, value);
}
}
@@ -0,0 +1,122 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayServerBlockBreakAnimation extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.BLOCK_BREAK_ANIMATION;
public WrapperPlayServerBlockBreakAnimation() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerBlockBreakAnimation(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Location.
* <p>
* Notes: block Position
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
/**
* Retrieve Destroy Stage.
* <p>
* Notes: 0 - 9
*
* @return The current Destroy Stage
*/
public int getDestroyStage() {
return handle.getIntegers().read(1);
}
/**
* Set Destroy Stage.
*
* @param value - new value.
*/
public void setDestroyStage(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,88 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.Location;
import org.bukkit.World;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.WrappedBlockData;
public class WrapperPlayServerBlockChange extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.BLOCK_CHANGE;
public WrapperPlayServerBlockChange() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerBlockChange(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
* <p>
* Notes: block Coordinates
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
/**
* Retrieve the Bukkit Location.
*
* @param world World for the location
* @return Bukkit Location
*/
public Location getBukkitLocation(World world) {
return getLocation().toVector().toLocation(world);
}
/**
* Retrieve Block Data.
*
* @return The current Block Data
*/
public WrappedBlockData getBlockData() {
return handle.getBlockData().read(0);
}
/**
* Set Block Data.
*
* @param value - new value.
*/
public void setBlockData(WrappedBlockData value) {
handle.getBlockData().write(0, value);
}
}
@@ -0,0 +1,133 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.UUID;
import org.bukkit.boss.BarColor;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
public class WrapperPlayServerBoss extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.BOSS;
public WrapperPlayServerBoss() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerBoss(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve UUID.
* <p>
* Notes: unique ID for this bar
*
* @return The current UUID
*/
public UUID getUniqueId() {
return handle.getUUIDs().read(0);
}
/**
* Set UUID.
*
* @param value - new value.
*/
public void setUniqueId(UUID value) {
handle.getUUIDs().write(0, value);
}
public Action getAction() {
return handle.getEnumModifier(Action.class, 1).read(0);
}
public void setAction(Action value) {
handle.getEnumModifier(Action.class, 1).write(0, value);
}
public WrappedChatComponent getTitle() {
return handle.getChatComponents().read(0);
}
public void setTitle(WrappedChatComponent value) {
handle.getChatComponents().write(0, value);
}
public float getHealth() {
return handle.getFloat().read(0);
}
public void setHealth(float value) {
handle.getFloat().write(0, value);
}
public BarColor getColor() {
return handle.getEnumModifier(BarColor.class, 4).read(0);
}
public void setColor(BarColor value) {
handle.getEnumModifier(BarColor.class, 4).write(0, value);
}
public BarStyle getStyle() {
return handle.getEnumModifier(BarStyle.class, 5).read(0);
}
public void setStyle(BarStyle value) {
handle.getEnumModifier(BarStyle.class, 5).write(0, value);
}
public boolean isDarkenSky() {
return handle.getBooleans().read(0);
}
public void setDarkenSky(boolean value) {
handle.getBooleans().write(0, value);
}
public boolean isPlayMusic() {
return handle.getBooleans().read(1);
}
public void setPlayMusic(boolean value) {
handle.getBooleans().write(1, value);
}
public boolean isCreateFog() {
return handle.getBooleans().read(2);
}
public void setCreateFog(boolean value) {
handle.getBooleans().write(2, value);
}
public static enum Action {
ADD, REMOVE, UPDATE_PCT, UPDATE_NAME, UPDATE_STYLE, UPDATE_PROPERTIES;
}
public static enum BarStyle {
PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12, NOTCHED_20;
}
}
@@ -0,0 +1,54 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerCamera extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.CAMERA;
public WrapperPlayServerCamera() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCamera(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Camera ID.
*
* @return The current Camera ID
*/
public int getCameraId() {
return handle.getIntegers().read(0);
}
/**
* Set Camera ID.
*
* @param value - new value.
*/
public void setCameraId(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,104 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.Arrays;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.EnumWrappers.ChatType;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
public class WrapperPlayServerChat extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.CHAT;
public WrapperPlayServerChat() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerChat(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve the chat message.
* <p>
* Limited to 32767 bytes
*
* @return The current message
*/
public WrappedChatComponent getMessage() {
return handle.getChatComponents().read(0);
}
/**
* Set the message.
*
* @param value - new value.
*/
public void setMessage(WrappedChatComponent value) {
handle.getChatComponents().write(0, value);
}
public ChatType getChatType() {
return handle.getChatTypes().read(0);
}
public void setChatType(ChatType type) {
handle.getChatTypes().write(0, type);
}
/**
* Retrieve Position.
* <p>
* Notes: 0 - Chat (chat box) ,1 - System Message (chat box), 2 - Above
* action bar
*
* @return The current Position
* @deprecated Magic values replaced by enum
*/
@Deprecated
public byte getPosition() {
Byte position = handle.getBytes().readSafely(0);
if (position != null) {
return position;
} else {
return getChatType().getId();
}
}
/**
* Set Position.
*
* @param value - new value.
* @deprecated Magic values replaced by enum
*/
@Deprecated
public void setPosition(byte value) {
handle.getBytes().writeSafely(0, value);
if (EnumWrappers.getChatTypeClass() != null)
{
Arrays.stream(ChatType.values()).filter(t -> t.getId() == value).findAny()
.ifPresent(t -> handle.getChatTypes().writeSafely(0, t));
}
}
}
@@ -0,0 +1,56 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerCloseWindow extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.CLOSE_WINDOW;
public WrapperPlayServerCloseWindow() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCloseWindow(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window ID.
* <p>
* Notes: this is the id of the window that was closed. 0 for inventory.
*
* @return The current Window ID
*/
public int getWindowId() {
return handle.getIntegers().read(0);
}
/**
* Set Window ID.
*
* @param value - new value.
*/
public void setWindowId(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,72 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerCollect extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.COLLECT;
public WrapperPlayServerCollect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCollect(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Collected Entity ID.
*
* @return The current Collected Entity ID
*/
public int getCollectedEntityId() {
return handle.getIntegers().read(0);
}
/**
* Set Collected Entity ID.
*
* @param value - new value.
*/
public void setCollectedEntityId(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Collector Entity ID.
*
* @return The current Collector Entity ID
*/
public int getCollectorEntityId() {
return handle.getIntegers().read(1);
}
/**
* Set Collector Entity ID.
*
* @param value - new value.
*/
public void setCollectorEntityId(int value) {
handle.getIntegers().write(1, value);
}
}
@@ -0,0 +1,136 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.CombatEventType;
public class WrapperPlayServerCombatEvent extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.COMBAT_EVENT;
public WrapperPlayServerCombatEvent() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCombatEvent(PacketContainer packet) {
super(packet, TYPE);
}
// ---- All
/**
* Retrieve Event.
* <p>
* Notes: 0 ENTER_COMBAT, 1 END_COMBAT, 2 ENTITY_DEAD
*
* @return The current Event
*/
public CombatEventType getEvent() {
return handle.getCombatEvents().read(0);
}
/**
* Set Event.
*
* @param value - new value.
*/
public void setEvent(CombatEventType value) {
handle.getCombatEvents().write(0, value);
}
// ---- END_COMBAT
public int getDuration() {
if (getEvent() != CombatEventType.END_COMBAT)
throw new IllegalStateException(
"Duration only exists for END_COMBAT");
return handle.getIntegers().read(0);
}
public void setDuration(int value) {
if (getEvent() != CombatEventType.END_COMBAT)
throw new IllegalStateException(
"Duration only exists for END_COMBAT");
handle.getIntegers().write(0, value);
}
// ---- ENTITY_DIED
public int getPlayerID() {
if (getEvent() != CombatEventType.ENTITY_DIED)
throw new IllegalStateException(
"Player ID only exists for ENTITY_DEAD");
return handle.getIntegers().read(0);
}
public void setPlayerId(int value) {
if (getEvent() != CombatEventType.ENTITY_DIED)
throw new IllegalStateException(
"Player ID only exists for ENTITY_DEAD");
handle.getIntegers().write(0, value);
}
public int getEntityID() {
CombatEventType event = getEvent();
switch (event) {
case END_COMBAT:
case ENTITY_DIED:
return handle.getIntegers().read(1);
default:
throw new IllegalStateException("Entity ID does not exist for "
+ event);
}
}
public void setEntityId(int value) {
CombatEventType event = getEvent();
switch (event) {
case END_COMBAT:
case ENTITY_DIED:
handle.getIntegers().write(1, value);
default:
throw new IllegalStateException("Entity ID does not exist for "
+ event);
}
}
public String getMessage() {
if (getEvent() != CombatEventType.ENTITY_DIED)
throw new IllegalStateException(
"Message only exists for ENTITY_DEAD");
return handle.getStrings().read(0);
}
public void setMessage(String value) {
if (getEvent() != CombatEventType.ENTITY_DIED)
throw new IllegalStateException(
"Message only exists for ENTITY_DEAD");
handle.getStrings().write(0, value);
}
}
@@ -0,0 +1,49 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.mojang.brigadier.tree.RootCommandNode;
public class WrapperPlayServerCommands extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.COMMANDS;
public WrapperPlayServerCommands() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCommands(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Mojang's brigadier library isn't versioned inside craftbukkit,
* so it should be safe to use here.
*/
public RootCommandNode getRoot() {
return (RootCommandNode) handle.getModifier().read(0);
}
public void setRoot(RootCommandNode node) {
handle.getModifier().write(0, node);
}
}
@@ -0,0 +1,103 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.MinecraftKey;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class WrapperPlayServerCustomPayload extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.CUSTOM_PAYLOAD;
public WrapperPlayServerCustomPayload() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCustomPayload(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Channel.
* <p>
* Notes: name of the "channel" used to send the data.
*
* @return The current Channel
*/
public MinecraftKey getChannel() {
return handle.getMinecraftKeys().read(0);
}
/**
* Starting in 1.13, channel names need to be lower case, in the new identifier format,
* i.e. {@code minecraft:brand}. The previously standard {@code |} is no longer allowed.
*/
public void setChannel(MinecraftKey value) {
handle.getMinecraftKeys().write(0, value);
}
/**
* Retrieve payload contents as a raw Netty buffer
*
* @return Payload contents as a Netty buffer
*/
public ByteBuf getContentsBuffer() {
return (ByteBuf) handle.getModifier().withType(ByteBuf.class).read(0);
}
/**
* Retrieve payload contents
*
* @return Payload contents as a byte array
*/
public byte[] getContents() {
ByteBuf buffer = getContentsBuffer();
byte[] array = new byte[buffer.readableBytes()];
buffer.readBytes(array);
return array;
}
/**
* Update payload contents with a Netty buffer
*
* @param contents - new payload content
*/
public void setContentsBuffer(ByteBuf contents) {
if (MinecraftReflection.is(MinecraftReflection.getPacketDataSerializerClass(), contents)) {
handle.getModifier().withType(ByteBuf.class).write(0, contents);
} else {
Object serializer = MinecraftReflection.getPacketDataSerializer(contents);
handle.getModifier().withType(ByteBuf.class).write(0, serializer);
}
}
/**
* Update payload contents with a byte array
*
* @param content - new payload content
*/
public void setContents(byte[] content) {
setContentsBuffer(Unpooled.copiedBuffer(content));
}
}
@@ -0,0 +1,183 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
import com.comphenix.protocol.wrappers.MinecraftKey;
public class WrapperPlayServerCustomSoundEffect extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.CUSTOM_SOUND_EFFECT;
public WrapperPlayServerCustomSoundEffect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerCustomSoundEffect(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Sound Name.
* <p>
* Notes: all known sound effect names can be seen here.
*
* @return The current Sound Name
*/
public MinecraftKey getSoundName() {
return handle.getMinecraftKeys().read(0);
}
/**
* Set Sound Name.
*
* @param value - new value.
*/
public void setSoundName(MinecraftKey value) {
handle.getMinecraftKeys().write(0, value);
}
/**
* Retrieve Sound Category.
* <p>
* Notes: the category that this sound will be played from (current
* categories)
*
* @return The current Sound Category
*/
public SoundCategory getSoundCategory() {
return handle.getSoundCategories().read(0);
}
/**
* Set Sound Category.
*
* @param value - new value.
*/
public void setSoundCategory(SoundCategory value) {
handle.getSoundCategories().write(0, value);
}
/**
* Retrieve Effect Position X.
* <p>
* Notes: effect X multiplied by 8 (fixed-point number with only 3 bits
* dedicated to the fractional part)
*
* @return The current Effect Position X
*/
public int getX() {
return handle.getIntegers().read(0);
}
/**
* Set Effect Position X.
*
* @param value - new value.
*/
public void setX(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Effect Position Y.
* <p>
* Notes: effect Y multiplied by 8 (fixed-point number with only 3 bits
* dedicated to the fractional part)
*
* @return The current Effect Position Y
*/
public int getY() {
return handle.getIntegers().read(1);
}
/**
* Set Effect Position Y.
*
* @param value - new value.
*/
public void setY(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Effect Position Z.
* <p>
* Notes: effect Z multiplied by 8 (fixed-point number with only 3 bits
* dedicated to the fractional part)
*
* @return The current Effect Position Z
*/
public int getZ() {
return handle.getIntegers().read(2);
}
/**
* Set Effect Position Z.
*
* @param value - new value.
*/
public void setZ(int value) {
handle.getIntegers().write(2, value);
}
/**
* Retrieve Volume.
* <p>
* Notes: 1 is 100%, can be more
*
* @return The current Volume
*/
public float getVolume() {
return handle.getFloat().read(0);
}
/**
* Set Volume.
*
* @param value - new value.
*/
public void setVolume(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Pitch.
* <p>
* Notes: 63 is 100%, can be more
*
* @return The current Pitch
*/
public float getPitch() {
return handle.getFloat().read(1);
}
/**
* Set Pitch.
*
* @param value - new value.
*/
public void setPitch(float value) {
handle.getFloat().write(1, value);
}
}
@@ -0,0 +1,79 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntity extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ENTITY;
public WrapperPlayServerEntity() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntity(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
}
@@ -0,0 +1,67 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerEntityDestroy extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ENTITY_DESTROY;
public WrapperPlayServerEntityDestroy() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityDestroy(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Count.
* <p>
* Notes: length of following array
*
* @return The current Count
*/
public int getCount() {
return handle.getIntegerArrays().read(0).length;
}
/**
* Retrieve Entity IDs.
* <p>
* Notes: the list of entities of destroy
*
* @return The current Entity IDs
*/
public int[] getEntityIDs() {
return handle.getIntegerArrays().read(0);
}
/**
* Set Entity IDs.
*
* @param value - new value.
*/
public void setEntityIds(int[] value) {
handle.getIntegerArrays().write(0, value);
}
}
@@ -0,0 +1,154 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntityEffect extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ENTITY_EFFECT;
public WrapperPlayServerEntityEffect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityEffect(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Effect ID.
* <p>
* Notes: see [[1]]
*
* @return The current Effect ID
*/
public byte getEffectID() {
return handle.getBytes().read(0);
}
/**
* Set Effect ID.
*
* @param value - new value.
*/
public void setEffectID(byte value) {
handle.getBytes().write(0, (byte) (value & 255));
}
/**
* Retrieve Amplifier.
*
* @return The current Amplifier
*/
public byte getAmplifier() {
return handle.getBytes().read(1);
}
/**
* Set Amplifier.
*
* @param value - new value.
*/
public void setAmplifier(byte value) {
handle.getBytes().write(1, (byte) (value & 255));
}
/**
* Retrieve Duration.
*
* @return The current Duration
*/
public int getDuration() {
return handle.getIntegers().read(1);
}
/**
* Set Duration.
*
* @param value - new value.
*/
public void setDuration(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Hide Particles.
*
* @return The current Hide Particles
*/
public boolean getHideParticles() {
return handle.getBytes().read(2) == 0;
}
/**
* Set Hide Particles.
*
* @param value - new value.
*/
public void setHideParticles(boolean value) {
handle.getBytes().write(2, (byte) (value ? 0 : 1));
}
}
@@ -0,0 +1,110 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot;
public class WrapperPlayServerEntityEquipment extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.ENTITY_EQUIPMENT;
public WrapperPlayServerEntityEquipment() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityEquipment(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
public ItemSlot getSlot() {
return handle.getItemSlots().read(0);
}
public void setSlot(ItemSlot value) {
handle.getItemSlots().write(0, value);
}
/**
* Retrieve Item.
* <p>
* Notes: item in slot format
*
* @return The current Item
*/
public ItemStack getItem() {
return handle.getItemModifier().read(0);
}
/**
* Set Item.
*
* @param value - new value.
*/
public void setItem(ItemStack value) {
handle.getItemModifier().write(0, value);
}
}
@@ -0,0 +1,100 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntityHeadRotation extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.ENTITY_HEAD_ROTATION;
public WrapperPlayServerEntityHeadRotation() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityHeadRotation(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Head Yaw.
* <p>
* Notes: head yaw in steps of 2p/256
*
* @return The current Head Yaw
*/
public byte getHeadYaw() {
return handle.getBytes().read(0);
}
/**
* Set Head Yaw.
*
* @param value - new value.
*/
public void setHeadYaw(byte value) {
handle.getBytes().write(0, value);
}
}
@@ -0,0 +1,133 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntityLook extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ENTITY_LOOK;
public WrapperPlayServerEntityLook() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityLook(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve the yaw of the current entity.
*
* @return The current Yaw
*/
public float getYaw() {
return (handle.getBytes().read(0) * 360.F) / 256.0F;
}
/**
* Set the yaw of the current entity.
*
* @param value - new yaw.
*/
public void setYaw(float value) {
handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F));
}
/**
* Retrieve the pitch of the current entity.
*
* @return The current pitch
*/
public float getPitch() {
return (handle.getBytes().read(1) * 360.F) / 256.0F;
}
/**
* Set the pitch of the current entity.
*
* @param value - new pitch.
*/
public void setPitch(float value) {
handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F));
}
/**
* Retrieve On Ground.
*
* @return The current On Ground
*/
public boolean getOnGround() {
return handle.getBooleans().read(0);
}
/**
* Set On Ground.
*
* @param value - new value.
*/
public void setOnGround(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,101 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
public class WrapperPlayServerEntityMetadata extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.ENTITY_METADATA;
public WrapperPlayServerEntityMetadata() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityMetadata(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Metadata.
*
* @return The current Metadata
*/
public List<WrappedWatchableObject> getMetadata() {
return handle.getWatchableCollectionModifier().read(0);
}
/**
* Set Metadata.
*
* @param value - new value.
*/
public void setMetadata(List<WrappedWatchableObject> value) {
handle.getWatchableCollectionModifier().write(0, value);
}
}
@@ -0,0 +1,99 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntityStatus extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.ENTITY_STATUS;
public WrapperPlayServerEntityStatus() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityStatus(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Entity Status.
* <p>
* Notes: see below
*
* @return The current Entity Status
*/
public byte getEntityStatus() {
return handle.getBytes().read(0);
}
/**
* Set Entity Status.
*
* @param value - new value.
*/
public void setEntityStatus(byte value) {
handle.getBytes().write(0, value);
}
}
@@ -0,0 +1,146 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntityTeleport extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.ENTITY_TELEPORT;
public WrapperPlayServerEntityTeleport() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityTeleport(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve entity ID.
*
* @return The current EID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity.
*
* @param world - the current world of the entity.
* @return The entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity.
*
* @param event - the packet event.
* @return The entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
public double getX() {
return handle.getDoubles().read(0);
}
public void setX(double value) {
handle.getDoubles().write(0, value);
}
public double getY() {
return handle.getDoubles().read(1);
}
public void setY(double value) {
handle.getDoubles().write(1, value);
}
public double getZ() {
return handle.getDoubles().read(2);
}
public void setZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve the yaw of the current entity.
*
* @return The current Yaw
*/
public float getYaw() {
return (handle.getBytes().read(0) * 360.F) / 256.0F;
}
/**
* Set the yaw of the current entity.
*
* @param value - new yaw.
*/
public void setYaw(float value) {
handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F));
}
/**
* Retrieve the pitch of the current entity.
*
* @return The current pitch
*/
public float getPitch() {
return (handle.getBytes().read(1) * 360.F) / 256.0F;
}
/**
* Set the pitch of the current entity.
*
* @param value - new pitch.
*/
public void setPitch(float value) {
handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F));
}
public boolean getOnGround() {
return handle.getBooleans().read(0);
}
public void setOnGround(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,134 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerEntityVelocity extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.ENTITY_VELOCITY;
public WrapperPlayServerEntityVelocity() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerEntityVelocity(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve the velocity in the x axis.
*
* @return The current velocity X
*/
public double getVelocityX() {
return handle.getIntegers().read(1) / 8000.0D;
}
/**
* Set the velocity in the x axis.
*
* @param value - new value.
*/
public void setVelocityX(double value) {
handle.getIntegers().write(1, (int) (value * 8000.0D));
}
/**
* Retrieve the velocity in the y axis.
*
* @return The current velocity y
*/
public double getVelocityY() {
return handle.getIntegers().read(2) / 8000.0D;
}
/**
* Set the velocity in the y axis.
*
* @param value - new value.
*/
public void setVelocityY(double value) {
handle.getIntegers().write(2, (int) (value * 8000.0D));
}
/**
* Retrieve the velocity in the z axis.
*
* @return The current velocity z
*/
public double getVelocityZ() {
return handle.getIntegers().read(3) / 8000.0D;
}
/**
* Set the velocity in the z axis.
*
* @param value - new value.
*/
public void setVelocityZ(double value) {
handle.getIntegers().write(3, (int) (value * 8000.0D));
}
}
@@ -0,0 +1,92 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerExperience extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.EXPERIENCE;
public WrapperPlayServerExperience() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerExperience(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Experience bar.
* <p>
* Notes: between 0 and 1
*
* @return The current Experience bar
*/
public float getExperienceBar() {
return handle.getFloat().read(0);
}
/**
* Set Experience bar.
*
* @param value - new value.
*/
public void setExperienceBar(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Level.
*
* @return The current Level
*/
public int getLevel() {
return handle.getIntegers().read(1);
}
/**
* Set Level.
*
* @param value - new value.
*/
public void setLevel(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Total Experience.
*
* @return The current Total Experience
*/
public int getTotalExperience() {
return handle.getIntegers().read(0);
}
/**
* Set Total Experience.
*
* @param value - new value.
*/
public void setTotalExperience(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,171 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.List;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayServerExplosion extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.EXPLOSION;
public WrapperPlayServerExplosion() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerExplosion(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve X.
*
* @return The current X
*/
public double getX() {
return handle.getDoubles().read(0);
}
/**
* Set X.
*
* @param value - new value.
*/
public void setX(double value) {
handle.getDoubles().write(0, value);
}
/**
* Retrieve Y.
*
* @return The current Y
*/
public double getY() {
return handle.getDoubles().read(1);
}
/**
* Set Y.
*
* @param value - new value.
*/
public void setY(double value) {
handle.getDoubles().write(1, value);
}
/**
* Retrieve Z.
*
* @return The current Z
*/
public double getZ() {
return handle.getDoubles().read(2);
}
/**
* Set Z.
*
* @param value - new value.
*/
public void setZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve Radius.
* <p>
* Notes: currently unused in the client
*
* @return The current Radius
*/
public float getRadius() {
return handle.getFloat().read(0);
}
/**
* Set Radius.
*
* @param value - new value.
*/
public void setRadius(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Record count.
* <p>
* Notes: this is the count, not the size. The size is 3 times this value.
*
* @return The current Record count
*/
public List<BlockPosition> getRecords() {
return handle.getBlockPositionCollectionModifier().read(0);
}
/**
* Retrieve Record count.
* <p>
* Notes: this is the count, not the size. The size is 3 times this value.
*
* @return The current Record count
* @deprecated Misspelled.
* @see #getRecords()
*/
@Deprecated
public List<BlockPosition> getRecors() {
return handle.getBlockPositionCollectionModifier().read(0);
}
/**
* Set Record count.
*
* @param value - new value.
*/
public void setRecords(List<BlockPosition> value) {
handle.getBlockPositionCollectionModifier().write(0, value);
}
public float getPlayerVelocityX() {
return handle.getFloat().read(0);
}
public void setPlayerVelocityX(float value) {
handle.getFloat().write(0, value);
}
public float getPlayerVelocityY() {
return handle.getFloat().read(1);
}
public void setPlayerVelocityY(float value) {
handle.getFloat().write(1, value);
}
public float getPlayerVelocityZ() {
return handle.getFloat().read(2);
}
public void setPlayerVelocityZ(float value) {
handle.getFloat().write(2, value);
}
}
@@ -0,0 +1,75 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerGameStateChange extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.GAME_STATE_CHANGE;
public WrapperPlayServerGameStateChange() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerGameStateChange(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Reason.
*
* @return The current Reason
*/
public int getReason() {
return handle.getIntegers().read(0);
}
/**
* Set Reason.
*
* @param value - new value.
*/
public void setReason(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Value.
* <p>
* Notes: depends on reason
*
* @return The current Value
*/
public float getValue() {
return handle.getFloat().read(0);
}
/**
* Set Value.
*
* @param value - new value.
*/
public void setValue(float value) {
handle.getFloat().write(0, value);
}
}
@@ -0,0 +1,56 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerHeldItemSlot extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.HELD_ITEM_SLOT;
public WrapperPlayServerHeldItemSlot() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerHeldItemSlot(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Slot.
* <p>
* Notes: the slot which the player has selected (0-8)
*
* @return The current Slot
*/
public int getSlot() {
return handle.getIntegers().read(0);
}
/**
* Set Slot.
*
* @param value - new value.
*/
public void setSlot(int value) {
handle.getIntegers().write(0, value);
}
}
@@ -0,0 +1,54 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerKeepAlive extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.KEEP_ALIVE;
public WrapperPlayServerKeepAlive() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerKeepAlive(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Keep Alive ID.
*
* @return The current Keep Alive ID
*/
public long getKeepAliveId() {
return handle.getLongs().read(0);
}
/**
* Set Keep Alive ID.
*
* @param value - new value.
*/
public void setKeepAliveId(long value) {
handle.getLongs().write(0, value);
}
}
@@ -0,0 +1,59 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
public class WrapperPlayServerKickDisconnect extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.KICK_DISCONNECT;
public WrapperPlayServerKickDisconnect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerKickDisconnect(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Reason.
* <p>
* Notes: displayed to the client when the connection terminates. Must be
* valid JSON.
*
* @return The current Reason
*/
public WrappedChatComponent getReason() {
return handle.getChatComponents().read(0);
}
/**
* Set Reason.
*
* @param value - new value.
*/
public void setReason(WrappedChatComponent value) {
handle.getChatComponents().write(0, value);
}
}
@@ -0,0 +1,201 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
public class WrapperPlayServerLogin extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.LOGIN;
public WrapperPlayServerLogin() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerLogin(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Gamemode.
* <p>
* Notes: 0: survival, 1: creative, 2: adventure. Bit 3 (0x8) is the
* hardcore flag
*
* @return The current Gamemode
*/
public NativeGameMode getGamemode() {
return handle.getGameModes().read(0);
}
/**
* Set Gamemode.
*
* @param value - new value.
*/
public void setGamemode(NativeGameMode value) {
handle.getGameModes().write(0, value);
}
/**
* Retrieve Dimension.
* <p>
* Notes: -1: nether, 0: overworld, 1: end
*
* @return The current Dimension
*/
public int getDimension() {
return handle.getIntegers().read(0);
}
/**
* Set Dimension.
*
* @param value - new value.
*/
public void setDimension(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Difficulty.
* <p>
* Notes: 0 thru 3 for Peaceful, Easy, Normal, Hard
*
* @return The current Difficulty
*/
public Difficulty getDifficulty() {
return handle.getDifficulties().read(0);
}
/**
* Set Difficulty.
*
* @param value - new value.
*/
public void setDifficulty(Difficulty value) {
handle.getDifficulties().write(0, value);
}
/**
* Retrieve Max Players.
* <p>
* Notes: used by the client to draw the player list
*
* @return The current Max Players
*/
public int getMaxPlayers() {
return handle.getIntegers().read(1);
}
/**
* Set Max Players.
*
* @param value - new value.
*/
public void setMaxPlayers(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Level Type.
* <p>
* Notes: default, flat, largeBiomes, amplified, default_1_1
*
* @return The current Level Type
*/
public WorldType getLevelType() {
return handle.getWorldTypeModifier().read(0);
}
/**
* Set Level Type.
*
* @param value - new value.
*/
public void setLevelType(WorldType value) {
handle.getWorldTypeModifier().write(0, value);
}
/**
* Retrieve Reduced Debug Info.
*
* @return The current Reduced Debug Info
*/
public boolean getReducedDebugInfo() {
return handle.getBooleans().read(0);
}
/**
* Set Reduced Debug Info.
*
* @param value - new value.
*/
public void setReducedDebugInfo(boolean value) {
handle.getBooleans().write(0, value);
}
}
@@ -0,0 +1,194 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
* <p>
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.utility.MinecraftReflection;
import org.bukkit.World;
import org.bukkit.entity.Entity;
public class WrapperPlayServerLookAt extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.LOOK_AT;
public WrapperPlayServerLookAt() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerLookAt(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Feet/eyes.
* <p>
* Notes: values are feet=0, eyes=1. If set to eyes, aims using the head position; otherwise aims using the feet position.
* @return The current Feet/eyes
*/
public Anchor getAnchor() {
return handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor"))
.readSafely(0);
}
/**
* Set Feet/eyes.
* @param value - new value.
*/
public void setAnchor(Anchor value) {
handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor"))
.writeSafely(0, value);
}
/**
* Retrieve Target x.
* <p>
* Notes: x coordinate of the point to face towards
* @return The current Target x
*/
public double getTargetX() {
return handle.getDoubles().read(0);
}
/**
* Set Target x.
* @param value - new value.
*/
public void setTargetX(double value) {
handle.getDoubles().write(0, value);
}
/**
* Retrieve Target y.
* <p>
* Notes: y coordinate of the point to face towards
* @return The current Target y
*/
public double getTargetY() {
return handle.getDoubles().read(1);
}
/**
* Set Target y.
* @param value - new value.
*/
public void setTargetY(double value) {
handle.getDoubles().write(1, value);
}
/**
* Retrieve Target z.
* <p>
* Notes: z coordinate of the point to face towards
* @return The current Target z
*/
public double getTargetZ() {
return handle.getDoubles().read(2);
}
/**
* Set Target z.
* @param value - new value.
*/
public void setTargetZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve Is entity.
* <p>
* Notes: if true, additional information about an entity is provided.
* @return The current Is entity
*/
public boolean getIsEntity() {
return handle.getBooleans().read(0);
}
/**
* Set Is entity.
* @param value - new value.
*/
public void setIsEntity(boolean value) {
handle.getBooleans().write(0, value);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: only if is entity is true — the entity to face towards
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity involved in this event.
* @param world - the current world of the entity.
* @return The involved entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(6);
}
/**
* Retrieve the entity involved in this event.
* @param event - the packet event.
* @return The involved entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Entity feet/eyes.
* <p>
* Notes: whether to look at the entity's eyes or feet. Same values and meanings as before, just for the entity's head/feet.
* @return The current Entity feet/eyes
*/
public Anchor getEntityAnchor() {
return handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor"))
.readSafely(1);
}
/**
* Set Entity feet/eyes.
* @param value - new value.
*/
public void setEntityAnchor(Anchor value) {
handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor"))
.writeSafely(1, value);
}
public enum Anchor {
FEET,
EYES
}
}
@@ -0,0 +1,129 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
public class WrapperPlayServerMap extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.MAP;
public WrapperPlayServerMap() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerMap(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Item Damage.
* <p>
* Notes: the damage value of the map being modified
*
* @return The current Item Damage
*/
public int getItemDamage() {
return handle.getIntegers().read(0);
}
/**
* Set Item Damage.
*
* @param value - new value.
*/
public void setItemDamage(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Scale.
*
* @return The current Scale
*/
public byte getScale() {
return handle.getBytes().read(0);
}
/**
* Set Scale.
*
* @param value - new value.
*/
public void setScale(byte value) {
handle.getBytes().write(0, value);
}
public boolean getTrackingPosition() {
return handle.getBooleans().read(0);
}
public void setTrackingPosition(boolean value) {
handle.getBooleans().write(0, value);
}
public Object[] getMapIcons() {
return (Object[]) handle.getModifier().read(3);
}
public void setMapIcons(Object[] value) {
handle.getModifier().write(3, value);
}
public int getColumns() {
return handle.getIntegers().read(3);
}
public void setColumns(int value) {
handle.getIntegers().write(3, value);
}
public int getRows() {
return handle.getIntegers().read(4);
}
public void setRows(int value) {
handle.getIntegers().write(4, value);
}
public int getX() {
return handle.getIntegers().read(1);
}
public void setX(int value) {
handle.getIntegers().write(1, value);
}
public int getZ() {
return handle.getIntegers().read(2);
}
public void setZ(int value) {
handle.getIntegers().write(2, value);
}
public byte[] getData() {
return handle.getByteArrays().read(0);
}
public void setData(byte[] value) {
handle.getByteArrays().write(0, value);
}
}
@@ -0,0 +1,138 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.List;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
public class WrapperPlayServerMapChunk extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.MAP_CHUNK;
public WrapperPlayServerMapChunk() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerMapChunk(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Chunk X.
* <p>
* Notes: chunk X coordinate
*
* @return The current Chunk X
*/
public int getChunkX() {
return handle.getIntegers().read(0);
}
/**
* Set Chunk X.
*
* @param value - new value.
*/
public void setChunkX(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Chunk Z.
* <p>
* Notes: chunk Z coordinate
*
* @return The current Chunk Z
*/
public int getChunkZ() {
return handle.getIntegers().read(1);
}
/**
* Set Chunk Z.
*
* @param value - new value.
*/
public void setChunkZ(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Ground-Up continuous.
* <p>
* Notes: this is True if the packet represents all sections in this
* vertical column, where the primary bit map specifies exactly which
* sections are included, and which are air
*
* @return The current Ground-Up continuous
*/
public boolean getGroundUpContinuous() {
return handle.getBooleans().read(0);
}
/**
* Set Ground-Up continuous.
*
* @param value - new value.
*/
public void setGroundUpContinuous(boolean value) {
handle.getBooleans().write(0, value);
}
/**
* Bitmask with bits set to 1 for every 16×16×16 chunk section whose data is
* included in Data. The least significant bit represents the chunk section at
* the bottom of the chunk column (from y=0 to y=15).
* @return the bitmask
*/
public int getBitmask() {
return handle.getIntegers().read(2);
}
public void setBitmask(int value) {
handle.getIntegers().write(2, value);
}
/**
* See <a href="http://wiki.vg/Chunk_Format#Data_structure">the wiki</a>
* @return the data array
*/
public byte[] getData() {
return handle.getByteArrays().read(0);
}
public void setData(byte[] value) {
handle.getByteArrays().write(0, value);
}
/**
* @return all block entities in the chunk
*/
public List<NbtBase<?>> getTileEntities() {
return handle.getListNbtModifier().read(0);
}
public void setTileEntities(List<NbtBase<?>> value) {
handle.getListNbtModifier().write(0, value);
}
}
@@ -0,0 +1,121 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
public class WrapperPlayServerMount extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.MOUNT;
public WrapperPlayServerMount() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerMount(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: vehicle's EID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Retrieve the entity involved in this event.
*
* @param world - the current world of the entity.
* @return The involved entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity involved in this event.
*
* @param event - the packet event.
* @return The involved entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
public int[] getPassengerIds() {
return handle.getIntegerArrays().read(0);
}
public void setPassengerIds(int[] value) {
handle.getIntegerArrays().write(0, value);
}
public List<Entity> getPassengers(PacketEvent event) {
return getPassengers(event.getPlayer().getWorld());
}
public List<Entity> getPassengers(World world) {
int[] ids = getPassengerIds();
List<Entity> passengers = new ArrayList<>();
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
for (int id : ids) {
Entity entity = manager.getEntityFromID(world, id);
if (entity != null) {
passengers.add(entity);
}
}
return passengers;
}
public void setPassengers(List<Entity> value) {
int[] array = new int[value.size()];
for (int i = 0; i < value.size(); i++) {
array[i] = value.get(i).getEntityId();
}
setPassengerIds(array);
}
}
@@ -0,0 +1,74 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
public class WrapperPlayServerMultiBlockChange extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.MULTI_BLOCK_CHANGE;
public WrapperPlayServerMultiBlockChange() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerMultiBlockChange(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve the chunk that has been altered.
*
* @return The current chunk
*/
public ChunkCoordIntPair getChunk() {
return handle.getChunkCoordIntPairs().read(0);
}
/**
* Set the chunk that has been altered.
*
* @param value - new value
*/
public void setChunk(ChunkCoordIntPair value) {
handle.getChunkCoordIntPairs().write(0, value);
}
/**
* Retrieve a copy of the record data as a block change array.
*
* @return The copied block change array.
*/
public MultiBlockChangeInfo[] getRecords() {
return handle.getMultiBlockChangeInfoArrays().read(0);
}
/**
* Set the record data using the given helper array.
*
* @param value - new value
*/
public void setRecords(MultiBlockChangeInfo[] value) {
handle.getMultiBlockChangeInfoArrays().write(0, value);
}
}
@@ -0,0 +1,204 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import java.util.UUID;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
public class WrapperPlayServerNamedEntitySpawn extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.NAMED_ENTITY_SPAWN;
public WrapperPlayServerNamedEntitySpawn() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerNamedEntitySpawn(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
/**
* Retrieve Player UUID.
* <p>
* Notes: player's UUID
*
* @return The current Player UUID
*/
public UUID getPlayerUUID() {
return handle.getUUIDs().read(0);
}
/**
* Set Player UUID.
*
* @param value - new value.
*/
public void setPlayerUUID(UUID value) {
handle.getUUIDs().write(0, value);
}
/**
* Retrieve the position of the spawned entity as a vector.
*
* @return The position as a vector.
*/
public Vector getPosition() {
return new Vector(getX(), getY(), getZ());
}
/**
* Set the position of the spawned entity using a vector.
*
* @param position - the new position.
*/
public void setPosition(Vector position) {
setX(position.getX());
setY(position.getY());
setZ(position.getZ());
}
public double getX() {
return handle.getDoubles().read(0);
}
public void setX(double value) {
handle.getDoubles().write(0, value);
}
public double getY() {
return handle.getDoubles().read(1);
}
public void setY(double value) {
handle.getDoubles().write(1, value);
}
public double getZ() {
return handle.getDoubles().read(2);
}
public void setZ(double value) {
handle.getDoubles().write(2, value);
}
/**
* Retrieve the yaw of the spawned entity.
*
* @return The current Yaw
*/
public float getYaw() {
return (handle.getBytes().read(0) * 360.F) / 256.0F;
}
/**
* Set the yaw of the spawned entity.
*
* @param value - new yaw.
*/
public void setYaw(float value) {
handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F));
}
/**
* Retrieve the pitch of the spawned entity.
*
* @return The current pitch
*/
public float getPitch() {
return (handle.getBytes().read(1) * 360.F) / 256.0F;
}
/**
* Set the pitch of the spawned entity.
*
* @param value - new pitch.
*/
public void setPitch(float value) {
handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F));
}
/**
* Retrieve Metadata.
* <p>
* Notes: the client will crash if no metadata is sent
*
* @return The current Metadata
*/
public WrappedDataWatcher getMetadata() {
return handle.getDataWatcherModifier().read(0);
}
/**
* Set Metadata.
*
* @param value - new value.
*/
public void setMetadata(WrappedDataWatcher value) {
handle.getDataWatcherModifier().write(0, value);
}
}
@@ -0,0 +1,156 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.Sound;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.NAMED_SOUND_EFFECT;
public WrapperPlayServerNamedSoundEffect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerNamedSoundEffect(PacketContainer packet) {
super(packet, TYPE);
}
public Sound getSoundEffect() {
return handle.getSoundEffects().read(0);
}
public void setSoundEffect(Sound value) {
handle.getSoundEffects().write(0, value);
}
public SoundCategory getSoundCategory() {
return handle.getSoundCategories().read(0);
}
public void setSoundCategory(SoundCategory value) {
handle.getSoundCategories().write(0, value);
}
/**
* Retrieve Effect position X.
* <p>
* Notes: effect X multiplied by 8
*
* @return The current Effect position X
*/
public int getEffectPositionX() {
return handle.getIntegers().read(0);
}
/**
* Set Effect position X.
*
* @param value - new value.
*/
public void setEffectPositionX(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Effect position Y.
* <p>
* Notes: effect Y multiplied by 8
*
* @return The current Effect position Y
*/
public int getEffectPositionY() {
return handle.getIntegers().read(1);
}
/**
* Set Effect position Y.
*
* @param value - new value.
*/
public void setEffectPositionY(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Effect position Z.
* <p>
* Notes: effect Z multiplied by 8
*
* @return The current Effect position Z
*/
public int getEffectPositionZ() {
return handle.getIntegers().read(2);
}
/**
* Set Effect position Z.
*
* @param value - new value.
*/
public void setEffectPositionZ(int value) {
handle.getIntegers().write(2, value);
}
/**
* Retrieve Volume.
* <p>
* Notes: 1 is 100%, can be more
*
* @return The current Volume
*/
public float getVolume() {
return handle.getFloat().read(0);
}
/**
* Set Volume.
*
* @param value - new value.
*/
public void setVolume(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Pitch.
* <p>
* Notes: 63 is 100%, can be more
*
* @return The current Pitch
*/
public float getPitch() {
return handle.getFloat().read(1);
}
/**
* Set Pitch.
*
* @param value - new value.
*/
public void setPitch(float value) {
handle.getFloat().write(1, value);
}
}
@@ -0,0 +1,74 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
public class WrapperPlayServerNbtQuery extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.NBT_QUERY;
public WrapperPlayServerNbtQuery() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerNbtQuery(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Transaction ID.
* <p>
* Notes: can be compared to the one sent in the original query packet.
* @return The current Transaction ID
*/
public int getTransactionId() {
return handle.getIntegers().read(0);
}
/**
* Set Transaction ID.
* @param value - new value.
*/
public void setTransactionId(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve NBT.
* <p>
* Notes: the NBT of the block or entity. May be a TAG_END (0) in which case no NBT is present.
* @return The current NBT
*/
public NbtBase<?> getNbt() {
return handle.getNbtModifier().read(0);
}
/**
* Set NBT.
* @param value - new value.
*/
public void setNbt(NbtBase<?> value) {
handle.getNbtModifier().write(0, value);
}
}
@@ -0,0 +1,57 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.BlockPosition;
public class WrapperPlayServerOpenSignEditor extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.OPEN_SIGN_EDITOR;
public WrapperPlayServerOpenSignEditor() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerOpenSignEditor(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Location.
*
* @return The current Location
*/
public BlockPosition getLocation() {
return handle.getBlockPositionModifier().read(0);
}
/**
* Set Location.
*
* @param value - new value.
*/
public void setLocation(BlockPosition value) {
handle.getBlockPositionModifier().write(0, value);
}
}
@@ -0,0 +1,162 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
public class WrapperPlayServerOpenWindow extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.OPEN_WINDOW;
public WrapperPlayServerOpenWindow() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerOpenWindow(PacketContainer packet) {
super(packet, TYPE);
}
/**
* Retrieve Window id.
* <p>
* Notes: a unique id number for the window to be displayed. Notchian server
* implementation is a counter, starting at 1.
*
* @return The current Window id
*/
public int getWindowID() {
return handle.getIntegers().read(0);
}
/**
* Set Window id.
*
* @param value - new value.
*/
public void setWindowID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Inventory Type.
* <p>
* Notes: the window type to use for display. Check below
*
* @return The current Inventory Type
*/
public String getInventoryType() {
return handle.getStrings().read(0);
}
/**
* Set Inventory Type.
*
* @param value - new value.
*/
public void setInventoryType(String value) {
handle.getStrings().write(0, value);
}
/**
* Retrieve Window title.
* <p>
* Notes: the title of the window.
*
* @return The current Window title
*/
public WrappedChatComponent getWindowTitle() {
return handle.getChatComponents().read(0);
}
/**
* Set Window title.
*
* @param value - new value.
*/
public void setWindowTitle(WrappedChatComponent value) {
handle.getChatComponents().write(0, value);
}
/**
* Retrieve Number of Slots.
* <p>
* Notes: number of slots in the window (excluding the number of slots in
* the player inventory).
*
* @return The current Number of Slots
*/
public int getNumberOfSlots() {
return handle.getIntegers().read(1);
}
/**
* Set Number of Slots.
*
* @param value - new value.
*/
public void setNumberOfSlots(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Entity ID.
* <p>
* Notes: entity's ID
*
* @return The current Entity ID
*/
public int getEntityID() {
return handle.getIntegers().read(0);
}
/**
* Set Entity ID.
*
* @param value - new value.
*/
public void setEntityID(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param world - the current world of the entity.
* @return The spawned entity.
*/
public Entity getEntity(World world) {
return handle.getEntityModifier(world).read(0);
}
/**
* Retrieve the entity of the painting that will be spawned.
*
* @param event - the packet event.
* @return The spawned entity.
*/
public Entity getEntity(PacketEvent event) {
return getEntity(event.getPlayer().getWorld());
}
}
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff. Show more