├── License.txt
├── PacketWrapper
├── .classpath
├── .project
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── comphenix
│ │ └── packetwrapper
│ │ ├── AbstractPacket.java
│ │ ├── BlockChangeArray.java
│ │ ├── ChunkPacketProcessor.java
│ │ ├── PacketWrapper.java
│ │ ├── WrapperHandshakeClientSetProtocol.java
│ │ ├── WrapperLoginClientEncryptionBegin.java
│ │ ├── WrapperLoginClientStart.java
│ │ ├── WrapperLoginServerDisconnect.java
│ │ ├── WrapperLoginServerEncryptionBegin.java
│ │ ├── WrapperLoginServerSuccess.java
│ │ ├── WrapperPlayClientAbilities.java
│ │ ├── WrapperPlayClientArmAnimation.java
│ │ ├── WrapperPlayClientBlockDig.java
│ │ ├── WrapperPlayClientBlockPlace.java
│ │ ├── WrapperPlayClientChat.java
│ │ ├── WrapperPlayClientClientCommand.java
│ │ ├── WrapperPlayClientCloseWindow.java
│ │ ├── WrapperPlayClientCustomPayload.java
│ │ ├── WrapperPlayClientEnchantItem.java
│ │ ├── WrapperPlayClientEntityAction.java
│ │ ├── WrapperPlayClientFlying.java
│ │ ├── WrapperPlayClientHeldItemSlot.java
│ │ ├── WrapperPlayClientKeepAlive.java
│ │ ├── WrapperPlayClientLook.java
│ │ ├── WrapperPlayClientPosition.java
│ │ ├── WrapperPlayClientPositionLook.java
│ │ ├── WrapperPlayClientSetCreativeSlot.java
│ │ ├── WrapperPlayClientSettings.java
│ │ ├── WrapperPlayClientSteerVehicle.java
│ │ ├── WrapperPlayClientTabComplete.java
│ │ ├── WrapperPlayClientTransaction.java
│ │ ├── WrapperPlayClientUpdateSign.java
│ │ ├── WrapperPlayClientUseEntity.java
│ │ ├── WrapperPlayClientWindowClick.java
│ │ ├── WrapperPlayServerAbilities.java
│ │ ├── WrapperPlayServerAnimation.java
│ │ ├── WrapperPlayServerAttachEntity.java
│ │ ├── WrapperPlayServerBed.java
│ │ ├── WrapperPlayServerBlockAction.java
│ │ ├── WrapperPlayServerBlockBreakAnimation.java
│ │ ├── WrapperPlayServerBlockChange.java
│ │ ├── WrapperPlayServerChat.java
│ │ ├── WrapperPlayServerCloseWindow.java
│ │ ├── WrapperPlayServerCollect.java
│ │ ├── WrapperPlayServerCraftProgressBar.java
│ │ ├── WrapperPlayServerCustomPayload.java
│ │ ├── WrapperPlayServerEntity.java
│ │ ├── WrapperPlayServerEntityDestroy.java
│ │ ├── WrapperPlayServerEntityEffect.java
│ │ ├── WrapperPlayServerEntityEquipment.java
│ │ ├── WrapperPlayServerEntityHeadRotation.java
│ │ ├── WrapperPlayServerEntityLook.java
│ │ ├── WrapperPlayServerEntityMetadata.java
│ │ ├── WrapperPlayServerEntityMoveLook.java
│ │ ├── WrapperPlayServerEntityStatus.java
│ │ ├── WrapperPlayServerEntityTeleport.java
│ │ ├── WrapperPlayServerEntityVelocity.java
│ │ ├── WrapperPlayServerExperience.java
│ │ ├── WrapperPlayServerExplosion.java
│ │ ├── WrapperPlayServerGameStateChange.java
│ │ ├── WrapperPlayServerHeldItemSlot.java
│ │ ├── WrapperPlayServerKeepAlive.java
│ │ ├── WrapperPlayServerKickDisconnect.java
│ │ ├── WrapperPlayServerLogin.java
│ │ ├── WrapperPlayServerMap.java
│ │ ├── WrapperPlayServerMapChunk.java
│ │ ├── WrapperPlayServerMapChunkBulk.java
│ │ ├── WrapperPlayServerMultiBlockChange.java
│ │ ├── WrapperPlayServerNamedEntitySpawn.java
│ │ ├── WrapperPlayServerNamedSoundEffect.java
│ │ ├── WrapperPlayServerOpenSignEntity.java
│ │ ├── WrapperPlayServerOpenWindow.java
│ │ ├── WrapperPlayServerPlayerInfo.java
│ │ ├── WrapperPlayServerPosition.java
│ │ ├── WrapperPlayServerRelEntityMove.java
│ │ ├── WrapperPlayServerRemoveEntityEffect.java
│ │ ├── WrapperPlayServerRespawn.java
│ │ ├── WrapperPlayServerScoreboardDisplayObjective.java
│ │ ├── WrapperPlayServerScoreboardObjective.java
│ │ ├── WrapperPlayServerScoreboardScore.java
│ │ ├── WrapperPlayServerScoreboardTeam.java
│ │ ├── WrapperPlayServerSetSlot.java
│ │ ├── WrapperPlayServerSpawnEntity.java
│ │ ├── WrapperPlayServerSpawnEntityExperienceOrb.java
│ │ ├── WrapperPlayServerSpawnEntityLiving.java
│ │ ├── WrapperPlayServerSpawnEntityPainting.java
│ │ ├── WrapperPlayServerSpawnEntityWeather.java
│ │ ├── WrapperPlayServerSpawnPosition.java
│ │ ├── WrapperPlayServerStatistics.java
│ │ ├── WrapperPlayServerTabComplete.java
│ │ ├── WrapperPlayServerTileEntityData.java
│ │ ├── WrapperPlayServerTransaction.java
│ │ ├── WrapperPlayServerUpdateAttributes.java
│ │ ├── WrapperPlayServerUpdateHealth.java
│ │ ├── WrapperPlayServerUpdateSign.java
│ │ ├── WrapperPlayServerUpdateTime.java
│ │ ├── WrapperPlayServerWindowItems.java
│ │ ├── WrapperPlayServerWorldEvent.java
│ │ ├── WrapperPlayServerWorldParticles.java
│ │ ├── WrapperStatusClientInPing.java
│ │ ├── WrapperStatusClientInStart.java
│ │ ├── WrapperStatusServerOutPing.java
│ │ └── WrapperStatusServerOutServerInfo.java
│ └── resources
│ └── plugin.yml
└── Readme.md
/PacketWrapper/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
22 | * This is 4 as of 1.7.2. Note to be confused with the old protocol versions. 23 | * @return The current Protocol Version 24 | */ 25 | public int getProtocolVersion() { 26 | return handle.getIntegers().read(0); 27 | } 28 | 29 | /** 30 | * Set the new protocol version. 31 | *
32 | * This is 4 as of 1.7.2. 33 | * @param value - new value. 34 | */ 35 | public void setProtocolVersion(int value) { 36 | handle.getIntegers().write(0, value); 37 | } 38 | 39 | /** 40 | * Retrieve the server hostname or IP. 41 | * @return The current server hostname. 42 | */ 43 | public String getServerHostname() { 44 | return handle.getStrings().read(0); 45 | } 46 | 47 | /** 48 | * Set the server hostname. 49 | * @param value - new value. 50 | */ 51 | public void setServerHostname(String value) { 52 | handle.getStrings().write(0, value); 53 | } 54 | 55 | /** 56 | * Retrieve the TCP port number, typically 25565. 57 | * @return The current server port 58 | */ 59 | public short getServerPort() { 60 | return handle.getIntegers().read(1).shortValue(); 61 | } 62 | 63 | /** 64 | * Set the TCP port number. 65 | * @param value - new value. 66 | */ 67 | public void setServerPort(short value) { 68 | handle.getIntegers().write(1, (int) value); 69 | } 70 | 71 | /** 72 | * Retrieve the next protocol to use. 73 | * @return The next protocol. 74 | */ 75 | public Protocol getNextProtocol() { 76 | return handle.getProtocols().read(0); 77 | } 78 | 79 | /** 80 | * Set the next protocol to use. 81 | * @param value - new protocll. 82 | */ 83 | public void setNextProtocol(Protocol value) { 84 | handle.getProtocols().write(0, value); 85 | } 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientEncryptionBegin.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperLoginClientEncryptionBegin extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Login.Client.ENCRYPTION_BEGIN; 8 | 9 | public WrapperLoginClientEncryptionBegin() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperLoginClientEncryptionBegin(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve the shared secret data. 20 | * @return The shared data. 21 | */ 22 | public byte[] getSharedSecret() { 23 | return handle.getByteArrays().read(0); 24 | } 25 | 26 | /** 27 | * Set the shared secret data. 28 | * @param value - new value. 29 | */ 30 | public void setSharedSecret(byte[] value) { 31 | handle.getByteArrays().write(0, value); 32 | } 33 | 34 | /** 35 | * Retrieve the token response. 36 | * @return The shared data. 37 | */ 38 | public byte[] getVerifyTokenResponse() { 39 | return handle.getByteArrays().read(1); 40 | } 41 | 42 | /** 43 | * Set token reponse. 44 | * @param value - new value. 45 | */ 46 | public void setVerifyTokenResponse(byte[] value) { 47 | handle.getByteArrays().write(1, value); 48 | } 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientStart.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | import com.comphenix.protocol.wrappers.WrappedGameProfile; 6 | 7 | public class WrapperLoginClientStart extends AbstractPacket { 8 | public static final PacketType TYPE = PacketType.Login.Client.START; 9 | 10 | public WrapperLoginClientStart() { 11 | super(new PacketContainer(TYPE), TYPE); 12 | handle.getModifier().writeDefaults(); 13 | } 14 | 15 | public WrapperLoginClientStart(PacketContainer packet) { 16 | super(packet, TYPE); 17 | } 18 | 19 | /** 20 | * Retrieve the initial game profile. 21 | *
22 | * Note that the UUID is NULL. 23 | * @return The current profile. 24 | */ 25 | public WrappedGameProfile getProfile() { 26 | return handle.getGameProfiles().read(0); 27 | } 28 | 29 | /** 30 | * Set the initial game profile. 31 | * @param value - new profile. 32 | */ 33 | public void setProfile(WrappedGameProfile value) { 34 | handle.getGameProfiles().write(0, value); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerDisconnect.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | import com.comphenix.protocol.wrappers.WrappedChatComponent; 6 | 7 | public class WrapperLoginServerDisconnect extends AbstractPacket { 8 | public static final PacketType TYPE = PacketType.Login.Server.DISCONNECT; 9 | 10 | public WrapperLoginServerDisconnect() { 11 | super(new PacketContainer(TYPE), TYPE); 12 | handle.getModifier().writeDefaults(); 13 | } 14 | 15 | public WrapperLoginServerDisconnect(PacketContainer packet) { 16 | super(packet, TYPE); 17 | } 18 | 19 | /** 20 | * Retrieve the message that is displayed to the client when the connection terminates. 21 | * @return The current JSON message. 22 | */ 23 | public WrappedChatComponent getJsonData() { 24 | return handle.getChatComponents().read(0); 25 | } 26 | 27 | /** 28 | * Set the message that is displayed to the client when the connection terminates. 29 | * @param value - new message. 30 | */ 31 | public void setJsonData(WrappedChatComponent value) { 32 | handle.getChatComponents().write(0, value); 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerEncryptionBegin.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import java.security.PublicKey; 4 | 5 | import com.comphenix.protocol.PacketType; 6 | import com.comphenix.protocol.events.PacketContainer; 7 | 8 | public class WrapperLoginServerEncryptionBegin extends AbstractPacket { 9 | public static final PacketType TYPE = PacketType.Login.Server.ENCRYPTION_BEGIN; 10 | 11 | public WrapperLoginServerEncryptionBegin() { 12 | super(new PacketContainer(TYPE), TYPE); 13 | handle.getModifier().writeDefaults(); 14 | } 15 | 16 | public WrapperLoginServerEncryptionBegin(PacketContainer packet) { 17 | super(packet, TYPE); 18 | } 19 | 20 | /** 21 | * Retrieve the server ID. 22 | * @return The current Server id 23 | */ 24 | public String getServerId() { 25 | return handle.getStrings().read(0); 26 | } 27 | 28 | /** 29 | * Set the server ID. 30 | * @param value - new value. 31 | */ 32 | public void setServerId(String value) { 33 | handle.getStrings().write(0, value); 34 | } 35 | 36 | /** 37 | * Retrieve the public key instance. 38 | * @return The current Public key length 39 | */ 40 | public PublicKey getPublicKey() { 41 | return handle.getSpecificModifier(PublicKey.class).read(0); 42 | } 43 | 44 | /** 45 | * Set the public key instance. 46 | * @param value - new value. 47 | */ 48 | public void setPublicKey(PublicKey value) { 49 | handle.getSpecificModifier(PublicKey.class).write(0, value); 50 | } 51 | 52 | /** 53 | * Retrieve the verify token. 54 | * @return The current Public key 55 | */ 56 | public byte[] getVerifyToken() { 57 | return handle.getByteArrays().read(0); 58 | } 59 | 60 | /** 61 | * Set the verify token. 62 | * @param value - new value. 63 | */ 64 | public void getVerifyToken(byte[] value) { 65 | handle.getByteArrays().write(0, value); 66 | } 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSuccess.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | import com.comphenix.protocol.wrappers.WrappedGameProfile; 6 | 7 | public class WrapperLoginServerSuccess extends AbstractPacket { 8 | public static final PacketType TYPE = PacketType.Login.Server.SUCCESS; 9 | 10 | public WrapperLoginServerSuccess() { 11 | super(new PacketContainer(TYPE), TYPE); 12 | handle.getModifier().writeDefaults(); 13 | } 14 | 15 | public WrapperLoginServerSuccess(PacketContainer packet) { 16 | super(packet, TYPE); 17 | } 18 | 19 | /** 20 | * Retrieve the UUID and player name of the connected client. 21 | * @return The current client profile. 22 | */ 23 | public WrappedGameProfile getProfile() { 24 | return handle.getGameProfiles().read(0); 25 | } 26 | 27 | /** 28 | * Set the UUID and player name of the connected client as a game profile. 29 | * @param value - new profile. 30 | */ 31 | public void setProfile(WrappedGameProfile value) { 32 | handle.getGameProfiles().write(0, value); 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAbilities.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayClientAbilities extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Client.ABILITIES; 8 | 9 | public WrapperPlayClientAbilities() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayClientAbilities(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve whether or not the current player is in creative mode. 20 | * @return Creative mode. 21 | */ 22 | public boolean isCreativeMode() { 23 | return handle.getSpecificModifier(boolean.class).read(0); 24 | } 25 | 26 | /** 27 | * Set whether or not the current player is in creative mode. 28 | * @param value - new value. 29 | */ 30 | public void setCreativeMode(boolean value) { 31 | handle.getSpecificModifier(boolean.class).write(0, value); 32 | } 33 | 34 | /** 35 | * Retrieve whether or not the current player is flying. 36 | * @return Creative mode. 37 | */ 38 | public boolean isFlying() { 39 | return handle.getSpecificModifier(boolean.class).read(1); 40 | } 41 | 42 | /** 43 | * Set whether or not the current player is flying. 44 | * @param value - new value. 45 | */ 46 | public void setFlying(boolean value) { 47 | handle.getSpecificModifier(boolean.class).write(1, value); 48 | } 49 | 50 | /** 51 | * Retrieve whether or not the current player is allowed to fly. 52 | * @return Creative mode. 53 | */ 54 | public boolean isFlyingAllowed() { 55 | return handle.getSpecificModifier(boolean.class).read(2); 56 | } 57 | 58 | /** 59 | * Set whether or not the current player is allowed to fly. 60 | * @param value - new value. 61 | */ 62 | public void setFlyingAllowed(boolean value) { 63 | handle.getSpecificModifier(boolean.class).write(2, value); 64 | } 65 | 66 | /** 67 | * Retrieve whether or not the current player is in god mode. 68 | * @return Creative mode. 69 | */ 70 | public boolean isGodMode() { 71 | return handle.getSpecificModifier(boolean.class).read(3); 72 | } 73 | 74 | /** 75 | * Set whether or not the current player is in god mode. 76 | * @param value - new value. 77 | */ 78 | public void setGodMode(boolean value) { 79 | handle.getSpecificModifier(boolean.class).write(3, value); 80 | } 81 | 82 | /** 83 | * Retrieve the current flying speed. 84 | * @return The current Flying speed 85 | */ 86 | public float getFlyingSpeed() { 87 | return handle.getFloat().read(0); 88 | } 89 | 90 | /** 91 | * Set the current flying speed. 92 | * @param value - new value. 93 | */ 94 | public void setFlyingSpeed(float value) { 95 | handle.getFloat().write(0, value); 96 | } 97 | 98 | /** 99 | * Retrieve the current walking speed. 100 | * @return The current walking speed 101 | */ 102 | public float getWalkingSpeed() { 103 | return handle.getFloat().read(1); 104 | } 105 | 106 | /** 107 | * Set the current walking speed. 108 | * @param value - walking value. 109 | */ 110 | public void setWalkingSpeed(float value) { 111 | handle.getFloat().write(1, value); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientArmAnimation.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | /* 4 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 5 | * Copyright (C) 2012 Kristian S. Stangeland 6 | * 7 | * This program is free software; you can redistribute it and/or modify it under the terms of the 8 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with this program; 16 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | * 02111-1307 USA 18 | */ 19 | 20 | import org.bukkit.World; 21 | import org.bukkit.entity.Entity; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketContainer; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | import com.comphenix.protocol.reflect.IntEnum; 27 | 28 | public class WrapperPlayClientArmAnimation extends AbstractPacket { 29 | public static final PacketType TYPE = PacketType.Play.Client.ARM_ANIMATION; 30 | 31 | /** 32 | * Represents the different animations sent by notchian clients. 33 | * 34 | * @author Kristian 35 | */ 36 | public static class Animations extends IntEnum { 37 | public static final int NO_ANIMATION = 0; 38 | public static final int SWING_ARM = 1; 39 | public static final int DAMAGE_ANIMATION = 2; 40 | public static final int LEAVE_BED = 3; 41 | public static final int EAT_FOOD = 5; 42 | public static final int UNKNOWN = 102; 43 | public static final int CROUCH = 104; 44 | public static final int UNCROUCH = 105; 45 | 46 | /** 47 | * The singleton instance. Can also be retrieved from the parent class. 48 | */ 49 | private static Animations INSTANCE = new Animations(); 50 | 51 | /** 52 | * Retrieve an instance of the Animation enum. 53 | * @return Animation enum. 54 | */ 55 | public static Animations getInstance() { 56 | return INSTANCE; 57 | } 58 | } 59 | 60 | public WrapperPlayClientArmAnimation() { 61 | super(new PacketContainer(TYPE), TYPE); 62 | handle.getModifier().writeDefaults(); 63 | } 64 | 65 | public WrapperPlayClientArmAnimation(PacketContainer packet) { 66 | super(packet, TYPE); 67 | } 68 | 69 | /** 70 | * Retrieve the player ID. 71 | * @return The current EID 72 | */ 73 | public int getEntityID() { 74 | return handle.getIntegers().read(0); 75 | } 76 | 77 | /** 78 | * Set the player ID. 79 | * @param value - new value. 80 | */ 81 | public void setEntityID(int value) { 82 | handle.getIntegers().write(0, value); 83 | } 84 | 85 | /** 86 | * Retrieve the player's entity object. 87 | * @param world - the word the player has joined. 88 | * @return The player's entity. 89 | */ 90 | public Entity getEntity(World world) { 91 | return handle.getEntityModifier(world).read(0); 92 | } 93 | 94 | /** 95 | * Retrieve the player's entity object. 96 | * @param event - the packet event. 97 | * @return The player's entity. 98 | */ 99 | public Entity getEntity(PacketEvent event) { 100 | return getEntity(event.getPlayer().getWorld()); 101 | } 102 | 103 | /** 104 | * Retrieve animation ID. 105 | * @return The current Animation 106 | */ 107 | public int getAnimation() { 108 | return handle.getIntegers().read(1); 109 | } 110 | 111 | /** 112 | * Set animation ID. 113 | * @param value - new value. 114 | */ 115 | public void setAnimation(int value) { 116 | handle.getIntegers().write(1, value); 117 | } 118 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientChat.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayClientChat extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Client.CHAT; 8 | 9 | public WrapperPlayClientChat() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayClientChat(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve the message sent by this player. 20 | * @return The current Message 21 | */ 22 | public String getMessage() { 23 | return handle.getStrings().read(0); 24 | } 25 | 26 | /** 27 | * Set the message sent by this player. 28 | * @param value - new value. 29 | */ 30 | public void setMessage(String value) { 31 | handle.getStrings().write(0, value); 32 | } 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientClientCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand; 23 | 24 | /** 25 | * Sent when the client is ready to complete login and when the client is ready to respawn after death. 26 | * @author Kristian 27 | */ 28 | public class WrapperPlayClientClientCommand extends AbstractPacket { 29 | public static final PacketType TYPE = PacketType.Play.Client.CLIENT_COMMAND; 30 | 31 | public WrapperPlayClientClientCommand() { 32 | super(new PacketContainer(TYPE), TYPE); 33 | handle.getModifier().writeDefaults(); 34 | } 35 | 36 | public WrapperPlayClientClientCommand(PacketContainer packet) { 37 | super(packet, TYPE); 38 | } 39 | 40 | /** 41 | * Retrieve whether or not we're logging in or respawning. 42 | * @return The current command 43 | */ 44 | public ClientCommand getCommand() { 45 | return handle.getClientCommands().read(0); 46 | } 47 | 48 | /** 49 | * Set whether or not we're logging in or respawning. 50 | * @param value - new value. 51 | */ 52 | public void setCommand(ClientCommand value) { 53 | handle.getClientCommands().write(0, value); 54 | } 55 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCloseWindow.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayClientCloseWindow extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Client.CLOSE_WINDOW; 8 | 9 | public WrapperPlayClientCloseWindow() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayClientCloseWindow(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve this is the id of the window that was closed. 0 for inventory. 20 | * @return The current Window id 21 | */ 22 | public byte getWindowId() { 23 | return handle.getIntegers().read(0).byteValue(); 24 | } 25 | 26 | /** 27 | * Set this is the id of the window that was closed. 0 for inventory. 28 | * @param value - new value. 29 | */ 30 | public void setWindowId(byte value) { 31 | handle.getIntegers().write(0, (int) value); 32 | } 33 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCustomPayload.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayClientCustomPayload extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Client.CUSTOM_PAYLOAD; 8 | 9 | public WrapperPlayClientCustomPayload() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayClientCustomPayload(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve name of the "channel" used to send the data.. 20 | * @return The current Channel 21 | */ 22 | public String getChannel() { 23 | return handle.getStrings().read(0); 24 | } 25 | 26 | /** 27 | * Set name of the "channel" used to send the data.. 28 | * @param value - new value. 29 | */ 30 | public void setChannel(String value) { 31 | handle.getStrings().write(0, value); 32 | } 33 | 34 | /** 35 | * Retrieve length of the following byte array. 36 | * @return The current Length 37 | */ 38 | public short getLength() { 39 | return handle.getIntegers().read(0).shortValue(); 40 | } 41 | 42 | /** 43 | * Set length of the following byte array. 44 | * @param value - new value. 45 | */ 46 | public void setLength(short value) { 47 | handle.getIntegers().write(0, (int) value); 48 | } 49 | 50 | /** 51 | * Retrieve any data.. 52 | * @return The current Data 53 | */ 54 | public byte[] getData() { 55 | return handle.getByteArrays().read(0); 56 | } 57 | 58 | /** 59 | * Set the data to sent. 60 | *
61 | * This will automatically update the length. 62 | * @param value - new value. 63 | */ 64 | public void setData(byte[] value) { 65 | setLength((short) value.length); 66 | handle.getByteArrays().write(0, value); 67 | } 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEnchantItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | 23 | public class WrapperPlayClientEnchantItem extends AbstractPacket { 24 | public static final PacketType TYPE = PacketType.Play.Client.ENCHANT_ITEM; 25 | 26 | public WrapperPlayClientEnchantItem() { 27 | super(new PacketContainer(TYPE), TYPE); 28 | handle.getModifier().writeDefaults(); 29 | } 30 | 31 | public WrapperPlayClientEnchantItem(PacketContainer packet) { 32 | super(packet, TYPE); 33 | } 34 | 35 | /** 36 | * Retrieve the ID sent by open window. 37 | * @return The current Window ID 38 | */ 39 | public byte getWindowId() { 40 | return handle.getIntegers().read(0).byteValue(); 41 | } 42 | 43 | /** 44 | * Set the ID sent by open window. 45 | * @param value - new value. 46 | */ 47 | public void setWindowId(byte value) { 48 | handle.getIntegers().write(0, (int) value); 49 | } 50 | 51 | /** 52 | * Retrieve the position of the enchantment on the enchantment table window, starting with 0 as the top-most one. 53 | * @return The current Enchantment 54 | */ 55 | public byte getEnchantment() { 56 | return handle.getIntegers().read(1).byteValue(); 57 | } 58 | 59 | /** 60 | * Set the position of the enchantment on the enchantment table window, starting with 0 as the top-most one. 61 | * @param value - new value. 62 | */ 63 | public void setEnchantment(byte value) { 64 | handle.getIntegers().write(1, (int) value); 65 | } 66 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import org.bukkit.World; 21 | import org.bukkit.entity.Entity; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketContainer; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | import com.comphenix.protocol.reflect.IntEnum; 27 | 28 | public class WrapperPlayClientEntityAction extends AbstractPacket { 29 | public static final PacketType TYPE = PacketType.Play.Client.ENTITY_ACTION; 30 | 31 | /** 32 | * Enumeration of all the entity actions. 33 | * @author Kristian 34 | */ 35 | public static class Action extends IntEnum { 36 | public static final int CROUCH = 1; 37 | public static final int UNCROUCH = 2; 38 | public static final int LEAVE_BED = 3; 39 | public static final int START_SPRINTING = 4; 40 | public static final int STOP_SPRINTING = 5; 41 | 42 | private static final Action INSTANCE = new Action(); 43 | 44 | public static Action getInstance() { 45 | return INSTANCE; 46 | } 47 | } 48 | 49 | public WrapperPlayClientEntityAction() { 50 | super(new PacketContainer(TYPE), TYPE); 51 | handle.getModifier().writeDefaults(); 52 | } 53 | 54 | public WrapperPlayClientEntityAction(PacketContainer packet) { 55 | super(packet, TYPE); 56 | } 57 | 58 | /** 59 | * Retrieve player ID. 60 | * @return The current EID 61 | */ 62 | public int getEntityID() { 63 | return handle.getIntegers().read(0); 64 | } 65 | 66 | /** 67 | * Set player ID. 68 | * @param value - new value. 69 | */ 70 | public void setEntityID(int value) { 71 | handle.getIntegers().write(0, value); 72 | } 73 | 74 | /** 75 | * Retrieve the player's entity object. 76 | * @param world - the word the player has joined. 77 | * @return The player's entity. 78 | */ 79 | public Entity getEntity(World world) { 80 | return handle.getEntityModifier(world).read(0); 81 | } 82 | 83 | /** 84 | * Retrieve the player's entity object. 85 | * @param event - the packet event. 86 | * @return The player's entity. 87 | */ 88 | public Entity getEntity(PacketEvent event) { 89 | return getEntity(event.getPlayer().getWorld()); 90 | } 91 | 92 | /** 93 | * Retrieve the ID of the action. 94 | * @see {@link WrapperPlayClientEntityAction.Action} 95 | * @return The current Action ID 96 | */ 97 | public byte getActionId() { 98 | return handle.getIntegers().read(1).byteValue(); 99 | } 100 | 101 | /** 102 | * Set the ID of the action, see below. 103 | * @see {@link WrapperPlayClientEntityAction.Action} 104 | * @param value - new value. 105 | */ 106 | public void setActionId(byte value) { 107 | handle.getIntegers().write(1, (int) value); 108 | } 109 | 110 | /** 111 | * Retrieve horse jump boost. Ranged from 0 -> 100.. 112 | * @return The current Jump Boost 113 | */ 114 | public int getJumpBoost() { 115 | return handle.getIntegers().read(2); 116 | } 117 | 118 | /** 119 | * Set horse jump boost. Ranged from 0 -> 100.. 120 | * @param value - new value. 121 | */ 122 | public void setJumpBoost(int value) { 123 | handle.getIntegers().write(2, value); 124 | } 125 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientFlying.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | 23 | public class WrapperPlayClientFlying extends AbstractPacket { 24 | public static final PacketType TYPE = PacketType.Play.Client.FLYING; 25 | 26 | public WrapperPlayClientFlying() { 27 | super(new PacketContainer(TYPE), TYPE); 28 | handle.getModifier().writeDefaults(); 29 | } 30 | 31 | public WrapperPlayClientFlying(PacketContainer packet) { 32 | super(packet, TYPE); 33 | } 34 | 35 | protected WrapperPlayClientFlying(PacketContainer packet, PacketType type) { 36 | super(packet, type); 37 | } 38 | 39 | /** 40 | * Retrieve the ground state. 41 | *
42 | * True if the client is on the ground, false otherwise. 43 | * @return The current On Ground 44 | */ 45 | public boolean getOnGround() { 46 | return handle.getSpecificModifier(boolean.class).read(0); 47 | } 48 | 49 | /** 50 | * Set the ground state. 51 | *
52 | * True if the client is on the ground, false otherwise. 53 | * @param value - new value. 54 | */ 55 | public void setOnGround(boolean value) { 56 | handle.getSpecificModifier(boolean.class).write(0, value); 57 | } 58 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientHeldItemSlot.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayClientHeldItemSlot extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Client.HELD_ITEM_SLOT; 8 | 9 | public WrapperPlayClientHeldItemSlot() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayClientHeldItemSlot(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve the slot which the player has selected (0-8). 20 | * @return The current Slot 21 | */ 22 | public short getSlot() { 23 | return handle.getIntegers().read(0).shortValue(); 24 | } 25 | 26 | /** 27 | * Set the slot which the player has selected (0-8). 28 | * @param value - new value. 29 | */ 30 | public void setSlot(short value) { 31 | handle.getIntegers().write(0, (int) value); 32 | } 33 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientKeepAlive.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | /** 7 | * This is the client's response to {@link WrapperPlayServerKeepAlive}. 8 | */ 9 | public class WrapperPlayClientKeepAlive extends AbstractPacket { 10 | public static final PacketType TYPE = PacketType.Play.Client.KEEP_ALIVE; 11 | 12 | public WrapperPlayClientKeepAlive() { 13 | super(new PacketContainer(TYPE), TYPE); 14 | handle.getModifier().writeDefaults(); 15 | } 16 | 17 | public WrapperPlayClientKeepAlive(PacketContainer packet) { 18 | super(packet, TYPE); 19 | } 20 | 21 | /** 22 | * Retrieve the server-generated random ID. 23 | * @return The current keep-alive ID 24 | */ 25 | public int getKeepAliveId() { 26 | return handle.getIntegers().read(0); 27 | } 28 | 29 | /** 30 | * Set the server-generated random ID. 31 | * @param value - new ID. 32 | */ 33 | public void setKeepAliveId(int value) { 34 | handle.getIntegers().write(0, value); 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientLook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | 23 | public class WrapperPlayClientLook extends WrapperPlayClientFlying { 24 | public static final PacketType TYPE = PacketType.Play.Client.LOOK; 25 | 26 | public WrapperPlayClientLook() { 27 | super(new PacketContainer(TYPE), TYPE); 28 | handle.getModifier().writeDefaults(); 29 | } 30 | 31 | public WrapperPlayClientLook(PacketContainer packet) { 32 | super(packet, TYPE); 33 | } 34 | 35 | /** 36 | * Retrieve absolute rotation on the X Axis, in degrees. 37 | * @return The current Yaw 38 | */ 39 | public float getYaw() { 40 | return handle.getFloat().read(0); 41 | } 42 | 43 | /** 44 | * Set absolute rotation on the X Axis, in degrees. 45 | * @param value - new value. 46 | */ 47 | public void setYaw(float value) { 48 | handle.getFloat().write(0, value); 49 | } 50 | 51 | /** 52 | * Retrieve absolute rotation on the Y Axis, in degrees. 53 | * @return The current Pitch 54 | */ 55 | public float getPitch() { 56 | return handle.getFloat().read(1); 57 | } 58 | 59 | /** 60 | * Set absolute rotation on the Y Axis, in degrees. 61 | * @param value - new value. 62 | */ 63 | public void setPitch(float value) { 64 | handle.getFloat().write(1, value); 65 | } 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | import com.comphenix.protocol.PacketType; 20 | import com.comphenix.protocol.events.PacketContainer; 21 | 22 | public class WrapperPlayClientPosition extends WrapperPlayClientFlying { 23 | public static final PacketType TYPE = PacketType.Play.Client.POSITION; 24 | 25 | public WrapperPlayClientPosition() { 26 | super(new PacketContainer(TYPE), TYPE); 27 | handle.getModifier().writeDefaults(); 28 | } 29 | 30 | public WrapperPlayClientPosition(PacketContainer packet) { 31 | super(packet, TYPE); 32 | } 33 | 34 | /** 35 | * Retrieve absolute position. 36 | * @return The current X 37 | */ 38 | public double getX() { 39 | return handle.getDoubles().read(0); 40 | } 41 | 42 | /** 43 | * Set absolute position. 44 | * @param value - new value. 45 | */ 46 | public void setX(double value) { 47 | handle.getDoubles().write(0, value); 48 | } 49 | 50 | /** 51 | * Retrieve absolute position. 52 | * @return The current Y 53 | */ 54 | public double getY() { 55 | return handle.getDoubles().read(1); 56 | } 57 | 58 | /** 59 | * Set absolute position. 60 | * @param value - new value. 61 | */ 62 | public void setY(double value) { 63 | handle.getDoubles().write(1, value); 64 | } 65 | 66 | /** 67 | * Retrieve used to modify the players bounding box when going up stairs, crouching, etc…. 68 | * @return The current Stance 69 | */ 70 | public double getStance() { 71 | return handle.getDoubles().read(3); 72 | } 73 | 74 | /** 75 | * Set used to modify the players bounding box when going up stairs, crouching, etc…. 76 | * @param value - new value. 77 | */ 78 | public void setStance(double value) { 79 | handle.getDoubles().write(3, value); 80 | } 81 | 82 | /** 83 | * Retrieve absolute position. 84 | * @return The current Z 85 | */ 86 | public double getZ() { 87 | return handle.getDoubles().read(2); 88 | } 89 | 90 | /** 91 | * Set absolute position. 92 | * @param value - new value. 93 | */ 94 | public void setZ(double value) { 95 | handle.getDoubles().write(2, value); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPositionLook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | 23 | public class WrapperPlayClientPositionLook extends WrapperPlayClientFlying { 24 | public static final PacketType TYPE = PacketType.Play.Client.POSITION_LOOK; 25 | 26 | public WrapperPlayClientPositionLook() { 27 | super(new PacketContainer(TYPE), TYPE); 28 | handle.getModifier().writeDefaults(); 29 | } 30 | 31 | public WrapperPlayClientPositionLook(PacketContainer packet) { 32 | super(packet, TYPE); 33 | } 34 | 35 | /** 36 | * Retrieve absolute position. 37 | * @return The current X 38 | */ 39 | public double getX() { 40 | return handle.getDoubles().read(0); 41 | } 42 | 43 | /** 44 | * Set absolute position. 45 | * @param value - new value. 46 | */ 47 | public void setX(double value) { 48 | handle.getDoubles().write(0, value); 49 | } 50 | 51 | /** 52 | * Retrieve absolute position. 53 | * @return The current Y 54 | */ 55 | public double getY() { 56 | return handle.getDoubles().read(1); 57 | } 58 | 59 | /** 60 | * Set absolute position. 61 | * @param value - new value. 62 | */ 63 | public void setY(double value) { 64 | handle.getDoubles().write(1, value); 65 | } 66 | 67 | /** 68 | * Retrieve used to modify the players bounding box when going up stairs, crouching, etc. 69 | * @return The current Stance 70 | */ 71 | public double getStance() { 72 | return handle.getDoubles().read(3); 73 | } 74 | 75 | /** 76 | * Set used to modify the players bounding box when going up stairs, crouching, etc. 77 | * @param value - new value. 78 | */ 79 | public void setStance(double value) { 80 | handle.getDoubles().write(3, value); 81 | } 82 | 83 | /** 84 | * Retrieve absolute position. 85 | * @return The current Z 86 | */ 87 | public double getZ() { 88 | return handle.getDoubles().read(2); 89 | } 90 | 91 | /** 92 | * Set absolute position. 93 | * @param value - new value. 94 | */ 95 | public void setZ(double value) { 96 | handle.getDoubles().write(2, value); 97 | } 98 | 99 | /** 100 | * Retrieve absolute rotation on the X Axis. 101 | * @return The current Yaw 102 | */ 103 | public float getYaw() { 104 | return handle.getFloat().read(0); 105 | } 106 | 107 | /** 108 | * Set absolute rotation on the X Axis. 109 | * @param value - new value. 110 | */ 111 | public void setYaw(float value) { 112 | handle.getFloat().write(0, value); 113 | } 114 | 115 | /** 116 | * Retrieve absolute rotation on the Y Axis. 117 | * @return The current Pitch 118 | */ 119 | public float getPitch() { 120 | return handle.getFloat().read(1); 121 | } 122 | 123 | /** 124 | * Set absolute rotation on the Y Axis. 125 | * @param value - new value. 126 | */ 127 | public void setPitch(float value) { 128 | handle.getFloat().write(1, value); 129 | } 130 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCreativeSlot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import org.bukkit.inventory.ItemStack; 21 | 22 | import com.comphenix.protocol.PacketType; 23 | import com.comphenix.protocol.events.PacketContainer; 24 | 25 | public class WrapperPlayClientSetCreativeSlot extends AbstractPacket { 26 | public static final PacketType TYPE = PacketType.Play.Client.SET_CREATIVE_SLOT; 27 | 28 | public WrapperPlayClientSetCreativeSlot() { 29 | super(new PacketContainer(TYPE), TYPE); 30 | handle.getModifier().writeDefaults(); 31 | } 32 | 33 | public WrapperPlayClientSetCreativeSlot(PacketContainer packet) { 34 | super(packet, TYPE); 35 | } 36 | 37 | /** 38 | * Retrieve the inventory slot index. 39 | * @return The current Slot 40 | */ 41 | public short getSlot() { 42 | return handle.getIntegers().read(0).shortValue(); 43 | } 44 | 45 | /** 46 | * Set the inventory slot index. 47 | * @param value - new value. 48 | */ 49 | public void setSlot(short value) { 50 | handle.getIntegers().write(0, (int) value); 51 | } 52 | 53 | /** 54 | * Retrieve the clicked item stack. 55 | * @return The current Clicked item 56 | */ 57 | public ItemStack getClickedItem() { 58 | return handle.getItemModifier().read(0); 59 | } 60 | 61 | /** 62 | * Set the clicked item stack. 63 | * @param value - new value. 64 | */ 65 | public void setClickedItem(ItemStack value) { 66 | handle.getItemModifier().write(0, value); 67 | } 68 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSettings.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility; 6 | import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty; 7 | 8 | public class WrapperPlayClientSettings extends AbstractPacket { 9 | public static final PacketType TYPE = PacketType.Play.Client.SETTINGS; 10 | 11 | public WrapperPlayClientSettings() { 12 | super(new PacketContainer(TYPE), TYPE); 13 | handle.getModifier().writeDefaults(); 14 | } 15 | 16 | public WrapperPlayClientSettings(PacketContainer packet) { 17 | super(packet, TYPE); 18 | } 19 | 20 | /** 21 | * Retrieve en_GB. 22 | * @return The current Locale 23 | */ 24 | public String getLocale() { 25 | return handle.getStrings().read(0); 26 | } 27 | 28 | /** 29 | * Set en_GB. 30 | * @param value - new value. 31 | */ 32 | public void setLocale(String value) { 33 | handle.getStrings().write(0, value); 34 | } 35 | 36 | /** 37 | * Retrieve 0-3 for 'far', 'normal', 'short', 'tiny'. 38 | * @return The current View distance 39 | */ 40 | public byte getViewDistance() { 41 | return handle.getIntegers().read(0).byteValue(); 42 | } 43 | 44 | /** 45 | * Set 0-3 for 'far', 'normal', 'short', 'tiny'.. 46 | * @param value - new value. 47 | */ 48 | public void setViewDistance(byte value) { 49 | handle.getIntegers().write(0, (int) value); 50 | } 51 | 52 | /** 53 | * Retrieve chat settings. 54 | * @return The current chat settings, 55 | */ 56 | public ChatVisibility getChatVisibility() { 57 | return handle.getChatVisibilities().read(0); 58 | } 59 | 60 | /** 61 | * Set chat settings. 62 | * @param value - new value. 63 | */ 64 | public void setChatFlags(ChatVisibility value) { 65 | handle.getChatVisibilities().write(0, value); 66 | } 67 | 68 | /** 69 | * Retrieve whether or not the colours multiplayer setting is enabled. 70 | * @return The current Chat colours 71 | */ 72 | public boolean getChatColours() { 73 | return handle.getSpecificModifier(boolean.class).read(0); 74 | } 75 | 76 | /** 77 | * Set whether or not the colours multiplayer setting is enabled. 78 | * @param value - new value. 79 | */ 80 | public void setChatColours(boolean value) { 81 | handle.getSpecificModifier(boolean.class).write(0, (boolean) value); 82 | } 83 | 84 | /** 85 | * Retrieve the client-side difficulty. 86 | * @return The current Difficulty 87 | */ 88 | public Difficulty getDifficulty() { 89 | return handle.getDifficulties().read(0); 90 | } 91 | 92 | /** 93 | * Set the client-side difficulty. 94 | * @param value - new value. 95 | */ 96 | public void setDifficulty(Difficulty difficulty) { 97 | handle.getDifficulties().write(0, difficulty); 98 | } 99 | 100 | /** 101 | * Retrieve the client-side "show cape" option. 102 | * @return The current Show Cape 103 | */ 104 | public boolean getShowCape() { 105 | return handle.getSpecificModifier(boolean.class).read(1); 106 | } 107 | 108 | /** 109 | * Set the client-side "show cape" option. 110 | * @param value - new value. 111 | */ 112 | public void setShowCape(boolean value) { 113 | handle.getSpecificModifier(boolean.class).write(1, (boolean) value); 114 | } 115 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSteerVehicle.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayClientSteerVehicle extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Client.STEER_VEHICLE; 8 | 9 | public WrapperPlayClientSteerVehicle() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayClientSteerVehicle(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve positive to the left of the player. 20 | * @return The current Sideways 21 | */ 22 | public float getSideways() { 23 | return handle.getFloat().read(0); 24 | } 25 | 26 | /** 27 | * Set positive to the left of the player. 28 | * @param value - new value. 29 | */ 30 | public void setSideways(float value) { 31 | handle.getFloat().write(0, value); 32 | } 33 | 34 | /** 35 | * Retrieve positive forward. 36 | * @return The current Forward 37 | */ 38 | public float getForward() { 39 | return handle.getFloat().read(1); 40 | } 41 | 42 | /** 43 | * Set positive forward. 44 | * @param value - new value. 45 | */ 46 | public void setForward(float value) { 47 | handle.getFloat().write(1, value); 48 | } 49 | 50 | /** 51 | * Retrieve whether or not the mounted player is jumping. 52 | * @return The current Jump 53 | */ 54 | public boolean getJump() { 55 | return handle.getSpecificModifier(boolean.class).read(0); 56 | } 57 | 58 | /** 59 | * Set whether or not the mounted player is jumping. 60 | * @param value - new value. 61 | */ 62 | public void setJump(boolean value) { 63 | handle.getSpecificModifier(boolean.class).write(0, (boolean) value); 64 | } 65 | 66 | /** 67 | * Retrieve true when leaving the vehicle. 68 | * @return The current Unmount 69 | */ 70 | public boolean getUnmount() { 71 | return handle.getSpecificModifier(boolean.class).read(1); 72 | } 73 | 74 | /** 75 | * Set true when leaving the vehicle. 76 | * @param value - new value. 77 | */ 78 | public void setUnmount(boolean value) { 79 | handle.getSpecificModifier(boolean.class).write(1, value); 80 | } 81 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | /** 7 | * Sent when the user presses [tab] while writing text. 8 | * @author Kristian 9 | */ 10 | public class WrapperPlayClientTabComplete extends AbstractPacket { 11 | public static final PacketType TYPE = PacketType.Play.Client.TAB_COMPLETE; 12 | 13 | public WrapperPlayClientTabComplete() { 14 | super(new PacketContainer(TYPE), TYPE); 15 | handle.getModifier().writeDefaults(); 16 | } 17 | 18 | public WrapperPlayClientTabComplete(PacketContainer packet) { 19 | super(packet, TYPE); 20 | } 21 | 22 | /** 23 | * Retrieve all the text currently behind the cursor. 24 | * @return The current Text 25 | */ 26 | public String getText() { 27 | return handle.getStrings().read(0); 28 | } 29 | 30 | /** 31 | * Set all the text currently behind the cursor. 32 | * @param value - new value. 33 | */ 34 | public void setText(String value) { 35 | handle.getStrings().write(0, value); 36 | } 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTransaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | 23 | public class WrapperPlayClientTransaction extends AbstractPacket { 24 | public static final PacketType TYPE = PacketType.Play.Client.TRANSACTION; 25 | 26 | public WrapperPlayClientTransaction() { 27 | super(new PacketContainer(TYPE), TYPE); 28 | handle.getModifier().writeDefaults(); 29 | } 30 | 31 | public WrapperPlayClientTransaction(PacketContainer packet) { 32 | super(packet, TYPE); 33 | } 34 | 35 | /** 36 | * Retrieve the id of the window that the action occurred in. 37 | * @return The current Window id 38 | */ 39 | public byte getWindowId() { 40 | return handle.getIntegers().read(0).byteValue(); 41 | } 42 | 43 | /** 44 | * Set the id of the window that the action occurred in.. 45 | * @param value - new value. 46 | */ 47 | public void setWindowId(byte value) { 48 | handle.getIntegers().write(0, (int) value); 49 | } 50 | 51 | /** 52 | * Retrieve every action that is to be accepted has a unique number. 53 | *
54 | * This field corresponds to that number.. 55 | * @return The current Action number 56 | */ 57 | public short getActionNumber() { 58 | return handle.getShorts().read(0); 59 | } 60 | 61 | /** 62 | * Set every action that is to be accepted has a unique number. 63 | *
64 | * This field corresponds to that number. 65 | * @param value - new value. 66 | */ 67 | public void setActionNumber(short value) { 68 | handle.getShorts().write(0, value); 69 | } 70 | 71 | /** 72 | * Retrieve whether or not the action was accepted. 73 | * @return The current Accepted? 74 | */ 75 | public boolean getAccepted() { 76 | return handle.getSpecificModifier(boolean.class).read(0); 77 | } 78 | 79 | /** 80 | * Set whether or not the action was accepted. 81 | * @param value - new value. 82 | */ 83 | public void setAccepted(boolean value) { 84 | handle.getSpecificModifier(boolean.class).write(0, value); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUpdateSign.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import javax.annotation.Nonnull; 21 | 22 | import org.bukkit.Location; 23 | 24 | import com.comphenix.protocol.PacketType; 25 | import com.comphenix.protocol.events.PacketContainer; 26 | import com.comphenix.protocol.events.PacketEvent; 27 | 28 | public class WrapperPlayClientUpdateSign extends AbstractPacket { 29 | public static final PacketType TYPE = PacketType.Play.Client.UPDATE_SIGN; 30 | 31 | public WrapperPlayClientUpdateSign() { 32 | super(new PacketContainer(TYPE), TYPE); 33 | handle.getModifier().writeDefaults(); 34 | } 35 | 36 | public WrapperPlayClientUpdateSign(PacketContainer packet) { 37 | super(packet, TYPE); 38 | } 39 | 40 | /** 41 | * Retrieve block X Coordinate. 42 | * @return The current X 43 | */ 44 | public int getX() { 45 | return handle.getIntegers().read(0); 46 | } 47 | 48 | /** 49 | * Set block X Coordinate. 50 | * @param value - new value. 51 | */ 52 | public void setX(int value) { 53 | handle.getIntegers().write(0, value); 54 | } 55 | 56 | /** 57 | * Retrieve block Y Coordinate. 58 | * @return The current Y 59 | */ 60 | public short getY() { 61 | return handle.getIntegers().read(1).shortValue(); 62 | } 63 | 64 | /** 65 | * Set block Y Coordinate. 66 | * @param value - new value. 67 | */ 68 | public void setY(short value) { 69 | handle.getIntegers().write(1, (int) value); 70 | } 71 | 72 | /** 73 | * Retrieve block Z Coordinate. 74 | * @return The current Z 75 | */ 76 | public int getZ() { 77 | return handle.getIntegers().read(2); 78 | } 79 | 80 | /** 81 | * Set block Z Coordinate. 82 | * @param value - new value. 83 | */ 84 | public void setZ(int value) { 85 | handle.getIntegers().write(2, value); 86 | } 87 | 88 | /** 89 | * Retrieve the location of the current particle. 90 | * @param event - the packet event. 91 | * @return The location. 92 | */ 93 | public Location getLocation(PacketEvent event) { 94 | return new Location(event.getPlayer().getWorld(), getX(), getY(), getZ()); 95 | } 96 | 97 | /** 98 | * Set the location of the particle to send. 99 | * @param loc - the location. 100 | */ 101 | public void setLocation(Location loc) { 102 | if (loc == null) 103 | throw new IllegalArgumentException("Location cannot be NULL."); 104 | setX(loc.getBlockX()); 105 | setY((short) loc.getBlockY()); 106 | setZ(loc.getBlockZ()); 107 | } 108 | 109 | /** 110 | * Retrieve the lines of text represented by a four-element String array. 111 | * @return The current lines. 112 | */ 113 | public String[] getLines() { 114 | return handle.getStringArrays().read(0); 115 | } 116 | 117 | /** 118 | * Set the lines of text represented by a four-element String array.. 119 | * @param value - new value. 120 | */ 121 | public void setLines(@Nonnull String[] lines) { 122 | if (lines == null) 123 | throw new IllegalArgumentException("Array cannot be NULL."); 124 | if (lines.length != 4) 125 | throw new IllegalArgumentException("The lines array must be four elements long."); 126 | handle.getStringArrays().write(0, lines); 127 | } 128 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import org.bukkit.World; 21 | import org.bukkit.entity.Entity; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketContainer; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction; 27 | 28 | public class WrapperPlayClientUseEntity extends AbstractPacket { 29 | public static final PacketType TYPE = PacketType.Play.Client.USE_ENTITY; 30 | 31 | public WrapperPlayClientUseEntity() { 32 | super(new PacketContainer(TYPE), TYPE); 33 | handle.getModifier().writeDefaults(); 34 | } 35 | 36 | public WrapperPlayClientUseEntity(PacketContainer packet) { 37 | super(packet, TYPE); 38 | } 39 | 40 | /** 41 | * Retrieve the entity ID the player is interacting with. 42 | * @return The current Target 43 | */ 44 | public int getTargetID() { 45 | return handle.getIntegers().read(0); 46 | } 47 | 48 | /** 49 | * Retrieve the entity the player is interacting with. 50 | * @param event - the world this event occured in. 51 | * @return The target entity. 52 | */ 53 | public Entity getTarget(World world) { 54 | return handle.getEntityModifier(world).read(0); 55 | } 56 | 57 | /** 58 | * Retrieve the entity the player is interacting with. 59 | * @param event - the current packet event. 60 | * @return The target entity. 61 | */ 62 | public Entity getTarget(PacketEvent event) { 63 | return getTarget(event.getPlayer().getWorld()); 64 | } 65 | 66 | /** 67 | * Set the entity ID the player is interacting with. 68 | * @param value - new value. 69 | */ 70 | public void setTargetID(int value) { 71 | handle.getIntegers().write(0, value); 72 | } 73 | 74 | /** 75 | * Retrieve the use action. 76 | * @return The action. 77 | */ 78 | public EntityUseAction getMouse() { 79 | return handle.getEntityUseActions().read(0); 80 | } 81 | 82 | /** 83 | * Set the use action. 84 | * @param value - new action. 85 | */ 86 | public void setMouse(EntityUseAction value) { 87 | handle.getEntityUseActions().write(0, value); 88 | } 89 | } 90 | 91 | 92 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAbilities.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | 6 | public class WrapperPlayServerAbilities extends AbstractPacket { 7 | public static final PacketType TYPE = PacketType.Play.Server.ABILITIES; 8 | 9 | public WrapperPlayServerAbilities() { 10 | super(new PacketContainer(TYPE), TYPE); 11 | handle.getModifier().writeDefaults(); 12 | } 13 | 14 | public WrapperPlayServerAbilities(PacketContainer packet) { 15 | super(packet, TYPE); 16 | } 17 | 18 | /** 19 | * Retrieve whether or not the current player is in creative mode. 20 | * @return Creative mode. 21 | */ 22 | public boolean isCreativeMode() { 23 | return handle.getSpecificModifier(boolean.class).read(0); 24 | } 25 | 26 | /** 27 | * Set whether or not the current player is in creative mode. 28 | * @param value - new value. 29 | */ 30 | public void setCreativeMode(boolean value) { 31 | handle.getSpecificModifier(boolean.class).write(0, value); 32 | } 33 | 34 | /** 35 | * Retrieve whether or not the current player is flying. 36 | * @return Creative mode. 37 | */ 38 | public boolean isFlying() { 39 | return handle.getSpecificModifier(boolean.class).read(1); 40 | } 41 | 42 | /** 43 | * Set whether or not the current player is flying. 44 | * @param value - new value. 45 | */ 46 | public void setFlying(boolean value) { 47 | handle.getSpecificModifier(boolean.class).write(1, value); 48 | } 49 | 50 | /** 51 | * Retrieve whether or not the current player is allowed to fly. 52 | * @return Creative mode. 53 | */ 54 | public boolean isFlyingAllowed() { 55 | return handle.getSpecificModifier(boolean.class).read(2); 56 | } 57 | 58 | /** 59 | * Set whether or not the current player is allowed to fly. 60 | * @param value - new value. 61 | */ 62 | public void setFlyingAllowed(boolean value) { 63 | handle.getSpecificModifier(boolean.class).write(2, value); 64 | } 65 | 66 | /** 67 | * Retrieve whether or not the current player is in god mode. 68 | * @return Creative mode. 69 | */ 70 | public boolean isGodMode() { 71 | return handle.getSpecificModifier(boolean.class).read(3); 72 | } 73 | 74 | /** 75 | * Set whether or not the current player is in god mode. 76 | * @param value - new value. 77 | */ 78 | public void setGodMode(boolean value) { 79 | handle.getSpecificModifier(boolean.class).write(3, value); 80 | } 81 | 82 | /** 83 | * Retrieve the current flying speed. 84 | * @return The current Flying speed 85 | */ 86 | public float getFlyingSpeed() { 87 | return handle.getFloat().read(0); 88 | } 89 | 90 | /** 91 | * Set the current flying speed. 92 | * @param value - new value. 93 | */ 94 | public void setFlyingSpeed(float value) { 95 | handle.getFloat().write(0, value); 96 | } 97 | 98 | /** 99 | * Retrieve the current walking speed. 100 | * @return The current walking speed 101 | */ 102 | public float getWalkingSpeed() { 103 | return handle.getFloat().read(1); 104 | } 105 | 106 | /** 107 | * Set the current walking speed. 108 | * @param value - walking value. 109 | */ 110 | public void setWalkingSpeed(float value) { 111 | handle.getFloat().write(1, value); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAnimation.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.entity.Entity; 5 | 6 | import com.comphenix.protocol.PacketType; 7 | import com.comphenix.protocol.events.PacketContainer; 8 | import com.comphenix.protocol.events.PacketEvent; 9 | import com.comphenix.protocol.reflect.IntEnum; 10 | 11 | public class WrapperPlayServerAnimation extends AbstractPacket { 12 | /** 13 | * Represents the different animations sent by notchian clients. 14 | * 15 | * @author Kristian 16 | */ 17 | public static class Animations extends IntEnum { 18 | public static final int SWING_ARM = 0; 19 | public static final int DAMAGE_ANIMATION = 1; 20 | public static final int LEAVE_BED = 2; 21 | public static final int EAT_FOOD = 3; 22 | public static final int CRITICAL_EFFECT = 4; 23 | public static final int MAGIC_CRITICAL_EFFECT = 5; 24 | public static final int UNKNOWN = 102; 25 | public static final int CROUCH = 104; 26 | public static final int UNCROUCH = 105; 27 | 28 | /** 29 | * The singleton instance. Can also be retrieved from the parent class. 30 | */ 31 | private static Animations INSTANCE = new Animations(); 32 | 33 | /** 34 | * Retrieve an instance of the Animation enum. 35 | * @return Animation enum. 36 | */ 37 | public static Animations getInstance() { 38 | return INSTANCE; 39 | } 40 | } 41 | 42 | public static final PacketType TYPE = PacketType.Play.Server.ANIMATION; 43 | 44 | public WrapperPlayServerAnimation() { 45 | super(new PacketContainer(TYPE), TYPE); 46 | handle.getModifier().writeDefaults(); 47 | } 48 | 49 | public WrapperPlayServerAnimation(PacketContainer packet) { 50 | super(packet, TYPE); 51 | } 52 | 53 | /** 54 | * Retrieve the player ID. 55 | * @return The current EID 56 | */ 57 | public int getEntityID() { 58 | return handle.getIntegers().read(0); 59 | } 60 | 61 | /** 62 | * Set the player ID. 63 | * @param value - new value. 64 | */ 65 | public void setEntityID(int value) { 66 | handle.getIntegers().write(0, value); 67 | } 68 | 69 | /** 70 | * Retrieve the player's entity object. 71 | * @param world - the word the player has joined. 72 | * @return The player's entity. 73 | */ 74 | public Entity getEntity(World world) { 75 | return handle.getEntityModifier(world).read(0); 76 | } 77 | 78 | /** 79 | * Retrieve the player's entity object. 80 | * @param event - the packet event. 81 | * @return The player's entity. 82 | */ 83 | public Entity getEntity(PacketEvent event) { 84 | return getEntity(event.getPlayer().getWorld()); 85 | } 86 | 87 | /** 88 | * Retrieve animation ID. 89 | * @see {@link WrapperPlayServerAnimation.Animations}. 90 | * @return The current Animation 91 | */ 92 | public int getAnimation() { 93 | return handle.getIntegers().read(1); 94 | } 95 | 96 | /** 97 | * Set animation ID. 98 | * @see {@link WrapperPlayServerAnimation.Animations}. 99 | * @param value - new value. 100 | */ 101 | public void setAnimation(int value) { 102 | handle.getIntegers().write(1, value); 103 | } 104 | } 105 | 106 | 107 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAttachEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import org.bukkit.World; 21 | import org.bukkit.entity.Entity; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketContainer; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | 27 | public class WrapperPlayServerAttachEntity extends AbstractPacket { 28 | public static final PacketType TYPE = PacketType.Play.Server.ATTACH_ENTITY; 29 | 30 | public WrapperPlayServerAttachEntity() { 31 | super(new PacketContainer(TYPE), TYPE); 32 | handle.getModifier().writeDefaults(); 33 | } 34 | 35 | public WrapperPlayServerAttachEntity(PacketContainer packet) { 36 | super(packet, TYPE); 37 | } 38 | 39 | /** 40 | * Retrieve whether or not the entity is leached onto the vehicle. 41 | * @return TRUE if it is, FALSE otherwise. 42 | */ 43 | public boolean getLeached() { 44 | return handle.getIntegers().read(0) != 0; 45 | } 46 | 47 | /** 48 | * Set whether or not the entity is leached onto the vehicle. 49 | * @param value - TRUE if it is leached, FALSE otherwise. 50 | */ 51 | public void setLeached(boolean value) { 52 | handle.getIntegers().write(0, value ? 1 : 0); 53 | } 54 | 55 | /** 56 | * Retrieve the player entity ID being attached. 57 | * @return The current Entity ID 58 | */ 59 | public int getEntityId() { 60 | return handle.getIntegers().read(1); 61 | } 62 | 63 | /** 64 | * Set the player entity ID being attached. 65 | * @param value - new value. 66 | */ 67 | public void setEntityId(int value) { 68 | handle.getIntegers().write(1, value); 69 | } 70 | 71 | /** 72 | * Retrieve the entity being attached. 73 | * @param world - the current world of the entity. 74 | * @return The entity. 75 | */ 76 | public Entity getEntity(World world) { 77 | return handle.getEntityModifier(world).read(1); 78 | } 79 | 80 | /** 81 | * Retrieve the entity being attached. 82 | * @param event - the packet event. 83 | * @return The entity. 84 | */ 85 | public Entity getEntity(PacketEvent event) { 86 | return getEntity(event.getPlayer().getWorld()); 87 | } 88 | 89 | /** 90 | * Retrieve the vehicle entity ID attached to (-1 for unattaching). 91 | * @return The current Vehicle ID 92 | */ 93 | public int getVehicleId() { 94 | return handle.getIntegers().read(2); 95 | } 96 | 97 | /** 98 | * Set the vehicle entity ID attached to (-1 for unattaching). 99 | * @param value - new value. 100 | */ 101 | public void setVehicleId(int value) { 102 | handle.getIntegers().write(2, value); 103 | } 104 | 105 | /** 106 | * Retrieve the vehicle entity attached to (NULL for unattaching). 107 | * @param world - the current world of the entity. 108 | * @return The vehicle. 109 | */ 110 | public Entity getVehicle(World world) { 111 | return handle.getEntityModifier(world).read(2); 112 | } 113 | 114 | /** 115 | * Retrieve the vehicle entity attached to (NULL for unattaching). 116 | * @param event - the packet event. 117 | * @return The vehicle. 118 | */ 119 | public Entity getVehicle(PacketEvent event) { 120 | return getVehicle(event.getPlayer().getWorld()); 121 | } 122 | } 123 | 124 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.Material; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketContainer; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | 27 | public class WrapperPlayServerBlockChange extends AbstractPacket { 28 | public static final PacketType TYPE = PacketType.Play.Server.BLOCK_CHANGE; 29 | 30 | public WrapperPlayServerBlockChange() { 31 | super(new PacketContainer(TYPE), TYPE); 32 | handle.getModifier().writeDefaults(); 33 | } 34 | 35 | public WrapperPlayServerBlockChange(PacketContainer packet) { 36 | super(packet, TYPE); 37 | } 38 | 39 | /** 40 | * Retrieve block X Coordinate. 41 | * @return The current X 42 | */ 43 | public int getX() { 44 | return handle.getIntegers().read(0); 45 | } 46 | 47 | /** 48 | * Set block X Coordinate. 49 | * @param value - new value. 50 | */ 51 | public void setX(int value) { 52 | handle.getIntegers().write(0, value); 53 | } 54 | 55 | /** 56 | * Retrieve block Y Coordinate. 57 | * @return The current Y 58 | */ 59 | public int getY() { 60 | return handle.getIntegers().read(1); 61 | } 62 | 63 | /** 64 | * Set block Y Coordinate. 65 | * @param value - new value. 66 | */ 67 | public void setY(int value) { 68 | handle.getIntegers().write(1, value); 69 | } 70 | 71 | /** 72 | * Retrieve block Z Coordinate. 73 | * @return The current Z 74 | */ 75 | public int getZ() { 76 | return handle.getIntegers().read(2); 77 | } 78 | 79 | /** 80 | * Set block Z Coordinate. 81 | * @param value - new value. 82 | */ 83 | public void setZ(int value) { 84 | handle.getIntegers().write(2, value); 85 | } 86 | 87 | /** 88 | * Retrieve the location of the block that is changing. 89 | * @param event - the parent event. 90 | * @return The location. 91 | */ 92 | public Location getLocation(PacketEvent event) { 93 | return new Location(event.getPlayer().getWorld(), getX(), getY(), getZ()); 94 | } 95 | 96 | /** 97 | * Set the location of the block that is changing. 98 | * @param loc - the new location. 99 | */ 100 | public void setLocation(Location loc) { 101 | setX(loc.getBlockX()); 102 | setY((byte) loc.getBlockY()); 103 | setZ(loc.getBlockZ()); 104 | } 105 | 106 | /** 107 | * Retrieve the new type of the block. 108 | * @return The current Block ID 109 | */ 110 | public Material getBlockType() { 111 | return handle.getBlocks().read(0); 112 | } 113 | 114 | /** 115 | * Set the new type of the block. 116 | * @param value - new value. 117 | */ 118 | public void setBlockType(Material value) { 119 | handle.getBlocks().write(0, value); 120 | } 121 | 122 | /** 123 | * Retrieve the new Metadata for the block. 124 | * @return The current Block Metadata 125 | */ 126 | public byte getBlockMetadata() { 127 | return handle.getIntegers().read(3).byteValue(); 128 | } 129 | 130 | /** 131 | * Set the new Metadata for the block. 132 | * @param value - new value. 133 | */ 134 | public void setBlockMetadata(byte value) { 135 | handle.getIntegers().write(3, (int) value); 136 | } 137 | } 138 | 139 | 140 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerChat.java: -------------------------------------------------------------------------------- 1 | package com.comphenix.packetwrapper; 2 | 3 | import com.comphenix.protocol.PacketType; 4 | import com.comphenix.protocol.events.PacketContainer; 5 | import com.comphenix.protocol.wrappers.WrappedChatComponent; 6 | 7 | public class WrapperPlayServerChat extends AbstractPacket { 8 | public static final PacketType TYPE = PacketType.Play.Server.CHAT; 9 | 10 | public WrapperPlayServerChat() { 11 | super(new PacketContainer(TYPE), TYPE); 12 | handle.getModifier().writeDefaults(); 13 | } 14 | 15 | public WrapperPlayServerChat(PacketContainer packet) { 16 | super(packet, TYPE); 17 | } 18 | 19 | /** 20 | * Retrieve the chat message. 21 | * @return The current JSON Data 22 | */ 23 | public WrappedChatComponent getMessage() { 24 | return handle.getChatComponents().read(0); 25 | } 26 | 27 | /** 28 | * Set the chat message. 29 | * @param value - new value. 30 | */ 31 | public void setMessage(WrappedChatComponent value) { 32 | handle.getChatComponents().write(0, value); 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCloseWindow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | package com.comphenix.packetwrapper; 18 | 19 | import com.comphenix.protocol.PacketType; 20 | import com.comphenix.protocol.events.PacketContainer; 21 | 22 | public class WrapperPlayServerCloseWindow extends AbstractPacket { 23 | public static final PacketType TYPE = PacketType.Play.Server.CLOSE_WINDOW; 24 | 25 | public WrapperPlayServerCloseWindow() { 26 | super(new PacketContainer(TYPE), TYPE); 27 | handle.getModifier().writeDefaults(); 28 | } 29 | 30 | public WrapperPlayServerCloseWindow(PacketContainer packet) { 31 | super(packet, TYPE); 32 | } 33 | 34 | /** 35 | * Retrieve this is the id of the window that was or should be closed. 36 | * @return The current Window id 37 | */ 38 | public byte getWindowId() { 39 | return handle.getIntegers().read(0).byteValue(); 40 | } 41 | 42 | /** 43 | * Set this is the id of the window that was or should be closed. 44 | * @param value - new value. 45 | */ 46 | public void setWindowId(byte value) { 47 | handle.getIntegers().write(0, (int) value); 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCollect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import org.bukkit.World; 21 | import org.bukkit.entity.Entity; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketContainer; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | 27 | /** 28 | * Sent by the server when an iten stack is collected from the ground. This packet simply 29 | * initiates the collect item animation, nothing more. 30 | * 31 | * @author Kristian 32 | */ 33 | public class WrapperPlayServerCollect extends AbstractPacket { 34 | public static final PacketType TYPE = PacketType.Play.Server.COLLECT; 35 | 36 | public WrapperPlayServerCollect() { 37 | super(new PacketContainer(TYPE), TYPE); 38 | handle.getModifier().writeDefaults(); 39 | } 40 | 41 | public WrapperPlayServerCollect(PacketContainer packet) { 42 | super(packet, TYPE); 43 | } 44 | 45 | /** 46 | * Retrieve the entity ID of the item we collected. 47 | * @return The current collected entity ID. 48 | */ 49 | public int getCollectedEntityID() { 50 | return handle.getIntegers().read(0); 51 | } 52 | 53 | /** 54 | * Retrieve the item stack that has been collected. 55 | * @param world - the current world of the item stack. 56 | * @return The item stack entity. 57 | */ 58 | public Entity getCollectedEntity(World world) { 59 | return handle.getEntityModifier(world).read(0); 60 | } 61 | 62 | /** 63 | * Retrieve the item stack that has been collected. 64 | * @param event - the packet event. 65 | * @return The item stack entity. 66 | */ 67 | public Entity getCollectedEntity(PacketEvent event) { 68 | return getCollectedEntity(event.getPlayer().getWorld()); 69 | } 70 | 71 | /** 72 | * Set the entity ID of the item we collected. 73 | * @param value - new value. 74 | */ 75 | public void setCollectedEntityID(int value) { 76 | handle.getIntegers().write(0, value); 77 | } 78 | 79 | /** 80 | * Retrieve the entity ID of the player that collected the item. 81 | * @return The current Collector EID 82 | */ 83 | public int getCollectorEntityID() { 84 | return handle.getIntegers().read(1); 85 | } 86 | 87 | /** 88 | * Set the entity ID of the player that collected the item. 89 | * @param value - new value. 90 | */ 91 | public void setCollectorEntityID(int value) { 92 | handle.getIntegers().write(1, value); 93 | } 94 | 95 | /** 96 | * Retrieve the player that has collected the item. 97 | * @param world - the current world of the player. 98 | * @return The player. 99 | */ 100 | public Entity getCollectorEntity(World world) { 101 | return handle.getEntityModifier(world).read(1); 102 | } 103 | 104 | /** 105 | * Retrieve the player that has collected the item. 106 | * @param event - the packet event. 107 | * @return The player. 108 | */ 109 | public Entity getCollectorEntity(PacketEvent event) { 110 | return getCollectorEntity(event.getPlayer().getWorld()); 111 | } 112 | } -------------------------------------------------------------------------------- /PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCraftProgressBar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PacketWrapper - Contains wrappers for each packet in Minecraft. 3 | * Copyright (C) 2012 Kristian S. Stangeland 4 | * 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the 6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program; 14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 15 | * 02111-1307 USA 16 | */ 17 | 18 | package com.comphenix.packetwrapper; 19 | 20 | import com.comphenix.protocol.PacketType; 21 | import com.comphenix.protocol.events.PacketContainer; 22 | 23 | public class WrapperPlayServerCraftProgressBar extends AbstractPacket { 24 | public static final PacketType TYPE = PacketType.Play.Server.CRAFT_PROGRESS_BAR; 25 | 26 | /** 27 | * List of properties for furnaces. 28 | * 29 | * @author Kristian 30 | */ 31 | public static class FurnaceProperties { 32 | /** 33 | * The value is then in the range 0 - 180. 34 | */ 35 | public static final int PROGRESS_ARROW = 0; 36 | 37 | /** 38 | * The value is in the range 0 - 250. 39 | */ 40 | public static final int PROGRESS_FIRE_ICON = 1; 41 | 42 | private static FurnaceProperties INSTANCE = new FurnaceProperties(); 43 | 44 | public static FurnaceProperties getInstace() { 45 | return INSTANCE; 46 | } 47 | } 48 | 49 | public WrapperPlayServerCraftProgressBar() { 50 | super(new PacketContainer(TYPE), TYPE); 51 | handle.getModifier().writeDefaults(); 52 | } 53 | 54 | public WrapperPlayServerCraftProgressBar(PacketContainer packet) { 55 | super(packet, TYPE); 56 | } 57 | 58 | /** 59 | * Retrieve the id of the window to update. 60 | * @return The current Window id 61 | */ 62 | public byte getWindowId() { 63 | return handle.getIntegers().read(0).byteValue(); 64 | } 65 | 66 | /** 67 | * Set the id of the window to update. 68 | * @param value - new value. 69 | */ 70 | public void setWindowId(byte value) { 71 | handle.getIntegers().write(0, (int) value); 72 | } 73 | 74 | /** 75 | * Retrieve which property should be updated. 76 | *
77 | * For the enchantment table, this is the slot ID. 78 | * @see {@link FurnaceProperties} 79 | * @return The current Property 80 | */ 81 | public short getProperty() { 82 | return handle.getIntegers().read(1).shortValue(); 83 | } 84 | 85 | /** 86 | * Set which property should be updated. 87 | *
88 | * For the enchantment table, this is the slot ID. 89 | * @see {@link FurnaceProperties} 90 | * @param value - new value. 91 | */ 92 | public void setProperty(short value) { 93 | handle.getIntegers().write(1, (int) value); 94 | } 95 | 96 | /** 97 | * Retrieve the new value for the property. 98 | *
99 | * For the enchantment table, this is the enchanting level in the given slot. 100 | * @return The current Value 101 | */ 102 | public short getValue() { 103 | return handle.getIntegers().read(2).shortValue(); 104 | } 105 | 106 | /** 107 | * Set the new value for the property. 108 | *
109 | * For the enchantment table, this is the enchanting level in the given slot.
110 | * @param value - new value.
111 | */
112 | public void setValue(short value) {
113 | handle.getIntegers().write(2, (int) value);
114 | }
115 | }
116 |
117 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomPayload.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 |
23 | public class WrapperPlayServerCustomPayload extends AbstractPacket {
24 | public static final PacketType TYPE = PacketType.Play.Server.CUSTOM_PAYLOAD;
25 |
26 | public WrapperPlayServerCustomPayload() {
27 | super(new PacketContainer(TYPE), TYPE);
28 | handle.getModifier().writeDefaults();
29 | }
30 |
31 | public WrapperPlayServerCustomPayload(PacketContainer packet) {
32 | super(packet, TYPE);
33 | }
34 |
35 | /**
36 | * Retrieve name of the "channel" used to send the data..
37 | * @return The current Channel
38 | */
39 | public String getChannel() {
40 | return handle.getStrings().read(0);
41 | }
42 |
43 | /**
44 | * Set name of the "channel" used to send the data..
45 | * @param value - new value.
46 | */
47 | public void setChannel(String value) {
48 | handle.getStrings().write(0, value);
49 | }
50 |
51 | /**
52 | * Retrieve the custom data that sent in this message.
53 | * @return The current data
54 | */
55 | public byte[] getData() {
56 | return handle.getByteArrays().read(0);
57 | }
58 |
59 | /**
60 | * Set the custom data that is sent.
61 | * @param value - new value.
62 | */
63 | public void setData(byte[] value) {
64 | handle.getByteArrays().write(0, value);
65 | }
66 | }
67 |
68 |
69 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.World;
21 | import org.bukkit.entity.Entity;
22 |
23 | import com.comphenix.protocol.PacketType;
24 | import com.comphenix.protocol.events.PacketContainer;
25 | import com.comphenix.protocol.events.PacketEvent;
26 |
27 | public class WrapperPlayServerEntity extends AbstractPacket {
28 | public static final PacketType TYPE = PacketType.Play.Server.ENTITY;
29 |
30 | public WrapperPlayServerEntity() {
31 | super(new PacketContainer(TYPE), TYPE);
32 | handle.getModifier().writeDefaults();
33 | }
34 |
35 | public WrapperPlayServerEntity(PacketContainer packet) {
36 | super(packet, TYPE);
37 | }
38 |
39 | protected WrapperPlayServerEntity(PacketContainer packet, PacketType type) {
40 | super(packet, type);
41 | }
42 |
43 | /**
44 | * Retrieve entity ID.
45 | * @return The current EID
46 | */
47 | public int getEntityID() {
48 | return handle.getIntegers().read(0);
49 | }
50 |
51 | /**
52 | * Set entity ID.
53 | * @param value - new value.
54 | */
55 | public void setEntityID(int value) {
56 | handle.getIntegers().write(0, value);
57 | }
58 |
59 | /**
60 | * Retrieve the entity.
61 | * @param world - the current world of the entity.
62 | * @return The entity.
63 | */
64 | public Entity getEntity(World world) {
65 | return handle.getEntityModifier(world).read(0);
66 | }
67 |
68 | /**
69 | * Retrieve the entity.
70 | * @param event - the packet event.
71 | * @return The entity.
72 | */
73 | public Entity getEntity(PacketEvent event) {
74 | return getEntity(event.getPlayer().getWorld());
75 | }
76 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityDestroy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import java.util.List;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 | import com.google.common.primitives.Ints;
25 |
26 | public class WrapperPlayServerEntityDestroy extends AbstractPacket {
27 | public static final PacketType TYPE = PacketType.Play.Server.ENTITY_DESTROY;
28 |
29 | public WrapperPlayServerEntityDestroy() {
30 | super(new PacketContainer(TYPE), TYPE);
31 | handle.getModifier().writeDefaults();
32 | }
33 |
34 | public WrapperPlayServerEntityDestroy(PacketContainer packet) {
35 | super(packet, TYPE);
36 | }
37 |
38 | /**
39 | * Retrieve the IDs of the entities that will be destroyed.
40 | * @return The current entities.
41 | */
42 | public List
77 | * Here zero indicates a held weapon or item, while 1 is boots, 2 is leggings,
78 | * 3 is chestplate and 4 is helmet.
79 | * @return The current slot
80 | */
81 | public short getSlot() {
82 | return handle.getIntegers().read(1).shortValue();
83 | }
84 |
85 | /**
86 | * Set equipment slot.
87 | *
88 | * Here zero indicates a held weapon or item, while 1 is boots, 2 is leggings,
89 | * 3 is chestplate and 4 is helmet.
90 | * @param value - new value.
91 | */
92 | public void setSlot(short value) {
93 | handle.getIntegers().write(1, (int) value);
94 | }
95 |
96 | /**
97 | * Retrieve the equipped item.
98 | * @return The current item
99 | */
100 | public ItemStack getItem() {
101 | return handle.getItemModifier().read(0);
102 | }
103 |
104 | /**
105 | * Set the equipped item.
106 | * @param value - new value.
107 | */
108 | public void setItem(ItemStack value) {
109 | handle.getItemModifier().write(0, value);
110 | }
111 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityHeadRotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.World;
21 | import org.bukkit.entity.Entity;
22 |
23 | import com.comphenix.protocol.PacketType;
24 | import com.comphenix.protocol.events.PacketContainer;
25 | import com.comphenix.protocol.events.PacketEvent;
26 |
27 | public class WrapperPlayServerEntityHeadRotation extends AbstractPacket {
28 | public static final PacketType TYPE = PacketType.Play.Server.ENTITY_HEAD_ROTATION;
29 |
30 | public WrapperPlayServerEntityHeadRotation() {
31 | super(new PacketContainer(TYPE), TYPE);
32 | handle.getModifier().writeDefaults();
33 | }
34 |
35 | public WrapperPlayServerEntityHeadRotation(PacketContainer packet) {
36 | super(packet, TYPE);
37 | }
38 |
39 | /**
40 | * Retrieve the entity ID.
41 | * @return The current Entity ID
42 | */
43 | public int getEntityId() {
44 | return handle.getIntegers().read(0);
45 | }
46 |
47 | /**
48 | * Set the entity ID.
49 | * @param value - new value.
50 | */
51 | public void setEntityId(int value) {
52 | handle.getIntegers().write(0, value);
53 | }
54 |
55 | /**
56 | * Retrieve the entity.
57 | * @param world - the current world of the entity.
58 | * @return The entity.
59 | */
60 | public Entity getEntity(World world) {
61 | return handle.getEntityModifier(world).read(0);
62 | }
63 |
64 | /**
65 | * Retrieve the entity.
66 | * @param event - the packet event.
67 | * @return The entity.
68 | */
69 | public Entity getEntity(PacketEvent event) {
70 | return getEntity(event.getPlayer().getWorld());
71 | }
72 |
73 | /**
74 | * Retrieve the yaw of the entity's head.
75 | * @return The current yaw.
76 | */
77 | public float getHeadYaw() {
78 | return (handle.getBytes().read(0) * 360.F) / 256.0F;
79 | }
80 |
81 | /**
82 | * Set the yaw of the entity's head.
83 | * @param value - new yaw.
84 | */
85 | public void setHeadYaw(float value) {
86 | handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F));
87 | }
88 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityLook.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 |
23 | public class WrapperPlayServerEntityLook extends WrapperPlayServerEntity {
24 | public static final PacketType TYPE = PacketType.Play.Server.ENTITY_LOOK;
25 |
26 | public WrapperPlayServerEntityLook() {
27 | super(new PacketContainer(TYPE), TYPE);
28 | handle.getModifier().writeDefaults();
29 | }
30 |
31 | public WrapperPlayServerEntityLook(PacketContainer packet) {
32 | super(packet, TYPE);
33 | }
34 |
35 | /**
36 | * Retrieve the yaw of the current entity.
37 | * @return The current Yaw
38 | */
39 | public float getYaw() {
40 | return (handle.getBytes().read(3) * 360.F) / 256.0F;
41 | }
42 |
43 | /**
44 | * Set the yaw of the current entity.
45 | * @param value - new yaw.
46 | */
47 | public void setYaw(float value) {
48 | handle.getBytes().write(3, (byte) (value * 256.0F / 360.0F));
49 | }
50 |
51 | /**
52 | * Retrieve the pitch of the current entity.
53 | * @return The current pitch
54 | */
55 | public float getPitch() {
56 | return (handle.getBytes().read(4) * 360.F) / 256.0F;
57 | }
58 |
59 | /**
60 | * Set the pitch of the current entity.
61 | * @param value - new pitch.
62 | */
63 | public void setPitch(float value) {
64 | handle.getBytes().write(4, (byte) (value * 256.0F / 360.0F));
65 | }
66 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import java.util.List;
21 |
22 | import org.bukkit.World;
23 | import org.bukkit.entity.Entity;
24 |
25 | import com.comphenix.protocol.PacketType;
26 | import com.comphenix.protocol.events.PacketContainer;
27 | import com.comphenix.protocol.events.PacketEvent;
28 | import com.comphenix.protocol.wrappers.WrappedDataWatcher;
29 | import com.comphenix.protocol.wrappers.WrappedWatchableObject;
30 |
31 | public class WrapperPlayServerEntityMetadata extends AbstractPacket {
32 | public static final PacketType TYPE = PacketType.Play.Server.ENTITY_METADATA;
33 |
34 | public WrapperPlayServerEntityMetadata() {
35 | super(new PacketContainer(TYPE), TYPE);
36 | handle.getModifier().writeDefaults();
37 | }
38 |
39 | public WrapperPlayServerEntityMetadata(PacketContainer packet) {
40 | super(packet, TYPE);
41 | }
42 |
43 | /**
44 | * Retrieve unique entity ID to update.
45 | * @return The current Entity ID
46 | */
47 | public int getEntityId() {
48 | return handle.getIntegers().read(0);
49 | }
50 |
51 | /**
52 | * Set unique entity ID to update.
53 | * @param value - new value.
54 | */
55 | public void setEntityId(int value) {
56 | handle.getIntegers().write(0, value);
57 | }
58 |
59 | /**
60 | * Retrieve the entity.
61 | * @param world - the current world of the entity.
62 | * @return The entity.
63 | */
64 | public Entity getEntity(World world) {
65 | return handle.getEntityModifier(world).read(0);
66 | }
67 |
68 | /**
69 | * Retrieve the entity.
70 | * @param event - the packet event.
71 | * @return The entity.
72 | */
73 | public Entity getEntity(PacketEvent event) {
74 | return getEntity(event.getPlayer().getWorld());
75 | }
76 |
77 | /**
78 | * Retrieve a list of all the watchable objects.
79 | *
80 | * This can be converted to a data watcher using {@link WrappedDataWatcher#WrappedDataWatcher(List) WrappedDataWatcher(List)}
81 | * @return The current metadata
82 | */
83 | public List
101 | * Only used when reason is 3.
102 | * @return The current Game mode
103 | */
104 | @SuppressWarnings("deprecation")
105 | public GameMode getGameMode() {
106 | return GameMode.getByValue(handle.getIntegers().read(1));
107 | }
108 |
109 | /**
110 | * Set the new game mode.
111 | *
112 | * Only used when reason is 3.
113 | * @param value - new value.
114 | */
115 | @SuppressWarnings("deprecation")
116 | public void setGameMode(GameMode value) {
117 | handle.getIntegers().write(1, value.getValue());
118 | }
119 | }
120 |
121 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerHeldItemSlot.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 | import com.comphenix.protocol.PacketType;
20 | import com.comphenix.protocol.events.PacketContainer;
21 |
22 | public class WrapperPlayServerHeldItemSlot extends AbstractPacket {
23 | public static final PacketType TYPE = PacketType.Play.Server.HELD_ITEM_SLOT;
24 |
25 | public WrapperPlayServerHeldItemSlot() {
26 | super(new PacketContainer(TYPE), TYPE);
27 | handle.getModifier().writeDefaults();
28 | }
29 |
30 | public WrapperPlayServerHeldItemSlot(PacketContainer packet) {
31 | super(packet, TYPE);
32 | }
33 |
34 | /**
35 | * Retrieve the slot which the player has selected (0-8).
36 | * @return The current Slot ID
37 | */
38 | public short getSlotId() {
39 | return handle.getIntegers().read(0).shortValue();
40 | }
41 |
42 | /**
43 | * Set the slot which the player has selected (0-8).
44 | * @param value - new value.
45 | */
46 | public void setSlotId(short value) {
47 | handle.getIntegers().write(0, (int) value);
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKeepAlive.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 |
6 | /**
7 | * The server will frequently send out a keep-alive, each containing a random ID.
8 | *
9 | * The client must respond with the same packet.
10 | */
11 | public class WrapperPlayServerKeepAlive extends AbstractPacket {
12 | public static final PacketType TYPE = PacketType.Play.Server.KEEP_ALIVE;
13 |
14 | public WrapperPlayServerKeepAlive() {
15 | super(new PacketContainer(TYPE), TYPE);
16 | handle.getModifier().writeDefaults();
17 | }
18 |
19 | public WrapperPlayServerKeepAlive(PacketContainer packet) {
20 | super(packet, TYPE);
21 | }
22 |
23 | /**
24 | * Retrieve the server-generated random ID.
25 | * @return The current keep-alive ID
26 | */
27 | public int getKeepAliveId() {
28 | return handle.getIntegers().read(0);
29 | }
30 |
31 | /**
32 | * Set the server-generated random ID.
33 | * @param value - new ID.
34 | */
35 | public void setKeepAliveId(int value) {
36 | handle.getIntegers().write(0, value);
37 | }
38 | }
39 |
40 |
41 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKickDisconnect.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 | import com.comphenix.protocol.wrappers.WrappedChatComponent;
6 |
7 | public class WrapperPlayServerKickDisconnect extends AbstractPacket {
8 | public static final PacketType TYPE = PacketType.Play.Server.KICK_DISCONNECT;
9 |
10 | public WrapperPlayServerKickDisconnect() {
11 | super(new PacketContainer(TYPE), TYPE);
12 | handle.getModifier().writeDefaults();
13 | }
14 |
15 | public WrapperPlayServerKickDisconnect(PacketContainer packet) {
16 | super(packet, TYPE);
17 | }
18 |
19 | /**
20 | * Retrieve the reason that is displayed to the client when the connection terminates.
21 | * @return The current Reason
22 | */
23 | public WrappedChatComponent getReason() {
24 | return handle.getChatComponents().read(0);
25 | }
26 |
27 | /**
28 | * Set the reason that is displayed to the client when the connection terminates.
29 | * @param value - new reason.
30 | */
31 | public void setReason(WrappedChatComponent value) {
32 | handle.getChatComponents().write(0, value);
33 | }
34 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import javax.annotation.Nonnull;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 |
25 | public class WrapperPlayServerMap extends AbstractPacket {
26 | public static final PacketType TYPE = PacketType.Play.Server.MAP;
27 |
28 | public WrapperPlayServerMap() {
29 | super(new PacketContainer(TYPE), TYPE);
30 | handle.getModifier().writeDefaults();
31 | }
32 |
33 | public WrapperPlayServerMap(PacketContainer packet) {
34 | super(packet, TYPE);
35 | }
36 |
37 | /**
38 | * Retrieve the damage value of the map being modified.
39 | * @return The current damage value.
40 | */
41 | public int getItemDamage() {
42 | return handle.getIntegers().read(0);
43 | }
44 |
45 | /**
46 | * Set the damage value of the item being modified.
47 | * @param value - new value.
48 | */
49 | public void setItemDamage(int value) {
50 | handle.getIntegers().write(0, value);
51 | }
52 |
53 | /**
54 | * Retrieve length of following byte array.
55 | * @return The current Text length
56 | */
57 | public byte[] getData() {
58 | return handle.getByteArrays().read(0);
59 | }
60 |
61 | /**
62 | * Set length of following byte array.
63 | * @param value - new value.
64 | */
65 | public void setData(@Nonnull byte[] value) {
66 | if (value == null)
67 | throw new IllegalArgumentException("Array cannot be NULL.");
68 | handle.getByteArrays().write(0, value);
69 | }
70 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenSignEntity.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import org.bukkit.Location;
4 |
5 | import com.comphenix.protocol.PacketType;
6 | import com.comphenix.protocol.events.PacketContainer;
7 | import com.comphenix.protocol.events.PacketEvent;
8 |
9 | /**
10 | * Sent by the server to trigger the edit sign UI.
11 | * @author Kristian
12 | */
13 | public class WrapperPlayServerOpenSignEntity extends AbstractPacket {
14 | public static final PacketType TYPE = PacketType.Play.Server.OPEN_SIGN_ENTITY;
15 |
16 | public WrapperPlayServerOpenSignEntity() {
17 | super(new PacketContainer(TYPE), TYPE);
18 | handle.getModifier().writeDefaults();
19 | }
20 |
21 | public WrapperPlayServerOpenSignEntity(PacketContainer packet) {
22 | super(packet, TYPE);
23 | }
24 |
25 | /**
26 | * Retrieve the x coordinate of the sign to edit.
27 | * @return The current X
28 | */
29 | public int getX() {
30 | return handle.getIntegers().read(0);
31 | }
32 |
33 | /**
34 | * Set the x coordinate of the sign to edit.
35 | * @param value - new value.
36 | */
37 | public void setX(int value) {
38 | handle.getIntegers().write(0, value);
39 | }
40 |
41 | /**
42 | * Retrieve the y coordinate of the sign to edit.
43 | * @return The current Y
44 | */
45 | public int getY() {
46 | return handle.getIntegers().read(1);
47 | }
48 |
49 | /**
50 | * Set the y coordinate of the sign to edit.
51 | * @param value - new value.
52 | */
53 | public void setY(int value) {
54 | handle.getIntegers().write(1, value);
55 | }
56 |
57 | /**
58 | * Retrieve the z coordinate of the sign to edit.
59 | * @return The current Z
60 | */
61 | public int getZ() {
62 | return handle.getIntegers().read(2);
63 | }
64 |
65 | /**
66 | * Set the z coordinate of the sign to edit.
67 | * @param value - new value.
68 | */
69 | public void setZ(int value) {
70 | handle.getIntegers().write(2, value);
71 | }
72 |
73 | /**
74 | * Retrieve the location of the sign.
75 | * @param event - the parent event.
76 | * @return The location.
77 | */
78 | public Location getLocation(PacketEvent event) {
79 | return new Location(event.getPlayer().getWorld(), getX(), getY(), getZ());
80 | }
81 |
82 | /**
83 | * Set the location of the sign.
84 | * @param loc - the new location.
85 | */
86 | public void setLocation(Location loc) {
87 | setX(loc.getBlockX());
88 | setY((byte) loc.getBlockY());
89 | setZ(loc.getBlockZ());
90 | }
91 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 |
23 | public class WrapperPlayServerPlayerInfo extends AbstractPacket {
24 | public static final PacketType TYPE = PacketType.Play.Server.PLAYER_INFO;
25 |
26 | public WrapperPlayServerPlayerInfo() {
27 | super(new PacketContainer(TYPE), TYPE);
28 | handle.getModifier().writeDefaults();
29 | }
30 |
31 | public WrapperPlayServerPlayerInfo(PacketContainer packet) {
32 | super(packet, TYPE);
33 | }
34 |
35 | /**
36 | * Retrieve the player name.
37 | *
38 | * Supports chat colouring. limited to 16 characters.
39 | * @return The current Player name
40 | */
41 | public String getPlayerName() {
42 | return handle.getStrings().read(0);
43 | }
44 |
45 | /**
46 | * Set the player name.
47 | *
48 | * Supports chat colouring. Limited to 16 characters.
49 | * @param value - new value.
50 | */
51 | public void setPlayerName(String value) {
52 | handle.getStrings().write(0, value);
53 | }
54 |
55 | /**
56 | * Retrieve whether or not to remove the given player from the list of online players.
57 | * @return The current Online
58 | */
59 | public boolean getOnline() {
60 | return handle.getSpecificModifier(boolean.class).read(0);
61 | }
62 |
63 | /**
64 | * Set whether or not to remove the given player from the list of online players.
65 | * @param value - new value.
66 | */
67 | public void setOnline(boolean value) {
68 | handle.getSpecificModifier(boolean.class).write(0, value);
69 | }
70 |
71 | /**
72 | * Retrieve ping in milliseconds.
73 | * @return The current Ping
74 | */
75 | public short getPing() {
76 | return handle.getIntegers().read(0).shortValue();
77 | }
78 |
79 | /**
80 | * Set ping in milliseconds.
81 | * @param value - new value.
82 | */
83 | public void setPing(short value) {
84 | handle.getIntegers().write(0, (int) value);
85 | }
86 | }
87 |
88 |
89 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPosition.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 |
6 | public class WrapperPlayServerPosition extends AbstractPacket {
7 | public static final PacketType TYPE = PacketType.Play.Server.POSITION;
8 |
9 | public WrapperPlayServerPosition() {
10 | super(new PacketContainer(TYPE), TYPE);
11 | handle.getModifier().writeDefaults();
12 | }
13 |
14 | public WrapperPlayServerPosition(PacketContainer packet) {
15 | super(packet, TYPE);
16 | }
17 |
18 | /**
19 | * Retrieve absolute position.
20 | * @return The current X
21 | */
22 | public double getX() {
23 | return handle.getDoubles().read(0);
24 | }
25 |
26 | /**
27 | * Set absolute position.
28 | * @param value - new value.
29 | */
30 | public void setX(double value) {
31 | handle.getDoubles().write(0, value);
32 | }
33 |
34 | /**
35 | * Retrieve absolute position.
36 | * @return The current Y
37 | */
38 | public double getY() {
39 | return handle.getDoubles().read(1);
40 | }
41 |
42 | /**
43 | * Set absolute position.
44 | * @param value - new value.
45 | */
46 | public void setY(double value) {
47 | handle.getDoubles().write(1, value);
48 | }
49 |
50 | /**
51 | * Retrieve absolute position.
52 | * @return The current Z
53 | */
54 | public double getZ() {
55 | return handle.getDoubles().read(2);
56 | }
57 |
58 | /**
59 | * Set absolute position.
60 | * @param value - new value.
61 | */
62 | public void setZ(double value) {
63 | handle.getDoubles().write(2, value);
64 | }
65 |
66 | /**
67 | * Retrieve absolute rotation on the X Axis, in degrees.
68 | * @return The current Yaw
69 | */
70 | public float getYaw() {
71 | return handle.getFloat().read(0);
72 | }
73 |
74 | /**
75 | * Set absolute rotation on the X Axis, in degrees.
76 | * @param value - new value.
77 | */
78 | public void setYaw(float value) {
79 | handle.getFloat().write(0, value);
80 | }
81 |
82 | /**
83 | * Retrieve absolute rotation on the Y Axis, in degrees.
84 | * @return The current Pitch
85 | */
86 | public float getPitch() {
87 | return handle.getFloat().read(1);
88 | }
89 |
90 | /**
91 | * Set absolute rotation on the Y Axis, in degrees.
92 | * @param value - new value.
93 | */
94 | public void setPitch(float value) {
95 | handle.getFloat().write(1, value);
96 | }
97 |
98 | /**
99 | * Retrieve true if the client is on the ground, False otherwise.
100 | * @return The current On Ground
101 | */
102 | public boolean getOnGround() {
103 | return handle.getSpecificModifier(boolean.class).read(0);
104 | }
105 |
106 | /**
107 | * Set true if the client is on the ground, False otherwise.
108 | * @param value - new value.
109 | */
110 | public void setOnGround(boolean value) {
111 | handle.getSpecificModifier(boolean.class).write(0, value);
112 | }
113 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMove.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 |
6 | public class WrapperPlayServerRelEntityMove extends WrapperPlayServerEntity {
7 | public static final PacketType TYPE = PacketType.Play.Server.REL_ENTITY_MOVE;
8 |
9 | public WrapperPlayServerRelEntityMove() {
10 | super(new PacketContainer(TYPE), TYPE);
11 | handle.getModifier().writeDefaults();
12 | }
13 |
14 | public WrapperPlayServerRelEntityMove(PacketContainer packet) {
15 | super(packet, TYPE);
16 | }
17 |
18 | /**
19 | * Retrieve the relative movement in the x axis.
20 | *
21 | * Note that this cannot exceed 4 blocks in either direction.
22 | * @return The current dX
23 | */
24 | public double getDx() {
25 | return handle.getBytes().read(0) / 32.0D;
26 | }
27 |
28 | /**
29 | * Set the relative movement in the x axis.
30 | *
31 | * Note that this cannot exceed 4 blocks in either direction.
32 | * @param value - new value.
33 | */
34 | public void setDx(double value) {
35 | if (Math.abs(value) > 4)
36 | throw new IllegalArgumentException("Displacement cannot exceed 4 meters.");
37 | handle.getBytes().write(0, (byte) Math.min(Math.floor(value * 32.0D), 127));
38 | }
39 |
40 | /**
41 | * Retrieve the relative movement in the y axis.
42 | *
43 | * Note that this cannot exceed 4 blocks in either direction.
44 | * @return The current dY
45 | */
46 | public double getDy() {
47 | return handle.getBytes().read(1) / 32.0D;
48 | }
49 |
50 | /**
51 | * Set the relative movement in the y axis.
52 | *
53 | * Note that this cannot exceed 4 blocks in either direction.
54 | * @param value - new value.
55 | */
56 | public void setDy(double value) {
57 | if (Math.abs(value) > 4)
58 | throw new IllegalArgumentException("Displacement cannot exceed 4 meters.");
59 | handle.getBytes().write(1, (byte) Math.min(Math.floor(value * 32.0D), 127));
60 | }
61 |
62 | /**
63 | * Retrieve the relative movement in the z axis.
64 | *
65 | * Note that this cannot exceed 4 blocks in either direction.
66 | * @return The current dZ
67 | */
68 | public double getDz() {
69 | return handle.getBytes().read(2) / 32.0D;
70 | }
71 |
72 | /**
73 | * Set the relative movement in the z axis.
74 | *
75 | * Note that this cannot exceed 4 blocks in either direction.
76 | * @param value - new value.
77 | */
78 | public void setDz(double value) {
79 | if (Math.abs(value) > 4)
80 | throw new IllegalArgumentException("Displacement cannot exceed 4 meters.");
81 | handle.getBytes().write(2, (byte) Math.min(Math.floor(value * 32.0D), 127));
82 | }
83 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRemoveEntityEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.World;
21 | import org.bukkit.entity.Entity;
22 | import org.bukkit.potion.PotionEffectType;
23 |
24 | import com.comphenix.protocol.PacketType;
25 | import com.comphenix.protocol.events.PacketContainer;
26 | import com.comphenix.protocol.events.PacketEvent;
27 |
28 | public class WrapperPlayServerRemoveEntityEffect extends AbstractPacket {
29 | public static final PacketType TYPE = PacketType.Play.Server.REMOVE_ENTITY_EFFECT;
30 |
31 | public WrapperPlayServerRemoveEntityEffect() {
32 | super(new PacketContainer(TYPE), TYPE);
33 | handle.getModifier().writeDefaults();
34 | }
35 |
36 | public WrapperPlayServerRemoveEntityEffect(PacketContainer packet) {
37 | super(packet, TYPE);
38 | }
39 |
40 | /**
41 | * Retrieve entity ID of a player.
42 | * @return The current Entity ID
43 | */
44 | public int getEntityId() {
45 | return handle.getIntegers().read(0);
46 | }
47 |
48 | /**
49 | * Set entity ID of a player.
50 | * @param value - new value.
51 | */
52 | public void setEntityId(int value) {
53 | handle.getIntegers().write(0, value);
54 | }
55 |
56 | /**
57 | * Retrieve the entity.
58 | * @param world - the current world of the entity.
59 | * @return The entity.
60 | */
61 | public Entity getEntity(World world) {
62 | return handle.getEntityModifier(world).read(0);
63 | }
64 |
65 | /**
66 | * Retrieve the entity.
67 | * @param event - the packet event.
68 | * @return The entity.
69 | */
70 | public Entity getEntity(PacketEvent event) {
71 | return getEntity(event.getPlayer().getWorld());
72 | }
73 |
74 | /**
75 | * Retrieve the ID of the effect to remove.
76 | * @return The current Effect ID
77 | */
78 | public byte getEffectId() {
79 | return handle.getBytes().read(1);
80 | }
81 |
82 | /**
83 | * Set the ID of the effect to remove.
84 | * @param value - new value.
85 | */
86 | public void setEffectId(byte value) {
87 | handle.getBytes().write(1, value);
88 | }
89 |
90 | /**
91 | * Retrieve the effect.
92 | * @return The current effect
93 | */
94 | @SuppressWarnings("deprecation")
95 | public PotionEffectType getEffect() {
96 | return PotionEffectType.getById(getEffectId());
97 | }
98 |
99 | /**
100 | * Set the effect id.
101 | * @param value - new value.
102 | */
103 | @SuppressWarnings("deprecation")
104 | public void setEffect(PotionEffectType value) {
105 | setEffectId((byte) value.getId());
106 | }
107 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRespawn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.WorldType;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 | import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
25 | import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
26 |
27 | public class WrapperPlayServerRespawn extends AbstractPacket {
28 | public static final PacketType TYPE = PacketType.Play.Server.RESPAWN;
29 |
30 | public WrapperPlayServerRespawn() {
31 | super(new PacketContainer(TYPE), TYPE);
32 | handle.getModifier().writeDefaults();
33 | }
34 |
35 | public WrapperPlayServerRespawn(PacketContainer packet) {
36 | super(packet, TYPE);
37 | }
38 |
39 | /**
40 | * Retrieve -1: The Nether, 0: The Overworld, 1: The End.
41 | * @return The current Dimension
42 | */
43 | public int getDimension() {
44 | return handle.getIntegers().read(0);
45 | }
46 |
47 | /**
48 | * Set -1: The Nether, 0: The Overworld, 1: The End.
49 | * @param value - new value.
50 | */
51 | public void setDimension(int value) {
52 | handle.getIntegers().write(0, value);
53 | }
54 |
55 | /**
56 | * Retrieve the difficulty level.
57 | * @return The current Difficulty
58 | */
59 | public Difficulty getDifficulty() {
60 | return handle.getDifficulties().read(0);
61 | }
62 |
63 | /**
64 | * Set the difficulty level.
65 | * @param value - new value.
66 | */
67 | public void setDifficulty(Difficulty value) {
68 | handle.getDifficulties().write(0, value);
69 | }
70 |
71 | /**
72 | * Retrieve the game mode of the current player.
73 | * @return The current game mode
74 | */
75 | public NativeGameMode getGameMode() {
76 | return handle.getGameModes().read(0);
77 | }
78 |
79 | /**
80 | * Set the game mode of the current player.
81 | * @param mode - new value.
82 | */
83 | public void setGameMode(NativeGameMode mode) {
84 | handle.getGameModes().write(0, mode);
85 | }
86 |
87 | /**
88 | * Retrieve the current level type.
89 | * @return The current level type
90 | */
91 | public WorldType getLevelType() {
92 | return handle.getWorldTypeModifier().read(0);
93 | }
94 |
95 | /**
96 | * Set see 0x01 login.
97 | * @param value - new world type.
98 | */
99 | public void setLevelType(WorldType value) {
100 | handle.getWorldTypeModifier().write(0, value);
101 | }
102 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardDisplayObjective.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 | import com.comphenix.protocol.reflect.IntEnum;
23 |
24 | public class WrapperPlayServerScoreboardDisplayObjective extends AbstractPacket {
25 | public static final PacketType TYPE = PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE;
26 |
27 | /**
28 | * Enumeration of all the possible scoreboard positions.
29 | * @author Kristian
30 | */
31 | public static class Positions extends IntEnum {
32 | public static final int LIST = 0;
33 | public static final int SIDEBAR = 1;
34 | public static final int BELOW_NAME = 2;
35 |
36 | private static final Positions INSTANCE = new Positions();
37 |
38 | public static Positions getInstance() {
39 | return INSTANCE;
40 | }
41 | }
42 |
43 | public WrapperPlayServerScoreboardDisplayObjective() {
44 | super(new PacketContainer(TYPE), TYPE);
45 | handle.getModifier().writeDefaults();
46 | }
47 |
48 | public WrapperPlayServerScoreboardDisplayObjective(PacketContainer packet) {
49 | super(packet, TYPE);
50 | }
51 |
52 | /**
53 | * Retrieve the {@link Positions} of the scoreboard.
54 | * @return The current Position
55 | */
56 | public byte getPosition() {
57 | return handle.getIntegers().read(0).byteValue();
58 | }
59 |
60 | /**
61 | * Set the {@link Positions} of the scoreboard.
62 | * @param value - new value.
63 | */
64 | public void setPosition(byte value) {
65 | handle.getIntegers().write(0, (int) value);
66 | }
67 |
68 | /**
69 | * Retrieve the unique name for the scoreboard to be displayed..
70 | * @return The current Score Name
71 | */
72 | public String getScoreName() {
73 | return handle.getStrings().read(0);
74 | }
75 |
76 | /**
77 | * Set the unique name for the scoreboard to be displayed..
78 | * @param value - new value.
79 | */
80 | public void setScoreName(String value) {
81 | handle.getStrings().write(0, value);
82 | }
83 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardObjective.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 | import com.comphenix.protocol.reflect.IntEnum;
23 |
24 | public class WrapperPlayServerScoreboardObjective extends AbstractPacket {
25 | public static final PacketType TYPE = PacketType.Play.Server.SCOREBOARD_OBJECTIVE;
26 |
27 | /**
28 | * Enumeration of all the known packet modes.
29 | *
30 | * @author Kristian
31 | */
32 | public static class Modes extends IntEnum {
33 | public static final int ADD_OBJECTIVE = 0;
34 | public static final int REMOVE_OBJECTIVE = 1;
35 | public static final int UPDATE_VALUE = 2;
36 |
37 | private static final Modes INSTANCE = new Modes();
38 |
39 | public static Modes getInstance() {
40 | return INSTANCE;
41 | }
42 | }
43 |
44 | public WrapperPlayServerScoreboardObjective() {
45 | super(new PacketContainer(TYPE), TYPE);
46 | handle.getModifier().writeDefaults();
47 | }
48 |
49 | public WrapperPlayServerScoreboardObjective(PacketContainer packet) {
50 | super(packet, TYPE);
51 | }
52 |
53 | /**
54 | * Retrieve an unique name for the objective.
55 | * @return The current Objective name
56 | */
57 | public String getObjectiveName() {
58 | return handle.getStrings().read(0);
59 | }
60 |
61 | /**
62 | * Set an unique name for the objective.
63 | * @param value - new value.
64 | */
65 | public void setObjectiveName(String value) {
66 | handle.getStrings().write(0, value);
67 | }
68 |
69 | /**
70 | * Retrieve the text to be displayed for the score.
71 | * @return The current Objective value
72 | */
73 | public String getObjectiveValue() {
74 | return handle.getStrings().read(1);
75 | }
76 |
77 | /**
78 | * Set the text to be displayed for the score.
79 | * @param value - new value.
80 | */
81 | public void setObjectiveValue(String value) {
82 | handle.getStrings().write(1, value);
83 | }
84 |
85 | /**
86 | * Retrieve the current packet {@link Modes}.
87 | *
88 | * This determines if the objective is added or removed.
89 | * @see {@link WrapperPlayServerScoreboardObjective.Modes}
90 | * @return The current Create/Remove
91 | */
92 | public byte getPacketMode() {
93 | return handle.getIntegers().read(0).byteValue();
94 | }
95 |
96 | /**
97 | * Set the current packet {@link Modes}.
98 | *
99 | * This determines if the objective is added or removed.
100 | * @see {@link WrapperPlayServerScoreboardObjective.Modes}
101 | * @param value - new value.
102 | */
103 | public void setPacketMode(byte value) {
104 | handle.getIntegers().write(0, (int) value);
105 | }
106 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardScore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 | import com.comphenix.protocol.reflect.IntEnum;
23 |
24 | public class WrapperPlayServerScoreboardScore extends AbstractPacket {
25 | public static final PacketType TYPE = PacketType.Play.Server.SCOREBOARD_SCORE;
26 |
27 | /**
28 | * Enumeration of all the known packet modes.
29 | *
30 | * @author Kristian
31 | */
32 | public static class Modes extends IntEnum {
33 | public static final int SET_SCORE = 0;
34 | public static final int REMOVE_SCORE = 1;
35 |
36 | private static final Modes INSTANCE = new Modes();
37 |
38 | public static Modes getInstance() {
39 | return INSTANCE;
40 | }
41 | }
42 |
43 | public WrapperPlayServerScoreboardScore() {
44 | super(new PacketContainer(TYPE), TYPE);
45 | handle.getModifier().writeDefaults();
46 | }
47 |
48 | public WrapperPlayServerScoreboardScore(PacketContainer packet) {
49 | super(packet, TYPE);
50 | }
51 |
52 | /**
53 | * Retrieve an unique name to be displayed in the list..
54 | * @return The current Item Name
55 | */
56 | public String getItemName() {
57 | return handle.getStrings().read(0);
58 | }
59 |
60 | /**
61 | * Set an unique name to be displayed in the list..
62 | * @param value - new value.
63 | */
64 | public void setItemName(String value) {
65 | handle.getStrings().write(0, value);
66 | }
67 |
68 | /**
69 | * Retrieve the current packet {@link Modes}.
70 | *
71 | * This determines if the objective is added or removed.
72 | * @return The current mode.
73 | */
74 | public byte getPacketMode() {
75 | return handle.getIntegers().read(1).byteValue();
76 | }
77 |
78 | /**
79 | * Set the current packet {@link Modes}.
80 | *
81 | * This determines if the objective is added or removed.
82 | * @param value - new value.
83 | */
84 | public void setPacketMode(byte value) {
85 | handle.getIntegers().write(1, (int) value);
86 | }
87 |
88 | /**
89 | * Retrieve the unique name for the scoreboard to be updated. Only sent when setting a score.
90 | * @return The current Score Name
91 | */
92 | public String getScoreName() {
93 | return handle.getStrings().read(1);
94 | }
95 |
96 | /**
97 | * Set the unique name for the scoreboard to be updated. Only sent when setting a score.
98 | * @param value - new value.
99 | */
100 | public void setScoreName(String value) {
101 | handle.getStrings().write(1, (String) value);
102 | }
103 |
104 | /**
105 | * Retrieve the score to be displayed next to the entry. Only sent when setting a score.
106 | * @return The current Value
107 | */
108 | public int getValue() {
109 | return handle.getIntegers().read(0);
110 | }
111 |
112 | /**
113 | * Set the score to be displayed next to the entry. Only sent when setting a score.
114 | * @param value - new value.
115 | */
116 | public void setValue(int value) {
117 | handle.getIntegers().write(0, (int) value);
118 | }
119 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetSlot.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.inventory.ItemStack;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 |
25 | public class WrapperPlayServerSetSlot extends AbstractPacket {
26 | public static final PacketType TYPE = PacketType.Play.Server.SET_SLOT;
27 |
28 | public WrapperPlayServerSetSlot() {
29 | super(new PacketContainer(TYPE), TYPE);
30 | handle.getModifier().writeDefaults();
31 | }
32 |
33 | public WrapperPlayServerSetSlot(PacketContainer packet) {
34 | super(packet, TYPE);
35 | }
36 |
37 | /**
38 | * Retrieve the window which is being updated.
39 | *
40 | * Use 0 for the player inventory. This packet will only be sent for the currently opened window while the player is
41 | * performing actions, even if it affects the player inventory. After the window is closed, a number of these packets
42 | * are sent to update the player's inventory window.
43 | * @return The current Window id
44 | */
45 | public byte getWindowId() {
46 | return handle.getIntegers().read(0).byteValue();
47 | }
48 |
49 | /**
50 | * Set the window which is being updated.
51 | *
52 | * Use 0 for the player inventory. This packet will only be sent for the currently opened window while the player is
53 | * performing actions, even if it affects the player inventory. After the window is closed, a number of these packets
54 | * are sent to update the player's inventory window.
55 | * @param value - new value.
56 | */
57 | public void setWindowId(byte value) {
58 | handle.getIntegers().write(0, (int) value);
59 | }
60 |
61 | /**
62 | * Retrieve the index of the slot that should be changed.
63 | * @return The current slot
64 | */
65 | public short getSlot() {
66 | return handle.getIntegers().read(1).shortValue();
67 | }
68 |
69 | /**
70 | * Set the index of the slot that should be changed.
71 | * @param value - new value.
72 | */
73 | public void setSlot(short value) {
74 | handle.getIntegers().write(1, (int) value);
75 | }
76 |
77 | /**
78 | * Retrieve the new updated item stack.
79 | * @return The current Slot data
80 | */
81 | public ItemStack getSlotData() {
82 | return handle.getItemModifier().read(0);
83 | }
84 |
85 | /**
86 | * Set the new item stack.
87 | * @param value - new value.
88 | */
89 | public void setSlotData(ItemStack value) {
90 | handle.getItemModifier().write(0, value);
91 | }
92 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityWeather.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 |
23 | public class WrapperPlayServerSpawnEntityWeather extends AbstractPacket {
24 | public static final PacketType TYPE = PacketType.Play.Server.SPAWN_ENTITY_WEATHER;
25 |
26 | public WrapperPlayServerSpawnEntityWeather() {
27 | super(new PacketContainer(TYPE), TYPE);
28 | handle.getModifier().writeDefaults();
29 | }
30 |
31 | public WrapperPlayServerSpawnEntityWeather(PacketContainer packet) {
32 | super(packet, TYPE);
33 | }
34 |
35 | /**
36 | * Retrieve the entity ID of the thunderbolt.
37 | * @return The current Entity ID
38 | */
39 | public int getEntityId() {
40 | return handle.getIntegers().read(0);
41 | }
42 |
43 | /**
44 | * Set the entity ID of the thunderbolt.
45 | * @param value - new value.
46 | */
47 | public void setEntityId(int value) {
48 | handle.getIntegers().write(0, value);
49 | }
50 |
51 | /**
52 | * Retrieve the global entity type.
53 | *
54 | * Currently always 1 for thunderbolt.
55 | * @return The current Type
56 | */
57 | public byte getType() {
58 | return handle.getIntegers().read(4).byteValue();
59 | }
60 |
61 | /**
62 | * Set the global entity type.
63 | *
64 | * Currently always 1 for thunderbolt.
65 | * @param value - new value.
66 | */
67 | public void setType(byte value) {
68 | handle.getIntegers().write(4, (int) value);
69 | }
70 |
71 | /**
72 | * Retrieve the x coordinate of the thunderbolt.
73 | * @return The current X
74 | */
75 | public double getX() {
76 | return handle.getIntegers().read(1) / 32.0D;
77 | }
78 |
79 | /**
80 | * Set the x coordinate of the thunderbolt.
81 | * @param value - new value.
82 | */
83 | public void setX(double value) {
84 | handle.getIntegers().write(1, (int) (value * 32.0D));
85 | }
86 |
87 | /**
88 | * Retrieve the y coordinate of the thunderbolt.
89 | * @return The current y
90 | */
91 | public double getY() {
92 | return handle.getIntegers().read(2) / 32.0D;
93 | }
94 |
95 | /**
96 | * Set the y coordinate of the thunderbolt.
97 | * @param value - new value.
98 | */
99 | public void setY(double value) {
100 | handle.getIntegers().write(2, (int) (value * 32.0D));
101 | }
102 |
103 | /**
104 | * Retrieve the z coordinate of the thunderbolt.
105 | * @return The current z
106 | */
107 | public double getZ() {
108 | return handle.getIntegers().read(3) / 32.0D;
109 | }
110 |
111 | /**
112 | * Set the z coordinate of the thunderbolt.
113 | * @param value - new value.
114 | */
115 | public void setZ(double value) {
116 | handle.getIntegers().write(3, (int) (value * 32.0D));
117 | }
118 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnPosition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.util.Vector;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 |
25 | public class WrapperPlayServerSpawnPosition extends AbstractPacket {
26 | public static final PacketType TYPE = PacketType.Play.Server.SPAWN_POSITION;
27 |
28 | public WrapperPlayServerSpawnPosition() {
29 | super(new PacketContainer(TYPE), TYPE);
30 | handle.getModifier().writeDefaults();
31 | }
32 |
33 | public WrapperPlayServerSpawnPosition(PacketContainer packet) {
34 | super(packet, TYPE);
35 | }
36 |
37 | /**
38 | * Retrieve the X coordinate of the spawn point.
39 | * @return The current x coordinate.
40 | */
41 | public int getX() {
42 | return handle.getIntegers().read(0);
43 | }
44 |
45 | /**
46 | * Set the X coordinate of the spawn point.
47 | * @param value - new value.
48 | */
49 | public void setX(int value) {
50 | handle.getIntegers().write(0, value);
51 | }
52 |
53 | /**
54 | * Retrieve the Y coordinate of the spawn point.
55 | * @return The current Y
56 | */
57 | public int getY() {
58 | return handle.getIntegers().read(1);
59 | }
60 |
61 | /**
62 | * Set the Y coordinate of the spawn point.
63 | * @param value - new value.
64 | */
65 | public void setY(int value) {
66 | handle.getIntegers().write(1, value);
67 | }
68 |
69 | /**
70 | * Retrieve the Z coordinate of the spawn point.
71 | * @return The current Z
72 | */
73 | public int getZ() {
74 | return handle.getIntegers().read(2);
75 | }
76 |
77 | /**
78 | * Set the Z coordinate of the spawn point..
79 | * @param value - new value.
80 | */
81 | public void setZ(int value) {
82 | handle.getIntegers().write(2, value);
83 | }
84 |
85 | /**
86 | * Set the spawn location using a vector.
87 | * @param point - the new spawn location.
88 | */
89 | public void setLocation(Vector point) {
90 | setX(point.getBlockX());
91 | setY(point.getBlockY());
92 | setZ(point.getBlockZ());
93 | }
94 |
95 | /**
96 | * Retrieve the spawn location as a vector.
97 | * @return The spawn location.
98 | */
99 | public Vector getLocation() {
100 | return new Vector(getX(), getY(), getZ());
101 | }
102 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStatistics.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import java.util.Map;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 | import com.comphenix.protocol.wrappers.WrappedStatistic;
25 |
26 | public class WrapperPlayServerStatistics extends AbstractPacket {
27 | public static final PacketType TYPE = PacketType.Play.Server.STATISTICS;
28 |
29 | public WrapperPlayServerStatistics() {
30 | super(new PacketContainer(TYPE), TYPE);
31 | handle.getModifier().writeDefaults();
32 | }
33 |
34 | public WrapperPlayServerStatistics(PacketContainer packet) {
35 | super(packet, TYPE);
36 | }
37 |
38 | /**
39 | * Retrieve a map of every statistic in this packet.
40 | *
41 | * Note that you must write back the map to save any changes.
42 | * @return Map of every statistics sent to the player.
43 | */
44 | public Map
54 | * This field corresponds to that number..
55 | * @return The current Action number
56 | */
57 | public short getActionNumber() {
58 | return handle.getShorts().read(0);
59 | }
60 |
61 | /**
62 | * Set every action that is to be accepted has a unique number.
63 | *
64 | * This field corresponds to that number.
65 | * @param value - new value.
66 | */
67 | public void setActionNumber(short value) {
68 | handle.getShorts().write(0, value);
69 | }
70 |
71 | /**
72 | * Retrieve whether or not the action was accepted.
73 | * @return The current Accepted?
74 | */
75 | public boolean getAccepted() {
76 | return handle.getSpecificModifier(boolean.class).read(0);
77 | }
78 |
79 | /**
80 | * Set whether or not the action was accepted.
81 | * @param value - new value.
82 | */
83 | public void setAccepted(boolean value) {
84 | handle.getSpecificModifier(boolean.class).write(0, value);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateAttributes.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import java.util.List;
4 |
5 | import org.bukkit.World;
6 | import org.bukkit.entity.Entity;
7 |
8 | import com.comphenix.protocol.PacketType;
9 | import com.comphenix.protocol.events.PacketContainer;
10 | import com.comphenix.protocol.events.PacketEvent;
11 | import com.comphenix.protocol.wrappers.WrappedAttribute;
12 |
13 | public class WrapperPlayServerUpdateAttributes extends AbstractPacket {
14 | public static final PacketType TYPE = PacketType.Play.Server.UPDATE_ATTRIBUTES;
15 |
16 | public WrapperPlayServerUpdateAttributes() {
17 | super(new PacketContainer(TYPE), TYPE);
18 | handle.getModifier().writeDefaults();
19 | }
20 |
21 | public WrapperPlayServerUpdateAttributes(PacketContainer packet) {
22 | super(packet, TYPE);
23 | }
24 |
25 | /**
26 | * Retrieve the entity's ID.
27 | * @return The current Entity ID
28 | */
29 | public int getEntityId() {
30 | return handle.getIntegers().read(0);
31 | }
32 |
33 | /**
34 | * Set the entity's ID.
35 | * @param value - new value.
36 | */
37 | public void setEntityId(int value) {
38 | handle.getIntegers().write(0, value);
39 | }
40 |
41 | /**
42 | * Retrieve the entity.
43 | * @param world - the current world of the entity.
44 | * @return The entity.
45 | */
46 | public Entity getEntity(World world) {
47 | return handle.getEntityModifier(world).read(0);
48 | }
49 |
50 | /**
51 | * Retrieve the entity.
52 | * @param event - the packet event.
53 | * @return The entity.
54 | */
55 | public Entity getEntity(PacketEvent event) {
56 | return getEntity(event.getPlayer().getWorld());
57 | }
58 |
59 | /**
60 | * Retrieve the collection of attributes associated with the entity.
61 | * @return The current attributes.
62 | */
63 | public List
38 | * Value zero or less is dead. 20 is the full HP.
39 | * @return The current Health
40 | */
41 | public float getHealth() {
42 | return handle.getFloat().read(0);
43 | }
44 |
45 | /**
46 | * Set the health of the current player.
47 | *
48 | * Value zero or less is dead. 20 is the full HP.
49 | * @param value - new value.
50 | */
51 | public void setHealth(float value) {
52 | handle.getFloat().write(0, value);
53 | }
54 |
55 | /**
56 | * Retrieve the food level.
57 | *
58 | * Valid range: 0 - 20.
59 | * @return The current food level.
60 | */
61 | public short getFood() {
62 | return handle.getIntegers().read(0).shortValue();
63 | }
64 |
65 | /**
66 | * Set the food level.
67 | *
68 | * Valid range: 0 - 20.
69 | * @param value - new value.
70 | */
71 | public void setFood(short value) {
72 | handle.getIntegers().write(0, (int) value);
73 | }
74 |
75 | /**
76 | * Retrieve the food saturation.
77 | *
78 | * Varies from 0.0 to 5.0 in integer increments.
79 | * @return The current Food Saturation
80 | */
81 | public float getFoodSaturation() {
82 | return handle.getFloat().read(1);
83 | }
84 |
85 | /**
86 | * Set the food saturation.
87 | *
88 | * Varies from 0.0 to 5.0 in integer increments.
89 | * @param value - new value.
90 | */
91 | public void setFoodSaturation(float value) {
92 | handle.getFloat().write(1, value);
93 | }
94 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateSign.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import javax.annotation.Nonnull;
21 |
22 | import org.bukkit.Location;
23 |
24 | import com.comphenix.protocol.PacketType;
25 | import com.comphenix.protocol.events.PacketContainer;
26 | import com.comphenix.protocol.events.PacketEvent;
27 |
28 | public class WrapperPlayServerUpdateSign extends AbstractPacket {
29 | public static final PacketType TYPE = PacketType.Play.Server.UPDATE_SIGN;
30 |
31 | public WrapperPlayServerUpdateSign() {
32 | super(new PacketContainer(TYPE), TYPE);
33 | handle.getModifier().writeDefaults();
34 | }
35 |
36 | public WrapperPlayServerUpdateSign(PacketContainer packet) {
37 | super(packet, TYPE);
38 | }
39 |
40 | /**
41 | * Retrieve block X Coordinate.
42 | * @return The current X
43 | */
44 | public int getX() {
45 | return handle.getIntegers().read(0);
46 | }
47 |
48 | /**
49 | * Set block X Coordinate.
50 | * @param value - new value.
51 | */
52 | public void setX(int value) {
53 | handle.getIntegers().write(0, value);
54 | }
55 |
56 | /**
57 | * Retrieve block Y Coordinate.
58 | * @return The current Y
59 | */
60 | public short getY() {
61 | return handle.getIntegers().read(1).shortValue();
62 | }
63 |
64 | /**
65 | * Set block Y Coordinate.
66 | * @param value - new value.
67 | */
68 | public void setY(short value) {
69 | handle.getIntegers().write(1, (int) value);
70 | }
71 |
72 | /**
73 | * Retrieve block Z Coordinate.
74 | * @return The current Z
75 | */
76 | public int getZ() {
77 | return handle.getIntegers().read(2);
78 | }
79 |
80 | /**
81 | * Set block Z Coordinate.
82 | * @param value - new value.
83 | */
84 | public void setZ(int value) {
85 | handle.getIntegers().write(2, value);
86 | }
87 |
88 | /**
89 | * Retrieve the location of the current particle.
90 | * @param event - the packet event.
91 | * @return The location.
92 | */
93 | public Location getLocation(PacketEvent event) {
94 | return new Location(event.getPlayer().getWorld(), getX(), getY(), getZ());
95 | }
96 |
97 | /**
98 | * Set the location of the particle to send.
99 | * @param loc - the location.
100 | */
101 | public void setLocation(Location loc) {
102 | if (loc == null)
103 | throw new IllegalArgumentException("Location cannot be NULL.");
104 | setX(loc.getBlockX());
105 | setY((short) loc.getBlockY());
106 | setZ(loc.getBlockZ());
107 | }
108 |
109 | /**
110 | * Retrieve the lines of text represented by a four-element String array.
111 | * @return The current lines.
112 | */
113 | public String[] getLines() {
114 | return handle.getStringArrays().read(0);
115 | }
116 |
117 | /**
118 | * Set the lines of text represented by a four-element String array..
119 | * @param value - new value.
120 | */
121 | public void setLines(@Nonnull String[] lines) {
122 | if (lines == null)
123 | throw new IllegalArgumentException("Array cannot be NULL.");
124 | if (lines.length != 4)
125 | throw new IllegalArgumentException("The lines array must be four elements long.");
126 | handle.getStringArrays().write(0, lines);
127 | }
128 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import com.comphenix.protocol.PacketType;
21 | import com.comphenix.protocol.events.PacketContainer;
22 |
23 | public class WrapperPlayServerUpdateTime extends AbstractPacket {
24 | public static final PacketType TYPE = PacketType.Play.Server.UPDATE_TIME;
25 |
26 | public WrapperPlayServerUpdateTime() {
27 | super(new PacketContainer(TYPE), TYPE);
28 | handle.getModifier().writeDefaults();
29 | }
30 |
31 | public WrapperPlayServerUpdateTime(PacketContainer packet) {
32 | super(packet, TYPE);
33 | }
34 |
35 | /**
36 | * Retrieve the age of the world in ticks.
37 | *
38 | * This cannot be changed by server commands.
39 | * @return The current age of the world
40 | */
41 | public long getAgeOfTheWorld() {
42 | return handle.getLongs().read(0);
43 | }
44 |
45 | /**
46 | * Set the age of the world in ticks.
47 | *
48 | * This cannot be changed by server commands.
49 | * @param value - new value.
50 | */
51 | public void setAgeOfTheWorld(long value) {
52 | handle.getLongs().write(0, value);
53 | }
54 |
55 | /**
56 | * Retrieve the world (or region) time, in ticks.
57 | * @return The current Time of Day
58 | */
59 | public long getTimeOfDay() {
60 | return handle.getLongs().read(1);
61 | }
62 |
63 | /**
64 | * Set the world (or region) time, in ticks.
65 | * @param value - new value.
66 | */
67 | public void setTimeOfDay(long value) {
68 | handle.getLongs().write(1, value);
69 | }
70 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowItems.java:
--------------------------------------------------------------------------------
1 | /*
2 | * PacketWrapper - Contains wrappers for each packet in Minecraft.
3 | * Copyright (C) 2012 Kristian S. Stangeland
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the
6 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of
7 | * the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 | * See the GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License along with this program;
14 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15 | * 02111-1307 USA
16 | */
17 |
18 | package com.comphenix.packetwrapper;
19 |
20 | import org.bukkit.inventory.ItemStack;
21 |
22 | import com.comphenix.protocol.PacketType;
23 | import com.comphenix.protocol.events.PacketContainer;
24 |
25 | public class WrapperPlayServerWindowItems extends AbstractPacket {
26 | public static final PacketType TYPE = PacketType.Play.Server.WINDOW_ITEMS;
27 |
28 | public WrapperPlayServerWindowItems() {
29 | super(new PacketContainer(TYPE), TYPE);
30 | handle.getModifier().writeDefaults();
31 | }
32 |
33 | public WrapperPlayServerWindowItems(PacketContainer packet) {
34 | super(packet, TYPE);
35 | }
36 |
37 | /**
38 | * Retrieve the ID of the window which is being updated.
39 | *
40 | * Use 0 for the player inventory.
41 | * @return The current Window id
42 | */
43 | public byte getWindowId() {
44 | return handle.getIntegers().read(0).byteValue();
45 | }
46 |
47 | /**
48 | * Set the ID of the window which is being updated.
49 | *
50 | * Use 0 for the player inventory.
51 | * @param value - new value.
52 | */
53 | public void setWindowId(byte value) {
54 | handle.getIntegers().write(0, (int) value);
55 | }
56 |
57 | /**
58 | * Retrieve the items in the inventory indexed by slot index.
59 | * @return The items that will fill the inventory.
60 | */
61 | public ItemStack[] getItems() {
62 | return handle.getItemArrayModifier().read(0);
63 | }
64 |
65 | /**
66 | * Set the items in the inventory indexed by slot index.
67 | * @param value - new value.
68 | */
69 | public void setItems(ItemStack[] value) {
70 | handle.getItemArrayModifier().write(0, value);
71 | }
72 | }
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientInPing.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 |
6 | public class WrapperStatusClientInPing extends AbstractPacket {
7 | public static final PacketType TYPE = PacketType.Status.Client.IN_PING;
8 |
9 | public WrapperStatusClientInPing() {
10 | super(new PacketContainer(TYPE), TYPE);
11 | handle.getModifier().writeDefaults();
12 | }
13 |
14 | public WrapperStatusClientInPing(PacketContainer packet) {
15 | super(packet, TYPE);
16 | }
17 |
18 | /**
19 | * Retrieve the random token we are sending.
20 | * @return The current random token.
21 | */
22 | public long getToken() {
23 | return handle.getLongs().read(0);
24 | }
25 |
26 | /**
27 | * Set the random token we are sending.
28 | * @param value - new token.
29 | */
30 | public void setToken(long value) {
31 | handle.getLongs().write(0, value);
32 | }
33 | }
34 |
35 |
36 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientInStart.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 |
6 | public class WrapperStatusClientInStart extends AbstractPacket {
7 | public static final PacketType TYPE = PacketType.Status.Client.IN_START;
8 |
9 | public WrapperStatusClientInStart() {
10 | super(new PacketContainer(TYPE), TYPE);
11 | handle.getModifier().writeDefaults();
12 | }
13 |
14 | public WrapperStatusClientInStart(PacketContainer packet) {
15 | super(packet, TYPE);
16 | }
17 |
18 | // There are no fields ...
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerOutPing.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 |
6 | public class WrapperStatusServerOutPing extends AbstractPacket {
7 | public static final PacketType TYPE = PacketType.Status.Server.OUT_PING;
8 |
9 | public WrapperStatusServerOutPing() {
10 | super(new PacketContainer(TYPE), TYPE);
11 | handle.getModifier().writeDefaults();
12 | }
13 |
14 | public WrapperStatusServerOutPing(PacketContainer packet) {
15 | super(packet, TYPE);
16 | }
17 |
18 | /**
19 | * Retrieve the random token that should be the same as sent by the client.
20 | * @return The current token.
21 | */
22 | public long getTime() {
23 | return handle.getLongs().read(0);
24 | }
25 |
26 | /**
27 | * Set the random token that should be the same as sent by the client.
28 | * @param value - new token.
29 | */
30 | public void setToken(long value) {
31 | handle.getLongs().write(0, value);
32 | }
33 | }
34 |
35 |
36 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerOutServerInfo.java:
--------------------------------------------------------------------------------
1 | package com.comphenix.packetwrapper;
2 |
3 | import com.comphenix.protocol.PacketType;
4 | import com.comphenix.protocol.events.PacketContainer;
5 | import com.comphenix.protocol.wrappers.WrappedServerPing;
6 |
7 | public class WrapperStatusServerOutServerInfo extends AbstractPacket {
8 | public static final PacketType TYPE = PacketType.Status.Server.OUT_SERVER_INFO;
9 |
10 | public WrapperStatusServerOutServerInfo() {
11 | super(new PacketContainer(TYPE), TYPE);
12 | handle.getModifier().writeDefaults();
13 | }
14 |
15 | public WrapperStatusServerOutServerInfo(PacketContainer packet) {
16 | super(packet, TYPE);
17 | }
18 |
19 | /**
20 | * Retrieve the server information to display in the multiplayer menu.
21 | * @return The current ping information.
22 | */
23 | public WrappedServerPing getServerPing() {
24 | return handle.getServerPings().read(0);
25 | }
26 |
27 | /**
28 | * Set the server information to display in the multiplayer menu.
29 | * @param value - new information.
30 | */
31 | public void setServerPing(WrappedServerPing value) {
32 | handle.getServerPings().write(0, value);
33 | }
34 | }
35 |
36 |
37 |
--------------------------------------------------------------------------------
/PacketWrapper/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: PacketWrapper
2 | main: com.comphenix.packetwrapper.PacketWrapper
3 |
4 | description: Contains wrappers for each packet in Minecraft.
5 | version: 1.6.1-R0.1
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | PacketWrapper
2 | ===========
3 |
4 | When reading and writing packets in ProtocolLib, it is necessary to know the order at which the fields are stored in memory.
5 | This requires you to decompile the Minecraft source code with [JD Gui](http://java.decompiler.free.fr/?q=jdgui), while decoding the meaning of a field by looking up an online [wiki](http://www.wiki.vg/Protocol) resource
6 | ([tutorial](http://forums.bukkit.org/threads/lib-1-4-6-protocollib-2-0-0-safely-and-easily-modify-sent-and-recieved-packets.101035/page-2#post-1366140)).
7 | It would be much easier if these packets could be accessed as any other normal Java bean.
8 |
9 | Enter PacketWrapper. It contains wrapper classes for all known packets in 1.6.1, providing you with access to the fields by name, along
10 | with automatic conversion to existing Bukkit enumerations and classes. It also includes a number of custom enumerations when appropriate.
11 |
12 | You can use PacketWrapper as a dependency if you wish, though the intent is for plugin authors to simply copy-and-paste the classes they need into their
13 | project.
14 |
15 | Building
16 | --------
17 | You can compile this project yourself by using the latest version of Maven.
18 |
19 |
20 | Remarks
21 | --------
22 | This project was partly auto-generated by a script.
--------------------------------------------------------------------------------