From f4f32d9382ef099041b8e07872c0477578ec1237 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Wed, 21 Nov 2018 22:42:20 +0800 Subject: [PATCH] Try use sync task Former-commit-id: 7dd6e2782dd9177cebbf2c28f56b50bed11ada9a [formerly 1347f2cce27cf6aec093bd4951d912fc3653dc4a] Former-commit-id: 28bd9c85a99aa23e3f5ac0477f0387b1b2a856cf --- .../packetwrapper/AbstractPacket.java | 114 +++++ .../packetwrapper/ChunkPacketProcessor.java | 401 ++++++++++++++++++ .../packetwrapper/PacketWrapper.java | 28 ++ .../WrapperHandshakingClientSetProtocol.java | 118 ++++++ .../WrapperLoginClientCustomPayload.java | 57 +++ .../WrapperLoginClientEncryptionBegin.java | 72 ++++ .../WrapperLoginClientStart.java | 54 +++ .../WrapperLoginServerCustomPayload.java | 57 +++ .../WrapperLoginServerDisconnect.java | 64 +++ .../WrapperLoginServerEncryptionBegin.java | 94 ++++ .../WrapperLoginServerSetCompression.java | 57 +++ .../WrapperLoginServerSuccess.java | 54 +++ .../WrapperPlayClientAbilities.java | 99 +++++ .../WrapperPlayClientAdvancements.java | 77 ++++ .../WrapperPlayClientArmAnimation.java | 35 ++ .../WrapperPlayClientAutoRecipe.java | 64 +++ .../WrapperPlayClientBeacon.java | 73 ++++ .../WrapperPlayClientBlockDig.java | 86 ++++ .../WrapperPlayClientBlockPlace.java | 53 +++ .../WrapperPlayClientBoatMove.java | 53 +++ .../WrapperPlayClientBookEdit.java | 72 ++++ .../packetwrapper/WrapperPlayClientChat.java | 54 +++ .../WrapperPlayClientClientCommand.java | 57 +++ .../WrapperPlayClientCloseWindow.java | 56 +++ .../WrapperPlayClientCustomPayload.java | 96 +++++ .../WrapperPlayClientEnchantItem.java | 77 ++++ .../WrapperPlayClientEntityAction.java | 121 ++++++ .../WrapperPlayClientEntityNbtQuery.java | 95 +++++ .../WrapperPlayClientFlying.java | 56 +++ .../WrapperPlayClientHeldItemSlot.java | 56 +++ .../WrapperPlayClientItemName.java | 55 +++ .../WrapperPlayClientKeepAlive.java | 54 +++ .../packetwrapper/WrapperPlayClientLook.java | 96 +++++ .../WrapperPlayClientPickItem.java | 55 +++ .../WrapperPlayClientPosition.java | 117 +++++ .../WrapperPlayClientPositionLook.java | 157 +++++++ .../WrapperPlayClientRecipeDisplayed.java | 66 +++ .../WrapperPlayClientResourcePackStatus.java | 58 +++ .../WrapperPlayClientSetCommandBlock.java | 111 +++++ .../WrapperPlayClientSetCommandMinecart.java | 109 +++++ .../WrapperPlayClientSetCreativeSlot.java | 77 ++++ .../WrapperPlayClientSettings.java | 137 ++++++ .../WrapperPlayClientSpectate.java | 56 +++ .../WrapperPlayClientSteerVehicle.java | 92 ++++ .../WrapperPlayClientStructureBlock.java | 39 ++ .../WrapperPlayClientTabComplete.java | 53 +++ .../WrapperPlayClientTeleportAccept.java | 58 +++ .../WrapperPlayClientTileNbtQuery.java | 74 ++++ .../WrapperPlayClientTradeSelect.java | 21 + .../WrapperPlayClientTransaction.java | 97 +++++ .../WrapperPlayClientUpdateSign.java | 79 ++++ .../WrapperPlayClientUseEntity.java | 117 +++++ .../WrapperPlayClientUseItem.java | 138 ++++++ .../WrapperPlayClientVehicleMove.java | 137 ++++++ .../WrapperPlayClientWindowClick.java | 148 +++++++ .../WrapperPlayServerAbilities.java | 99 +++++ .../WrapperPlayServerAdvancements.java | 148 +++++++ .../WrapperPlayServerAnimation.java | 100 +++++ .../WrapperPlayServerAttachEntity.java | 99 +++++ .../WrapperPlayServerAutoRecipe.java | 54 +++ .../packetwrapper/WrapperPlayServerBed.java | 101 +++++ .../WrapperPlayServerBlockAction.java | 119 ++++++ .../WrapperPlayServerBlockBreakAnimation.java | 122 ++++++ .../WrapperPlayServerBlockChange.java | 88 ++++ .../packetwrapper/WrapperPlayServerBoss.java | 133 ++++++ .../WrapperPlayServerCamera.java | 54 +++ .../packetwrapper/WrapperPlayServerChat.java | 104 +++++ .../WrapperPlayServerCloseWindow.java | 56 +++ .../WrapperPlayServerCollect.java | 72 ++++ .../WrapperPlayServerCombatEvent.java | 136 ++++++ .../WrapperPlayServerCommands.java | 49 +++ .../WrapperPlayServerCustomPayload.java | 103 +++++ .../WrapperPlayServerCustomSoundEffect.java | 183 ++++++++ .../WrapperPlayServerEntity.java | 79 ++++ .../WrapperPlayServerEntityDestroy.java | 67 +++ .../WrapperPlayServerEntityEffect.java | 154 +++++++ .../WrapperPlayServerEntityEquipment.java | 110 +++++ .../WrapperPlayServerEntityHeadRotation.java | 100 +++++ .../WrapperPlayServerEntityLook.java | 133 ++++++ .../WrapperPlayServerEntityMetadata.java | 101 +++++ .../WrapperPlayServerEntityStatus.java | 99 +++++ .../WrapperPlayServerEntityTeleport.java | 146 +++++++ .../WrapperPlayServerEntityVelocity.java | 134 ++++++ .../WrapperPlayServerExperience.java | 92 ++++ .../WrapperPlayServerExplosion.java | 171 ++++++++ .../WrapperPlayServerGameStateChange.java | 75 ++++ .../WrapperPlayServerHeldItemSlot.java | 56 +++ .../WrapperPlayServerKeepAlive.java | 54 +++ .../WrapperPlayServerKickDisconnect.java | 59 +++ .../packetwrapper/WrapperPlayServerLogin.java | 201 +++++++++ .../WrapperPlayServerLookAt.java | 194 +++++++++ .../packetwrapper/WrapperPlayServerMap.java | 129 ++++++ .../WrapperPlayServerMapChunk.java | 138 ++++++ .../packetwrapper/WrapperPlayServerMount.java | 121 ++++++ .../WrapperPlayServerMultiBlockChange.java | 74 ++++ .../WrapperPlayServerNamedEntitySpawn.java | 204 +++++++++ .../WrapperPlayServerNamedSoundEffect.java | 156 +++++++ .../WrapperPlayServerNbtQuery.java | 74 ++++ .../WrapperPlayServerOpenSignEditor.java | 57 +++ .../WrapperPlayServerOpenWindow.java | 162 +++++++ .../WrapperPlayServerPlayerInfo.java | 55 +++ ...apperPlayServerPlayerListHeaderFooter.java | 74 ++++ .../WrapperPlayServerPosition.java | 161 +++++++ .../WrapperPlayServerRecipeUpdate.java | 38 ++ .../WrapperPlayServerRecipes.java | 98 +++++ .../WrapperPlayServerRelEntityMove.java | 122 ++++++ .../WrapperPlayServerRelEntityMoveLook.java | 188 ++++++++ .../WrapperPlayServerRemoveEntityEffect.java | 89 ++++ .../WrapperPlayServerResourcePackSend.java | 81 ++++ .../WrapperPlayServerRespawn.java | 121 ++++++ ...rPlayServerScoreboardDisplayObjective.java | 78 ++++ .../WrapperPlayServerScoreboardObjective.java | 141 ++++++ .../WrapperPlayServerScoreboardScore.java | 107 +++++ .../WrapperPlayServerScoreboardTeam.java | 279 ++++++++++++ ...WrapperPlayServerSelectAdvancementTab.java | 45 ++ .../WrapperPlayServerServerDifficulty.java | 58 +++ .../WrapperPlayServerSetCooldown.java | 96 +++++ .../WrapperPlayServerSetSlot.java | 101 +++++ .../WrapperPlayServerSpawnEntity.java | 378 +++++++++++++++++ ...perPlayServerSpawnEntityExperienceOrb.java | 160 +++++++ .../WrapperPlayServerSpawnEntityLiving.java | 315 ++++++++++++++ .../WrapperPlayServerSpawnEntityPainting.java | 118 ++++++ .../WrapperPlayServerSpawnEntityWeather.java | 160 +++++++ .../WrapperPlayServerSpawnPosition.java | 57 +++ .../WrapperPlayServerStatistic.java | 37 ++ .../WrapperPlayServerStopSound.java | 54 +++ .../WrapperPlayServerTabComplete.java | 53 +++ .../packetwrapper/WrapperPlayServerTags.java | 40 ++ .../WrapperPlayServerTileEntityData.java | 97 +++++ .../packetwrapper/WrapperPlayServerTitle.java | 131 ++++++ .../WrapperPlayServerTransaction.java | 97 +++++ .../WrapperPlayServerUnloadChunk.java | 77 ++++ .../WrapperPlayServerUpdateAttributes.java | 101 +++++ .../WrapperPlayServerUpdateHealth.java | 96 +++++ .../WrapperPlayServerUpdateTime.java | 77 ++++ .../WrapperPlayServerVehicleMove.java | 137 ++++++ .../WrapperPlayServerWindowData.java | 96 +++++ .../WrapperPlayServerWindowItems.java | 79 ++++ .../WrapperPlayServerWorldBorder.java | 108 +++++ .../WrapperPlayServerWorldEvent.java | 117 +++++ .../WrapperPlayServerWorldParticles.java | 238 +++++++++++ .../WrapperStatusClientPing.java | 54 +++ .../WrapperStatusClientStart.java | 35 ++ .../WrapperStatusServerPong.java | 56 +++ .../WrapperStatusServerServerInfo.java | 57 +++ .../org/maxgamer/quickshop/Command/QS.java | 44 +- .../org/maxgamer/quickshop/Util/Util.java | 7 +- 147 files changed, 14597 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/comphenix/packetwrapper/AbstractPacket.java create mode 100644 src/main/java/com/comphenix/packetwrapper/ChunkPacketProcessor.java create mode 100644 src/main/java/com/comphenix/packetwrapper/PacketWrapper.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperHandshakingClientSetProtocol.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginClientCustomPayload.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginClientEncryptionBegin.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginClientStart.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginServerCustomPayload.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginServerDisconnect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginServerEncryptionBegin.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSetCompression.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSuccess.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAbilities.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAdvancements.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientArmAnimation.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAutoRecipe.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBeacon.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockDig.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockPlace.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBoatMove.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBookEdit.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientChat.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientClientCommand.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCloseWindow.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCustomPayload.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEnchantItem.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityAction.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityNbtQuery.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientFlying.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientHeldItemSlot.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientItemName.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientKeepAlive.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientLook.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPickItem.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPosition.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPositionLook.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientRecipeDisplayed.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientResourcePackStatus.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandBlock.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandMinecart.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCreativeSlot.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSettings.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSpectate.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSteerVehicle.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTeleportAccept.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTileNbtQuery.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTradeSelect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTransaction.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUpdateSign.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseEntity.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseItem.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientVehicleMove.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayClientWindowClick.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAbilities.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAdvancements.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAnimation.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAttachEntity.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAutoRecipe.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBed.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockAction.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockBreakAnimation.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockChange.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBoss.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCamera.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerChat.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCloseWindow.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCollect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCombatEvent.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomPayload.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomSoundEffect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntity.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityDestroy.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEffect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEquipment.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityHeadRotation.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityLook.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityStatus.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityTeleport.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityVelocity.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExperience.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExplosion.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerGameStateChange.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerHeldItemSlot.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKeepAlive.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKickDisconnect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLogin.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLookAt.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMap.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMount.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMultiBlockChange.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedEntitySpawn.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedSoundEffect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNbtQuery.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenSignEditor.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenWindow.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerInfo.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerListHeaderFooter.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPosition.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipeUpdate.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipes.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMove.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMoveLook.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRemoveEntityEffect.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerResourcePackSend.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRespawn.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardDisplayObjective.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardObjective.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardScore.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardTeam.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSelectAdvancementTab.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerServerDifficulty.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetCooldown.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetSlot.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityExperienceOrb.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityLiving.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityPainting.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityWeather.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnPosition.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStatistic.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStopSound.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTabComplete.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTags.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTileEntityData.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTitle.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTransaction.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUnloadChunk.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateAttributes.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateHealth.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateTime.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerVehicleMove.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowData.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowItems.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldBorder.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldEvent.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperStatusClientPing.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperStatusClientStart.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperStatusServerPong.java create mode 100644 src/main/java/com/comphenix/packetwrapper/WrapperStatusServerServerInfo.java diff --git a/src/main/java/com/comphenix/packetwrapper/AbstractPacket.java b/src/main/java/com/comphenix/packetwrapper/AbstractPacket.java new file mode 100644 index 000000000..4bc555cf6 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/AbstractPacket.java @@ -0,0 +1,114 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.lang.reflect.InvocationTargetException; + +import org.bukkit.entity.Player; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import com.google.common.base.Objects; + +public abstract class AbstractPacket { + // The packet we will be modifying + protected PacketContainer handle; + + /** + * Constructs a new strongly typed wrapper for the given packet. + * + * @param handle - handle to the raw packet data. + * @param type - the packet type. + */ + protected AbstractPacket(PacketContainer handle, PacketType type) { + // Make sure we're given a valid packet + if (handle == null) + throw new IllegalArgumentException("Packet handle cannot be NULL."); + if (!Objects.equal(handle.getType(), type)) + throw new IllegalArgumentException(handle.getHandle() + + " is not a packet of type " + type); + + this.handle = handle; + } + + /** + * Retrieve a handle to the raw packet data. + * + * @return Raw packet data. + */ + public PacketContainer getHandle() { + return handle; + } + + /** + * Send the current packet to the given receiver. + * + * @param receiver - the receiver. + * @throws RuntimeException If the packet cannot be sent. + */ + public void sendPacket(Player receiver) { + try { + ProtocolLibrary.getProtocolManager().sendServerPacket(receiver, + getHandle()); + } catch (InvocationTargetException e) { + throw new RuntimeException("Cannot send packet.", e); + } + } + + /** + * Send the current packet to all online players. + */ + public void broadcastPacket() { + ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle()); + } + + /** + * Simulate receiving the current packet from the given sender. + * + * @param sender - the sender. + * @throws RuntimeException If the packet cannot be received. + * @deprecated Misspelled. recieve to receive + * @see #receivePacket(Player) + */ + @Deprecated + public void recievePacket(Player sender) { + try { + ProtocolLibrary.getProtocolManager().recieveClientPacket(sender, + getHandle()); + } catch (Exception e) { + throw new RuntimeException("Cannot recieve packet.", e); + } + } + + /** + * Simulate receiving the current packet from the given sender. + * + * @param sender - the sender. + * @throws RuntimeException if the packet cannot be received. + */ + public void receivePacket(Player sender) { + try { + ProtocolLibrary.getProtocolManager().recieveClientPacket(sender, + getHandle()); + } catch (Exception e) { + throw new RuntimeException("Cannot receive packet.", e); + } + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/ChunkPacketProcessor.java b/src/main/java/com/comphenix/packetwrapper/ChunkPacketProcessor.java new file mode 100644 index 000000000..c6993afc4 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/ChunkPacketProcessor.java @@ -0,0 +1,401 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.World.Environment; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.StructureModifier; + +/** + * Used to process a chunk. + * + * @author Kristian + */ +public class ChunkPacketProcessor { + /** + * Contains the offset of the different block data in a chunk packet. + * + * @author Kristian + */ + public static class ChunkOffsets { + private int blockIdOffset; + private int dataOffset; + private int lightOffset; + private int skylightOffset; + private int extraOffset; + + private ChunkOffsets(int blockIdOffset, int dataOffset, + int lightOffset, int skylightOffset, int extraOffset) { + this.blockIdOffset = blockIdOffset; + this.dataOffset = dataOffset; + this.lightOffset = lightOffset; + this.skylightOffset = skylightOffset; + this.extraOffset = extraOffset; + } + + private void incrementIdIndex() { + blockIdOffset += ChunkPacketProcessor.BLOCK_ID_LENGTH; + dataOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART; + dataOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART; + + if (skylightOffset >= 0) { + skylightOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART; + } + } + + private void incrementExtraIndex() { + if (extraOffset >= 0) { + extraOffset += ChunkPacketProcessor.BYTES_PER_NIBBLE_PART; + } + } + + /** + * Retrieve the starting index of the block ID data. + *

+ * This will be 4096 bytes in length, one byte for each block in the + * 16x16x16 chunklet. + * + * @return The starting location of the block ID data. + */ + public int getBlockIdOffset() { + return blockIdOffset; + } + + /** + * Retrieve the starting index of the meta data (4 bit per block). + *

+ * This will be 2048 bytes in length, one nibblet for each block in the + * 16x16x16 chunklet. + * + * @return The starting location of the block meta data. + */ + public int getDataOffset() { + return dataOffset; + } + + /** + * Retrieve the starting index of the torch light data (4 bit per + * block). + *

+ * This will be 2048 bytes in length, one nibblet for each block in the + * 16x16x16 chunklet. + * + * @return The starting location of the torch light data. + */ + public int getLightOffset() { + return lightOffset; + } + + /** + * Retrieve the starting index of the skylight data (4 bit per block). + *

+ * This will be 2048 bytes in length if the skylight data exists (see + * {@link #hasSkylightOffset()}), no bytes if not. + * + * @return The starting location of the skylight data. + */ + public int getSkylightOffset() { + return skylightOffset; + } + + /** + * Determine if the current chunklet contains skylight data. + * + * @return TRUE if it does, FALSE otherwise. + */ + public boolean hasSkylightOffset() { + return skylightOffset >= 0; + } + + /** + * Retrieve the extra 4 bits in each block ID, if necessary. + *

+ * This will be 2048 bytes in length if the extra data exists, no bytes + * if not. + * + * @return The starting location of the extra data. + */ + public int getExtraOffset() { + return extraOffset; + } + + /** + * Determine if the current chunklet contains any extra block ID data. + * + * @return TRUE if it does, FALSE otherwise. + */ + public boolean hasExtraOffset() { + return extraOffset > 0; + } + } + + /** + * Process the content of a single 16x16x16 chunklet in a 16x256x16 chunk. + * + * @author Kristian + */ + public interface ChunkletProcessor { + /** + * Process a given chunklet (16x16x16). + * + * @param origin - the block with the lowest x, y and z coordinate in + * the chunklet. + * @param data - the data array. + * @param offsets - the offsets with the data for the given chunklet. + */ + public void processChunklet(Location origin, byte[] data, + ChunkOffsets offsets); + + /** + * Process the biome array for a chunk (16x256x16). + *

+ * This method will not be called if the chunk is missing biome + * information. + * + * @param origin - the block with the lowest x, y and z coordinate in + * the chunk. + * @param data - the data array. + * @param biomeIndex - the starting index of the biome data (256 bytes + * in lenght). + */ + public void processBiomeArray(Location origin, byte[] data, + int biomeIndex); + } + + // Useful Minecraft constants + protected static final int BYTES_PER_NIBBLE_PART = 2048; + protected static final int CHUNK_SEGMENTS = 16; + protected static final int NIBBLES_REQUIRED = 4; + + /**Misspelled. + * @see #BLOCK_ID_LENGTH + */ + @Deprecated + public static final int BLOCK_ID_LENGHT = 4096; + + public static final int BLOCK_ID_LENGTH = 4096; + + /**Misspelled. + * @see #DATA_LENGTH + */ + @Deprecated + public static final int DATA_LENGHT = 2048; + + public static final int DATA_LENGTH = 2048; + public static final int BIOME_ARRAY_LENGTH = 256; + + private int chunkX; + private int chunkZ; + private int chunkMask; + private int extraMask; + private int chunkSectionNumber; + private int extraSectionNumber; + private boolean hasContinuous = true; + + private int startIndex; + private int size; + + private byte[] data; + private World world; + + private ChunkPacketProcessor() { + // Use factory methods + } + + /** + * Construct a chunk packet processor from a given MAP_CHUNK packet. + * + * @param packet - the map chunk packet. + * @return The chunk packet processor. + */ + public static ChunkPacketProcessor fromMapPacket(PacketContainer packet, + World world) { + if (!packet.getType().equals(PacketType.Play.Server.MAP_CHUNK)) + throw new IllegalArgumentException(packet + + " must be a MAP_CHUNK packet."); + + StructureModifier ints = packet.getIntegers(); + StructureModifier byteArray = packet.getByteArrays(); + + // Create an info objects + ChunkPacketProcessor processor = new ChunkPacketProcessor(); + processor.world = world; + processor.chunkX = ints.read(0); // packet.a; + processor.chunkZ = ints.read(1); // packet.b; + processor.chunkMask = ints.read(2); // packet.c; + processor.extraMask = ints.read(3); // packet.d; + processor.data = byteArray.read(1); // packet.inflatedBuffer; + processor.startIndex = 0; + + if (packet.getBooleans().size() > 0) { + processor.hasContinuous = packet.getBooleans().read(0); + } + return processor; + } + + /** + * Construct an array of chunk packet processors from a given MAP_CHUNK_BULK + * packet. + * + * @param packet - the map chunk bulk packet. + * @return The chunk packet processors. + */ + // The MAP_CHUNK_BULK packet no longer exists + /* + * public static ChunkPacketProcessor[] fromMapBulkPacket(PacketContainer + * packet, World world) { + * if (!packet.getType().equals(PacketType.Play.Server.MAP_CHUNK_BULK)) + * throw new IllegalArgumentException(packet + + * " must be a MAP_CHUNK_BULK packet."); + * StructureModifier intArrays = packet.getIntegerArrays(); + * StructureModifier byteArrays = packet.getByteArrays(); + * int[] x = intArrays.read(0); // packet.c; + * int[] z = intArrays.read(1); // packet.d; + * ChunkPacketProcessor[] processors = new ChunkPacketProcessor[x.length]; + * int[] chunkMask = intArrays.read(2); // packet.a; + * int[] extraMask = intArrays.read(3); // packet.b; + * int dataStartIndex = 0; + * for (int chunkNum = 0; chunkNum < processors.length; chunkNum++) { + * // Create an info objects + * ChunkPacketProcessor processor = new ChunkPacketProcessor(); + * processors[chunkNum] = processor; + * processor.world = world; + * processor.chunkX = x[chunkNum]; + * processor.chunkZ = z[chunkNum]; + * processor.chunkMask = chunkMask[chunkNum]; + * processor.extraMask = extraMask[chunkNum]; + * processor.hasContinuous = true; // Always true + * processor.data = byteArrays.read(1); //packet.buildBuffer; + * // Check for Spigot + * if (processor.data == null || processor.data.length == 0) { + * processor.data = + * packet.getSpecificModifier(byte[][].class).read(0)[chunkNum]; + * } else { + * processor.startIndex = dataStartIndex; + * } + * dataStartIndex += processor.size; + * } + * return processors; + * } + */ + + /** + * Begin processing the current chunk with the provided processor. + * + * @param processor - the processor that will process the chunk. + */ + public void process(ChunkletProcessor processor) { + // Compute chunk number + for (int i = 0; i < CHUNK_SEGMENTS; i++) { + if ((chunkMask & (1 << i)) > 0) { + chunkSectionNumber++; + } + if ((extraMask & (1 << i)) > 0) { + extraSectionNumber++; + } + } + + int skylightCount = getSkylightCount(); + + // The total size of a chunk is the number of blocks sent (depends on the number of sections) multiplied by the + // amount of bytes per block. This last figure can be calculated by adding together all the data parts: + // For any block: + // * Block ID - 8 bits per block (byte) + // * Block metadata - 4 bits per block (nibble) + // * Block light array - 4 bits per block + // If 'worldProvider.skylight' is TRUE + // * Sky light array - 4 bits per block + // If the segment has extra data: + // * Add array - 4 bits per block + // Biome array - only if the entire chunk (has continous) is sent: + // * Biome array - 256 bytes + // + // A section has 16 * 16 * 16 = 4096 blocks. + size = + BYTES_PER_NIBBLE_PART + * ((NIBBLES_REQUIRED + skylightCount) + * chunkSectionNumber + extraSectionNumber) + + (hasContinuous ? BIOME_ARRAY_LENGTH : 0); + + if ((getOffset(2) - startIndex) > data.length) { + return; + } + + // Make sure the chunk is loaded + if (isChunkLoaded(world, chunkX, chunkZ)) { + translate(processor); + } + } + + /** + * Retrieve the number of 2048 byte segments per chunklet. + * 0 ? getOffset(current++) : -1, + extraSectionNumber > 0 ? getOffset(current++) : -1); + + for (int i = 0; i < 16; i++) { + // If the bitmask indicates this chunk is sent + if ((chunkMask & 1 << i) > 0) { + // The lowest block (in x, y, z) in this chunklet + Location origin = + new Location(world, chunkX << 4, i * 16, chunkZ << 4); + + processor.processChunklet(origin, data, offsets); + offsets.incrementIdIndex(); + } + if ((extraMask & 1 << i) > 0) { + offsets.incrementExtraIndex(); + } + } + + if (hasContinuous) { + processor.processBiomeArray(new Location(world, chunkX << 4, 0, + chunkZ << 4), data, startIndex + size - BIOME_ARRAY_LENGTH); + } + } + + private boolean isChunkLoaded(World world, int x, int z) { + return world.isChunkLoaded(x, z); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/PacketWrapper.java b/src/main/java/com/comphenix/packetwrapper/PacketWrapper.java new file mode 100644 index 000000000..00c3b5f16 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/PacketWrapper.java @@ -0,0 +1,28 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.plugin.java.JavaPlugin; + +public class PacketWrapper extends JavaPlugin { + @Override + public void onEnable() { + // We don't really do much ... + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperHandshakingClientSetProtocol.java b/src/main/java/com/comphenix/packetwrapper/WrapperHandshakingClientSetProtocol.java new file mode 100644 index 000000000..89f265a2d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperHandshakingClientSetProtocol.java @@ -0,0 +1,118 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.PacketType.Protocol; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperHandshakingClientSetProtocol extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Handshake.Client.SET_PROTOCOL; + + public WrapperHandshakingClientSetProtocol() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperHandshakingClientSetProtocol(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Protocol Version. + *

+ * Notes: (4 as of 1.7.2) + * + * @return The current Protocol Version + */ + public int getProtocolVersion() { + return handle.getIntegers().read(0); + } + + /** + * Set Protocol Version. + * + * @param value - new value. + */ + public void setProtocolVersion(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Server Address (hostname or IP). + *

+ * Notes: localhost + * + * @return The current Server Address (hostname or IP) + */ + public String getServerAddressHostnameOrIp() { + return handle.getStrings().read(0); + } + + /** + * Set Server Address (hostname or IP). + * + * @param value - new value. + */ + public void setServerAddressHostnameOrIp(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Server Port. + *

+ * Notes: 25565 + * + * @return The current Server Port + */ + public int getServerPort() { + return handle.getIntegers().read(1); + } + + /** + * Set Server Port. + * + * @param value - new value. + */ + public void setServerPort(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Next state. + *

+ * Notes: 1 for status, 2 for login + * + * @return The current Next state + */ + public Protocol getNextState() { + return handle.getProtocols().read(0); + } + + /** + * Set Next state. + * + * @param value - new value. + */ + public void setNextState(Protocol value) { + handle.getProtocols().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientCustomPayload.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientCustomPayload.java new file mode 100644 index 000000000..31f0dfc23 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientCustomPayload.java @@ -0,0 +1,57 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperLoginClientCustomPayload extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Login.Client.CUSTOM_PAYLOAD; + + public WrapperLoginClientCustomPayload() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginClientCustomPayload(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Message ID. + *

+ * Notes: should match ID from server. + * @return The current Message ID + */ + public int getMessageId() { + return handle.getIntegers().read(0); + } + + /** + * Set Message ID. + * @param value - new value. + */ + public void setMessageId(int value) { + handle.getIntegers().write(0, value); + } + + // Cannot find type for b + // Cannot find type for b +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientEncryptionBegin.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientEncryptionBegin.java new file mode 100644 index 000000000..792ab2253 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientEncryptionBegin.java @@ -0,0 +1,72 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperLoginClientEncryptionBegin extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Login.Client.ENCRYPTION_BEGIN; + + public WrapperLoginClientEncryptionBegin() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginClientEncryptionBegin(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Shared Secret. + * + * @return The current Shared Secret + */ + public byte[] getSharedSecret() { + return handle.getByteArrays().read(0); + } + + /** + * Set Shared Secret. + * + * @param value - new value. + */ + public void setSharedSecret(byte[] value) { + handle.getByteArrays().write(0, value); + } + + /** + * Retrieve Verify Token. + * + * @return The current Verify Token + */ + public byte[] getVerifyToken() { + return handle.getByteArrays().read(1); + } + + /** + * Set Verify Token. + * + * @param value - new value. + */ + public void setVerifyToken(byte[] value) { + handle.getByteArrays().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientStart.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientStart.java new file mode 100644 index 000000000..b43a360a1 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginClientStart.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedGameProfile; + +public class WrapperLoginClientStart extends AbstractPacket { + public static final PacketType TYPE = PacketType.Login.Client.START; + + public WrapperLoginClientStart() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginClientStart(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Profile. + * + * @return The current Profile + */ + public WrappedGameProfile getProfile() { + return handle.getGameProfiles().read(0); + } + + /** + * Set Name. + * + * @param value - new value. + */ + public void setProfile(WrappedGameProfile value) { + handle.getGameProfiles().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerCustomPayload.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerCustomPayload.java new file mode 100644 index 000000000..930c2793b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerCustomPayload.java @@ -0,0 +1,57 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperLoginServerCustomPayload extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Login.Server.CUSTOM_PAYLOAD; + + public WrapperLoginServerCustomPayload() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginServerCustomPayload(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Message ID. + *

+ * Notes: generated by the server - should be unique to the connection. + * @return The current Message ID + */ + public int getMessageId() { + return handle.getIntegers().read(0); + } + + /** + * Set Message ID. + * @param value - new value. + */ + public void setMessageId(int value) { + handle.getIntegers().write(0, value); + } + + // Cannot find type for b + // Cannot find type for b +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerDisconnect.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerDisconnect.java new file mode 100644 index 000000000..6314a4e9e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerDisconnect.java @@ -0,0 +1,64 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperLoginServerDisconnect extends AbstractPacket { + public static final PacketType TYPE = PacketType.Login.Server.DISCONNECT; + + public WrapperLoginServerDisconnect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginServerDisconnect(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve reason. + * + * @return The current reason + */ + public WrappedChatComponent getReason() { + return handle.getChatComponents().read(0); + } + + @Deprecated + public WrappedChatComponent getJsonData() { + return getReason(); + } + + /** + * Set reason. + * + * @param value - new value. + */ + public void setReason(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + @Deprecated + public void setJsonData(WrappedChatComponent value) { + setReason(value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerEncryptionBegin.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerEncryptionBegin.java new file mode 100644 index 000000000..6c3ed9213 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerEncryptionBegin.java @@ -0,0 +1,94 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.security.PublicKey; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperLoginServerEncryptionBegin extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Login.Server.ENCRYPTION_BEGIN; + + public WrapperLoginServerEncryptionBegin() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginServerEncryptionBegin(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Server ID. + *

+ * Notes: appears to be empty as of 1.7.x + * + * @return The current Server ID + */ + public String getServerId() { + return handle.getStrings().read(0); + } + + /** + * Set Server ID. + * + * @param value - new value. + */ + public void setServerId(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Public Key. + * + * @return The current Public Key + */ + public PublicKey getPublicKey() { + return handle.getSpecificModifier(PublicKey.class).read(0); + } + + /** + * Set Public Key. + * + * @param value - new value. + */ + public void setPublicKey(PublicKey value) { + handle.getSpecificModifier(PublicKey.class).write(0, value); + } + + /** + * Retrieve Verify Token. + * + * @return The current Verify Token + */ + public byte[] getVerifyToken() { + return handle.getByteArrays().read(0); + } + + /** + * Set Verify Token. + * + * @param value - new value. + */ + public void setVerifyToken(byte[] value) { + handle.getByteArrays().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSetCompression.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSetCompression.java new file mode 100644 index 000000000..101f02f61 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSetCompression.java @@ -0,0 +1,57 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperLoginServerSetCompression extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Login.Server.SET_COMPRESSION; + + public WrapperLoginServerSetCompression() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginServerSetCompression(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Threshold. + *

+ * Notes: threshold is the max size of a packet before its compressed + * + * @return The current Threshold + */ + public int getThreshold() { + return handle.getIntegers().read(0); + } + + /** + * Set Threshold. + * + * @param value - new value. + */ + public void setThreshold(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSuccess.java b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSuccess.java new file mode 100644 index 000000000..8a70a0721 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperLoginServerSuccess.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedGameProfile; + +public class WrapperLoginServerSuccess extends AbstractPacket { + public static final PacketType TYPE = PacketType.Login.Server.SUCCESS; + + public WrapperLoginServerSuccess() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperLoginServerSuccess(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve the UUID and player name of the connected client. + * + * @return The current client profile. + */ + public WrappedGameProfile getProfile() { + return handle.getGameProfiles().read(0); + } + + /** + * Set the UUID and player name of the connected client as a game profile. + * + * @param value - new profile. + */ + public void setProfile(WrappedGameProfile value) { + handle.getGameProfiles().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAbilities.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAbilities.java new file mode 100644 index 000000000..afb5f528c --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAbilities.java @@ -0,0 +1,99 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientAbilities extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.ABILITIES; + + public WrapperPlayClientAbilities() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientAbilities(PacketContainer packet) { + super(packet, TYPE); + } + + public boolean isInvulnerable() { + return handle.getBooleans().read(0); + } + + public void setInvulnerable(boolean value) { + handle.getBooleans().write(0, value); + } + + /**Misspelled. + * @see #isInvulnerable() + */ + @Deprecated + public boolean isInvulnurable() { + return handle.getBooleans().read(0); + } + + /**Misspelled. + * @see #setInvulnerable(boolean) + */ + @Deprecated + public void setInvulnurable(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean isFlying() { + return handle.getBooleans().read(1); + } + + public void setFlying(boolean value) { + handle.getBooleans().write(1, value); + } + + public boolean canFly() { + return handle.getBooleans().read(2); + } + + public void setCanFly(boolean value) { + handle.getBooleans().write(2, value); + } + + public boolean canInstantlyBuild() { + return handle.getBooleans().read(3); + } + + public void setCanInstantlyBuild(boolean value) { + handle.getBooleans().write(3, value); + } + + public float getFlyingSpeed() { + return handle.getFloat().read(0); + } + + public void setFlyingSpeed(float value) { + handle.getFloat().write(0, value); + } + + public float getWalkingSpeed() { + return handle.getFloat().read(1); + } + + public void setWalkingSpeed(float value) { + handle.getFloat().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAdvancements.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAdvancements.java new file mode 100644 index 000000000..cf895ddf4 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAdvancements.java @@ -0,0 +1,77 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.MinecraftKey; + +public class WrapperPlayClientAdvancements extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.ADVANCEMENTS; + + public WrapperPlayClientAdvancements() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientAdvancements(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Action. + *

+ * Notes: 0: Opened tab, 1: Closed screen + * @return The current Action + */ + public Status getAction() { + return handle.getEnumModifier(Status.class, 0).readSafely(0); + } + + /** + * Set Action. + * @param value - new value. + */ + public void setAction(Status value) { + handle.getEnumModifier(Status.class, 0).writeSafely(0, value); + } + /** + * Retrieve Tab ID. + *

+ * Notes: only present if action is Opened tab + * @return The current Tab ID + */ + public MinecraftKey getTabId() { + return handle.getMinecraftKeys().readSafely(0); + } + + /** + * Set Tab ID. + * @param value - new value. + */ + public void setTabId(MinecraftKey value) { + handle.getMinecraftKeys().writeSafely(0, value); + } + + public enum Status { + OPENED_TAB, + CLOSED_SCREEN; + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientArmAnimation.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientArmAnimation.java new file mode 100644 index 000000000..0eb24192f --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientArmAnimation.java @@ -0,0 +1,35 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientArmAnimation extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.ARM_ANIMATION; + + public WrapperPlayClientArmAnimation() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientArmAnimation(PacketContainer packet) { + super(packet, TYPE); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAutoRecipe.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAutoRecipe.java new file mode 100644 index 000000000..9fd17c226 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientAutoRecipe.java @@ -0,0 +1,64 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientAutoRecipe extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.AUTO_RECIPE; + + public WrapperPlayClientAutoRecipe() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientAutoRecipe(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the window id. + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + // Modifier for recipe can be created upon request + + public boolean isMakeAll() { + return handle.getBooleans().read(0); + } + + public void setMakeAll(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBeacon.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBeacon.java new file mode 100644 index 000000000..41993c1ba --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBeacon.java @@ -0,0 +1,73 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientBeacon extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.BEACON; + + public WrapperPlayClientBeacon() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientBeacon(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Primary Effect. + *

+ * Notes: a Potion ID. (Was a full Integer for the plugin message) + * @return The current Primary Effect + */ + public int getPrimaryEffect() { + return handle.getIntegers().read(0); + } + + /** + * Set Primary Effect. + * @param value - new value. + */ + public void setPrimaryEffect(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Secondary Effect. + *

+ * Notes: a Potion ID. (Was a full Integer for the plugin message) + * @return The current Secondary Effect + */ + public int getSecondaryEffect() { + return handle.getIntegers().read(1); + } + + /** + * Set Secondary Effect. + * @param value - new value. + */ + public void setSecondaryEffect(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockDig.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockDig.java new file mode 100644 index 000000000..e4cda8813 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockDig.java @@ -0,0 +1,86 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.comphenix.protocol.wrappers.EnumWrappers.Direction; +import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType; + +public class WrapperPlayClientBlockDig extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.BLOCK_DIG; + + public WrapperPlayClientBlockDig() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientBlockDig(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + *

+ * Notes: block position + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + public Direction getDirection() { + return handle.getDirections().read(0); + } + + public void setDirection(Direction value) { + handle.getDirections().write(0, value); + } + + /** + * Retrieve Status. + *

+ * Notes: the action the player is taking against the block (see below) + * + * @return The current Status + */ + public PlayerDigType getStatus() { + return handle.getPlayerDigTypes().read(0); + } + + /** + * Set Status. + * + * @param value - new value. + */ + public void setStatus(PlayerDigType value) { + handle.getPlayerDigTypes().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockPlace.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockPlace.java new file mode 100644 index 000000000..924444ed4 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBlockPlace.java @@ -0,0 +1,53 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.Hand; + +public class WrapperPlayClientBlockPlace extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.BLOCK_PLACE; + + public WrapperPlayClientBlockPlace() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientBlockPlace(PacketContainer packet) { + super(packet, TYPE); + } + + public Hand getHand() { + return handle.getHands().read(0); + } + + public void setHand(Hand value) { + handle.getHands().write(0, value); + } + + public long getTimestamp() { + return handle.getLongs().read(0); + } + + public void setTimestamp(long value) { + handle.getLongs().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBoatMove.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBoatMove.java new file mode 100644 index 000000000..2cabee2df --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBoatMove.java @@ -0,0 +1,53 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientBoatMove extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.BOAT_MOVE; + + public WrapperPlayClientBoatMove() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientBoatMove(PacketContainer packet) { + super(packet, TYPE); + } + + public boolean getLeftOar() { + return handle.getBooleans().read(0); + } + + public void setLeftOar(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean getRightOar() { + return handle.getBooleans().read(1); + } + + public void setRightOar(boolean value) { + handle.getBooleans().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBookEdit.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBookEdit.java new file mode 100644 index 000000000..c4596607e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientBookEdit.java @@ -0,0 +1,72 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +import org.bukkit.inventory.ItemStack; + +public class WrapperPlayClientBookEdit extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.BOOK_EDIT; + + public WrapperPlayClientBookEdit() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientBookEdit(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve New book. + * @return The current New book + */ + public ItemStack getNewBook() { + return handle.getItemModifier().read(0); + } + + /** + * Set New book. + * @param value - new value. + */ + public void setNewBook(ItemStack value) { + handle.getItemModifier().write(0, value); + } + + /** + * Retrieve Is signing. + *

+ * Notes: true if the player is signing the book; false if the player is saving a draft. + * @return The current Is signing + */ + public boolean getIsSigning() { + return handle.getBooleans().read(0); + } + + /** + * Set Is signing. + * @param value - new value. + */ + public void setIsSigning(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientChat.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientChat.java new file mode 100644 index 000000000..8fbd7d52f --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientChat.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientChat extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.CHAT; + + public WrapperPlayClientChat() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientChat(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Message. + * + * @return The current Message + */ + public String getMessage() { + return handle.getStrings().read(0); + } + + /** + * Set Message. + * + * @param value - new value. + */ + public void setMessage(String value) { + handle.getStrings().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientClientCommand.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientClientCommand.java new file mode 100644 index 000000000..7f2bb9836 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientClientCommand.java @@ -0,0 +1,57 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand; + +public class WrapperPlayClientClientCommand extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.CLIENT_COMMAND; + + public WrapperPlayClientClientCommand() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientClientCommand(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Action ID. + *

+ * Notes: see below + * + * @return The current Action ID + */ + public ClientCommand getAction() { + return handle.getClientCommands().read(0); + } + + /** + * Set Action ID. + * + * @param value - new value. + */ + public void setAction(ClientCommand value) { + handle.getClientCommands().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCloseWindow.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCloseWindow.java new file mode 100644 index 000000000..9428318fb --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCloseWindow.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientCloseWindow extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.CLOSE_WINDOW; + + public WrapperPlayClientCloseWindow() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientCloseWindow(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window id. + *

+ * Notes: this is the id of the window that was closed. 0 for inventory. + * + * @return The current Window id + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window id. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCustomPayload.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCustomPayload.java new file mode 100644 index 000000000..21441579d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientCustomPayload.java @@ -0,0 +1,96 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.utility.MinecraftReflection; +import com.comphenix.protocol.wrappers.MinecraftKey; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +public class WrapperPlayClientCustomPayload extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.CUSTOM_PAYLOAD; + + public WrapperPlayClientCustomPayload() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientCustomPayload(PacketContainer packet) { + super(packet, TYPE); + } + + public MinecraftKey getChannel() { + return handle.getMinecraftKeys().readSafely(0); + } + + /** + * Starting in 1.13, channel names need to be lower case, in the new identifier format, + * i.e. {@code minecraft:brand}. The previously standard {@code |} is no longer allowed. + */ + public void setChannel(MinecraftKey value) { + handle.getMinecraftKeys().writeSafely(0, value); + } + + /** + * Retrieve payload contents as a raw Netty buffer + * + * @return Payload contents as a Netty buffer + */ + public ByteBuf getContentsBuffer() { + return (ByteBuf) handle.getModifier().withType(ByteBuf.class).read(0); + } + + /** + * Retrieve payload contents + * + * @return Payload contents as a byte array + */ + public byte[] getContents() { + ByteBuf buffer = getContentsBuffer(); + byte[] array = new byte[buffer.readableBytes()]; + buffer.readBytes(array); + return array; + } + + /** + * Update payload contents with a Netty buffer + * + * @param contents - new payload contents + */ + public void setContentsBuffer(ByteBuf contents) { + if (MinecraftReflection.is(MinecraftReflection.getPacketDataSerializerClass(), contents)) { + handle.getModifier().withType(ByteBuf.class).write(0, contents); + } else { + Object serializer = MinecraftReflection.getPacketDataSerializer(contents); + handle.getModifier().withType(ByteBuf.class).write(0, serializer); + } + } + + /** + * Update payload contents with a byte array + * + * @param content - new payload content + */ + public void setContents(byte[] content) { + setContentsBuffer(Unpooled.copiedBuffer(content)); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEnchantItem.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEnchantItem.java new file mode 100644 index 000000000..98ab0847b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEnchantItem.java @@ -0,0 +1,77 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientEnchantItem extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.ENCHANT_ITEM; + + public WrapperPlayClientEnchantItem() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientEnchantItem(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the ID sent by Open Window + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(byte value) { + handle.getIntegers().write(0, (int) value); + } + + /** + * Retrieve Enchantment. + *

+ * Notes: the position of the enchantment on the enchantment table window, + * starting with 0 as the topmost one. + * + * @return The current Enchantment + */ + public int getEnchantment() { + return handle.getIntegers().read(1); + } + + /** + * Set Enchantment. + * + * @param value - new value. + */ + public void setEnchantment(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityAction.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityAction.java new file mode 100644 index 000000000..2b6da6b37 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityAction.java @@ -0,0 +1,121 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.EnumWrappers.PlayerAction; + +public class WrapperPlayClientEntityAction extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.ENTITY_ACTION; + + public WrapperPlayClientEntityAction() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientEntityAction(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Action ID. + *

+ * Notes: the ID of the action, see below. + * + * @return The current Action ID + */ + public PlayerAction getAction() { + return handle.getPlayerActions().read(0); + } + + /** + * Set Action ID. + * + * @param value - new value. + */ + public void setAction(PlayerAction value) { + handle.getPlayerActions().write(0, value); + } + + /** + * Retrieve Jump Boost. + *

+ * Notes: horse jump boost. Ranged from 0 -> 100. + * + * @return The current Jump Boost + */ + public int getJumpBoost() { + return handle.getIntegers().read(1); + } + + /** + * Set Jump Boost. + * + * @param value - new value. + */ + public void setJumpBoost(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityNbtQuery.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityNbtQuery.java new file mode 100644 index 000000000..2c44e1037 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientEntityNbtQuery.java @@ -0,0 +1,95 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +public class WrapperPlayClientEntityNbtQuery extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.ENTITY_NBT_QUERY; + + public WrapperPlayClientEntityNbtQuery() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientEntityNbtQuery(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Transaction ID. + *

+ * Notes: an incremental ID so that the client can verify that the response matches. + * @return The current Transaction ID + */ + public int getTransactionId() { + return handle.getIntegers().read(0); + } + + /** + * Set Transaction ID. + * @param value - new value. + */ + public void setTransactionId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: the ID of the entity to query. + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(1); + } + + /** + * Retrieve the entity involved in this event. + * @param world - the current world of the entity. + * @return The involved entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(1); + } + + /** + * Retrieve the entity involved in this event. + * @param event - the packet event. + * @return The involved entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Set Entity ID. + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientFlying.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientFlying.java new file mode 100644 index 000000000..7a788d361 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientFlying.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientFlying extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.FLYING; + + public WrapperPlayClientFlying() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientFlying(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve On Ground. + *

+ * Notes: true if the client is on the ground, False otherwise + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientHeldItemSlot.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientHeldItemSlot.java new file mode 100644 index 000000000..764c0c0db --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientHeldItemSlot.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientHeldItemSlot extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.HELD_ITEM_SLOT; + + public WrapperPlayClientHeldItemSlot() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientHeldItemSlot(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Slot. + *

+ * Notes: the slot which the player has selected (0-8) + * + * @return The current Slot + */ + public int getSlot() { + return handle.getIntegers().read(0); + } + + /** + * Set Slot. + * + * @param value - new value. + */ + public void setSlot(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientItemName.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientItemName.java new file mode 100644 index 000000000..c125f1e40 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientItemName.java @@ -0,0 +1,55 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientItemName extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.ITEM_NAME; + + public WrapperPlayClientItemName() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientItemName(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Item name. + *

+ * Notes: the new name of the item + * @return The current Item name + */ + public String getItemName() { + return handle.getStrings().read(0); + } + + /** + * Set Item name. + * @param value - new value. + */ + public void setItemName(String value) { + handle.getStrings().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientKeepAlive.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientKeepAlive.java new file mode 100644 index 000000000..39ef4c7af --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientKeepAlive.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientKeepAlive extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.KEEP_ALIVE; + + public WrapperPlayClientKeepAlive() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientKeepAlive(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Keep Alive ID. + * + * @return The current Keep Alive ID + */ + public long getKeepAliveId() { + return handle.getLongs().read(0); + } + + /** + * Set Keep Alive ID. + * + * @param value - new value. + */ + public void setKeepAliveId(long value) { + handle.getLongs().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientLook.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientLook.java new file mode 100644 index 000000000..a13e8935e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientLook.java @@ -0,0 +1,96 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientLook extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.LOOK; + + public WrapperPlayClientLook() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientLook(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Yaw. + *

+ * Notes: absolute rotation on the X Axis, in degrees + * + * @return The current Yaw + */ + public float getYaw() { + return handle.getFloat().read(0); + } + + /** + * Set Yaw. + * + * @param value - new value. + */ + public void setYaw(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: absolute rotation on the Y Axis, in degrees + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } + + /** + * Retrieve On Ground. + *

+ * Notes: true if the client is on the ground, False otherwise + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPickItem.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPickItem.java new file mode 100644 index 000000000..be015d8cd --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPickItem.java @@ -0,0 +1,55 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientPickItem extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.PICK_ITEM; + + public WrapperPlayClientPickItem() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientPickItem(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Slot to use. + *

+ * Notes: see Inventory + * @return The current Slot to use + */ + public int getSlotToUse() { + return handle.getIntegers().read(0); + } + + /** + * Set Slot to use. + * @param value - new value. + */ + public void setSlotToUse(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPosition.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPosition.java new file mode 100644 index 000000000..dce69a6aa --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPosition.java @@ -0,0 +1,117 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientPosition extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.POSITION; + + public WrapperPlayClientPosition() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientPosition(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve X. + *

+ * Notes: absolute position + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve FeetY. + *

+ * Notes: absolute feet position, normally HeadY - 1.62. Used to modify the + * players bounding box when going up stairs, crouching, etc… + * + * @return The current FeetY + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set FeetY. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: absolute position + * + * @return The current Z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve On Ground. + *

+ * Notes: true if the client is on the ground, False otherwise + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPositionLook.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPositionLook.java new file mode 100644 index 000000000..79e47e7fd --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientPositionLook.java @@ -0,0 +1,157 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientPositionLook extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.POSITION_LOOK; + + public WrapperPlayClientPositionLook() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientPositionLook(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve X. + *

+ * Notes: absolute position + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve Feet Y. + *

+ * Notes: absolute feet position. Is normally HeadY - 1.62. Used to modify + * the players bounding box when going up stairs, crouching, etc… + * + * @return The current FeetY + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set Feet Y. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: absolute position + * + * @return The current Z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Yaw. + *

+ * Notes: absolute rotation on the X Axis, in degrees + * + * @return The current Yaw + */ + public float getYaw() { + return handle.getFloat().read(0); + } + + /** + * Set Yaw. + * + * @param value - new value. + */ + public void setYaw(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: absolute rotation on the Y Axis, in degrees + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } + + /** + * Retrieve On Ground. + *

+ * Notes: true if the client is on the ground, False otherwise + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientRecipeDisplayed.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientRecipeDisplayed.java new file mode 100644 index 000000000..a0b7dc910 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientRecipeDisplayed.java @@ -0,0 +1,66 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientRecipeDisplayed extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.RECIPE_DISPLAYED; + + public WrapperPlayClientRecipeDisplayed() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientRecipeDisplayed(PacketContainer packet) { + super(packet, TYPE); + } + + public Status getStatus() { + return handle.getEnumModifier(Status.class, 0).readSafely(0); + } + + public void setStatus(Status value) { + handle.getEnumModifier(Status.class, 0).writeSafely(0, value); + } + + // Modifier for recipe can be created upon request + + public boolean isBookOpen() { + return handle.getBooleans().read(0); + } + + public void setBookOpen(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean isFilterActive() { + return handle.getBooleans().read(1); + } + + public void setFilterActive(boolean value) { + handle.getBooleans().write(1, value); + } + + public enum Status { + SHOWN, + SETTINGS; + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientResourcePackStatus.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientResourcePackStatus.java new file mode 100644 index 000000000..88c7b226a --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientResourcePackStatus.java @@ -0,0 +1,58 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus; + +public class WrapperPlayClientResourcePackStatus extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Client.RESOURCE_PACK_STATUS; + + public WrapperPlayClientResourcePackStatus() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientResourcePackStatus(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Result. + *

+ * Notes: successfully loaded: 0, Declined: 1, Failed download: 2, Accepted: + * 3 + * + * @return The current Result + */ + public ResourcePackStatus getResult() { + return handle.getResourcePackStatus().read(0); + } + + /** + * Set Result. + * + * @param value - new value. + */ + public void setResult(ResourcePackStatus value) { + handle.getResourcePackStatus().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandBlock.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandBlock.java new file mode 100644 index 000000000..f3138bec9 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandBlock.java @@ -0,0 +1,111 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.utility.MinecraftReflection; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayClientSetCommandBlock extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.SET_COMMAND_BLOCK; + + public WrapperPlayClientSetCommandBlock() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientSetCommandBlock(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().readSafely(0); + } + + /** + * Set Location. + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().writeSafely(0, value); + } + + /** + * Retrieve Command. + * @return The current Command + */ + public String getCommand() { + return handle.getStrings().read(0); + } + + /** + * Set Command. + * @param value - new value. + */ + public void setCommand(String value) { + handle.getStrings().write(0, value); + } + + /** + * if false, the output of the previous command will not be stored within the command block + */ + public boolean isTrackOutput() { + return handle.getBooleans().read(0); + } + + public void setTrackOutput(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean isConditional() { + return handle.getBooleans().read(1); + } + + public void setConditional(boolean value) { + handle.getBooleans().write(1, value); + } + + public boolean isAutomatic() { + return handle.getBooleans().read(2); + } + + public void setAutomatic(boolean value) { + handle.getBooleans().write(2, value); + } + + public Mode getMode() { + return handle.getEnumModifier(Mode.class, MinecraftReflection.getMinecraftClass("TileEntityCommand$Type")).readSafely(0); + } + + public void setMode(Mode mode) { + handle.getEnumModifier(Mode.class, MinecraftReflection.getMinecraftClass("TileEntityCommand$Type")).writeSafely(0, mode); + } + + public enum Mode { + SEQUENCE, + AUTO, + REDSTONE + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandMinecart.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandMinecart.java new file mode 100644 index 000000000..e8cc92a26 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCommandMinecart.java @@ -0,0 +1,109 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +public class WrapperPlayClientSetCommandMinecart extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.SET_COMMAND_MINECART; + + public WrapperPlayClientSetCommandMinecart() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientSetCommandMinecart(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Retrieve the entity involved in this event. + * @param world - the current world of the entity. + * @return The involved entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity involved in this event. + * @param event - the packet event. + * @return The involved entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Set Entity ID. + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Command. + * @return The current Command + */ + public String getCommand() { + return handle.getStrings().read(0); + } + + /** + * Set Command. + * @param value - new value. + */ + public void setCommand(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Track Output. + *

+ * Notes: if false, the output of the previous command will not be stored within the command block. + * @return The current Track Output + */ + public boolean getTrackOutput() { + return handle.getBooleans().read(0); + } + + /** + * Set Track Output. + * @param value - new value. + */ + public void setTrackOutput(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCreativeSlot.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCreativeSlot.java new file mode 100644 index 000000000..d5debf117 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSetCreativeSlot.java @@ -0,0 +1,77 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.inventory.ItemStack; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientSetCreativeSlot extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Client.SET_CREATIVE_SLOT; + + public WrapperPlayClientSetCreativeSlot() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientSetCreativeSlot(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Slot. + *

+ * Notes: inventory slot + * + * @return The current Slot + */ + public int getSlot() { + return handle.getIntegers().read(0); + } + + /** + * Set Slot. + * + * @param value - new value. + */ + public void setSlot(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Clicked item. + * + * @return The current Clicked item + */ + public ItemStack getClickedItem() { + return handle.getItemModifier().read(0); + } + + /** + * Set Clicked item. + * + * @param value - new value. + */ + public void setClickedItem(ItemStack value) { + handle.getItemModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSettings.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSettings.java new file mode 100644 index 000000000..e1f639dde --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSettings.java @@ -0,0 +1,137 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility; + +public class WrapperPlayClientSettings extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.SETTINGS; + + public WrapperPlayClientSettings() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientSettings(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Locale. + *

+ * Notes: en_GB + * + * @return The current Locale + */ + public String getLocale() { + return handle.getStrings().read(0); + } + + /** + * Set Locale. + * + * @param value - new value. + */ + public void setLocale(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve View distance. + *

+ * Notes: client-side render distance(chunks) + * + * @return The current View distance + */ + public int getViewDistance() { + return handle.getIntegers().read(0); + } + + /** + * Set View distance. + * + * @param value - new value. + */ + public void setViewDistance(byte value) { + handle.getIntegers().write(0, (int) value); + } + + /** + * Retrieve Chat flags. + *

+ * Notes: chat settings. See notes below. + * + * @return The current Chat flags + */ + public ChatVisibility getChatFlags() { + return handle.getChatVisibilities().read(0); + } + + /** + * Set Chat flags. + * + * @param value - new value. + */ + public void setChatFlags(ChatVisibility value) { + handle.getChatVisibilities().write(0, value); + } + + /** + * Retrieve Chat colours. + *

+ * Notes: "Colours" multiplayer setting + * + * @return The current Chat colours + */ + public boolean getChatColours() { + return handle.getBooleans().read(0); + } + + /** + * Set Chat colours. + * + * @param value - new value. + */ + public void setChatColours(boolean value) { + handle.getBooleans().write(0, value); + } + + /** + * Retrieve Displayed skin parts. + *

+ * Notes: skin parts. See note below + * + * @return The current Displayed skin parts + */ + public int getDisplayedSkinParts() { + return handle.getIntegers().read(1); + } + + /** + * Set Displayed skin parts. + * + * @param value - new value. + */ + public void setDisplayedSkinParts(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSpectate.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSpectate.java new file mode 100644 index 000000000..255d997b2 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSpectate.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.UUID; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientSpectate extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.SPECTATE; + + public WrapperPlayClientSpectate() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientSpectate(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Target Player. + * + * @return The current Target Player + */ + public UUID getTargetPlayer() { + return handle.getUUIDs().read(0); + } + + /** + * Set Target Player. + * + * @param value - new value. + */ + public void setTargetPlayer(UUID value) { + handle.getUUIDs().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSteerVehicle.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSteerVehicle.java new file mode 100644 index 000000000..a0a7fc19d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientSteerVehicle.java @@ -0,0 +1,92 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientSteerVehicle extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.STEER_VEHICLE; + + public WrapperPlayClientSteerVehicle() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientSteerVehicle(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Sideways. + *

+ * Notes: positive to the left of the player + * + * @return The current Sideways + */ + public float getSideways() { + return handle.getFloat().read(0); + } + + /** + * Set Sideways. + * + * @param value - new value. + */ + public void setSideways(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Forward. + *

+ * Notes: positive forward + * + * @return The current Forward + */ + public float getForward() { + return handle.getFloat().read(1); + } + + /** + * Set Forward. + * + * @param value - new value. + */ + public void setForward(float value) { + handle.getFloat().write(1, value); + } + + public boolean isJump() { + return handle.getBooleans().read(0); + } + + public void setJump(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean isUnmount() { + return handle.getBooleans().read(1); + } + + public void setUnmount(boolean value) { + handle.getBooleans().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java new file mode 100644 index 000000000..68eb80272 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientStructureBlock.java @@ -0,0 +1,39 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayClientStructureBlock extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.STRUCTURE_BLOCK; + + public WrapperPlayClientStructureBlock() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientStructureBlock(PacketContainer packet) { + super(packet, TYPE); + } + + // TODO manually upon request +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java new file mode 100644 index 000000000..171578623 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTabComplete.java @@ -0,0 +1,53 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.mojang.brigadier.suggestion.Suggestions; + +public class WrapperPlayClientTabComplete extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.TAB_COMPLETE; + + public WrapperPlayClientTabComplete() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientTabComplete(PacketContainer packet) { + super(packet, TYPE); + } + + public int getTransactionId() { + return handle.getIntegers().read(0); + } + + public void setTransactionId(int value) { + handle.getIntegers().write(0, value); + } + + public String getInput() { + return handle.getStrings().read(0); + } + + public void setInput(String value) { + handle.getStrings().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTeleportAccept.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTeleportAccept.java new file mode 100644 index 000000000..ebce6d4f7 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTeleportAccept.java @@ -0,0 +1,58 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientTeleportAccept extends AbstractPacket { + + public static final PacketType TYPE = + PacketType.Play.Client.TELEPORT_ACCEPT; + + public WrapperPlayClientTeleportAccept() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientTeleportAccept(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Teleport ID. + *

+ * Notes: the ID given by the Player Position And Look packet + * + * @return The current Teleport ID + */ + public int getTeleportId() { + return handle.getIntegers().read(0); + } + + /** + * Set Teleport ID. + * + * @param value - new value. + */ + public void setTeleportId(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTileNbtQuery.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTileNbtQuery.java new file mode 100644 index 000000000..5653ee687 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTileNbtQuery.java @@ -0,0 +1,74 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayClientTileNbtQuery extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.TILE_NBT_QUERY; + + public WrapperPlayClientTileNbtQuery() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientTileNbtQuery(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Transaction ID. + *

+ * Notes: an incremental ID so that the client can verify that the response matches. + * @return The current Transaction ID + */ + public int getTransactionId() { + return handle.getIntegers().read(0); + } + + /** + * Set Transaction ID. + * @param value - new value. + */ + public void setTransactionId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Location. + *

+ * Notes: the location of the block to check. + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTradeSelect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTradeSelect.java new file mode 100644 index 000000000..1fed8dac4 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTradeSelect.java @@ -0,0 +1,21 @@ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientTradeSelect extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.TRADE_SELECT; + + public WrapperPlayClientTradeSelect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public int getSlot() { + return handle.getIntegers().read(0); + } + + public void setSlot(int value) { + handle.getIntegers().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTransaction.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTransaction.java new file mode 100644 index 000000000..65c011a5e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientTransaction.java @@ -0,0 +1,97 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientTransaction extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.TRANSACTION; + + public WrapperPlayClientTransaction() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientTransaction(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the id of the window that the action occurred in. + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(byte value) { + handle.getIntegers().write(0, (int) value); + } + + /** + * Retrieve Action number. + *

+ * Notes: every action that is to be accepted has a unique number. This + * field corresponds to that number. + * + * @return The current Action number + */ + public short getActionNumber() { + return handle.getShorts().read(0); + } + + /** + * Set Action number. + * + * @param value - new value. + */ + public void setActionNumber(short value) { + handle.getShorts().write(0, value); + } + + /** + * Retrieve Accepted. + *

+ * Notes: whether the action was accepted. + * + * @return The current Accepted + */ + public boolean getAccepted() { + return handle.getBooleans().read(0); + } + + /** + * Set Accepted. + * + * @param value - new value. + */ + public void setAccepted(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUpdateSign.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUpdateSign.java new file mode 100644 index 000000000..34ba2bddf --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUpdateSign.java @@ -0,0 +1,79 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayClientUpdateSign extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.UPDATE_SIGN; + + public WrapperPlayClientUpdateSign() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientUpdateSign(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + *

+ * Notes: block Coordinates + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + /** + * Retrieve this sign's lines of text. + * + * @return The current lines + */ + public String[] getLines() { + return handle.getStringArrays().read(0); + } + + /** + * Set this sign's lines of text. + * + * @param value - Lines, must be 4 elements long + */ + public void setLines(String[] value) { + if (value == null) + throw new IllegalArgumentException("value cannot be null!"); + if (value.length != 4) + throw new IllegalArgumentException("value must have 4 elements!"); + + handle.getStringArrays().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseEntity.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseEntity.java new file mode 100644 index 000000000..974b03679 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseEntity.java @@ -0,0 +1,117 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.util.Vector; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction; + +public class WrapperPlayClientUseEntity extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.USE_ENTITY; + + public WrapperPlayClientUseEntity() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientUseEntity(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve entity ID of the target. + * + * @return The current entity ID + */ + public int getTargetID() { + return handle.getIntegers().read(0); + } + + /** + * Retrieve the entity that was targeted. + * + * @param world - the current world of the entity. + * @return The targeted entity. + */ + public Entity getTarget(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity that was targeted. + * + * @param event - the packet event. + * @return The targeted entity. + */ + public Entity getTarget(PacketEvent event) { + return getTarget(event.getPlayer().getWorld()); + } + + /** + * Set entity ID of the target. + * + * @param value - new value. + */ + public void setTargetID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Type. + * + * @return The current Type + */ + public EntityUseAction getType() { + return handle.getEntityUseActions().read(0); + } + + /** + * Set Type. + * + * @param value - new value. + */ + public void setType(EntityUseAction value) { + handle.getEntityUseActions().write(0, value); + } + + /** + * Retrieve the target vector. + *

+ * Notes: Only if {@link #getType()} is {@link EntityUseAction#INTERACT_AT}. + * + * @return The target vector or null + */ + public Vector getTargetVector() { + return handle.getVectors().read(0); + } + + /** + * Set the target vector. + * + * @param value - new value. + */ + public void setTargetVector(Vector value) { + handle.getVectors().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseItem.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseItem.java new file mode 100644 index 000000000..f7083b805 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseItem.java @@ -0,0 +1,138 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.comphenix.protocol.wrappers.EnumWrappers.Direction; +import com.comphenix.protocol.wrappers.EnumWrappers.Hand; + +public class WrapperPlayClientUseItem extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.USE_ITEM; + + public WrapperPlayClientUseItem() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientUseItem(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + *

+ * Notes: block position + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + public Direction getFace() { + return handle.getDirections().read(0); + } + + public void setFace(Direction value) { + handle.getDirections().write(0, value); + } + + public Hand getHand() { + return handle.getHands().read(0); + } + + public void setHand(Hand value) { + handle.getHands().write(0, value); + } + + /** + * Retrieve Cursor Position X. + *

+ * Notes: the position of the crosshair on the block, from 0 to 15 + * increasing from west to east + * + * @return The current Cursor Position X + */ + public float getCursorPositionX() { + return handle.getFloat().read(0); + } + + /** + * Set Cursor Position X. + * + * @param value - new value. + */ + public void setCursorPositionX(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Cursor Position Y. + *

+ * Notes: the position of the crosshair on the block, from 0 to 15 + * increasing from bottom to top + * + * @return The current Cursor Position Y + */ + public float getCursorPositionY() { + return handle.getFloat().read(1); + } + + /** + * Set Cursor Position Y. + * + * @param value - new value. + */ + public void setCursorPositionY(float value) { + handle.getFloat().write(1, value); + } + + /** + * Retrieve Cursor Position Z. + *

+ * Notes: the position of the crosshair on the block, from 0 to 15 + * increasing from north to south + * + * @return The current Cursor Position Z + */ + public float getCursorPositionZ() { + return handle.getFloat().read(2); + } + + /** + * Set Cursor Position Z. + * + * @param value - new value. + */ + public void setCursorPositionZ(float value) { + handle.getFloat().write(2, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientVehicleMove.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientVehicleMove.java new file mode 100644 index 000000000..27f2d413b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientVehicleMove.java @@ -0,0 +1,137 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientVehicleMove extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Client.VEHICLE_MOVE; + + public WrapperPlayClientVehicleMove() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientVehicleMove(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve X. + *

+ * Notes: absolute position (X coordinate) + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve Y. + *

+ * Notes: absolute position (Y coordinate) + * + * @return The current Y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set Y. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: absolute position (Z coordinate) + * + * @return The current Z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Yaw. + *

+ * Notes: absolute rotation on the vertical axis, in degrees + * + * @return The current Yaw + */ + public float getYaw() { + return handle.getFloat().read(0); + } + + /** + * Set Yaw. + * + * @param value - new value. + */ + public void setYaw(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: absolute rotation on the horizontal axis, in degrees + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientWindowClick.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientWindowClick.java new file mode 100644 index 000000000..84bbb9fcb --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientWindowClick.java @@ -0,0 +1,148 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.inventory.ItemStack; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayClientWindowClick extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Client.WINDOW_CLICK; + + public WrapperPlayClientWindowClick() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayClientWindowClick(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the id of the window which was clicked. 0 for player inventory. + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Slot. + *

+ * Notes: the clicked slot. See below. + * + * @return The current Slot + */ + public int getSlot() { + return handle.getIntegers().read(1); + } + + /** + * Set Slot. + * + * @param value - new value. + */ + public void setSlot(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Button. + *

+ * Notes: the button used in the click. See below. + * + * @return The current Button + */ + public int getButton() { + return handle.getIntegers().read(2); + } + + /** + * Set Button. + * + * @param value - new value. + */ + public void setButton(int value) { + handle.getIntegers().write(2, value); + } + + /** + * Retrieve Action number. + *

+ * Notes: a unique number for the action, used for transaction handling (See + * the Transaction packet). + * + * @return The current Action number + */ + public short getActionNumber() { + return handle.getShorts().read(0); + } + + /** + * Set Action number. + * + * @param value - new value. + */ + public void setActionNumber(short value) { + handle.getShorts().write(0, value); + } + + /** + * Retrieve Clicked item. + * + * @return The current Clicked item + */ + public ItemStack getClickedItem() { + return handle.getItemModifier().read(0); + } + + /** + * Set Clicked item. + * + * @param value - new value. + */ + public void setClickedItem(ItemStack value) { + handle.getItemModifier().write(0, value); + } + + public InventoryClickType getShift() { + return handle.getEnumModifier(InventoryClickType.class, 5).read(0); + } + + public void setShift(InventoryClickType value) { + handle.getEnumModifier(InventoryClickType.class, 5).write(0, value); + } + + public enum InventoryClickType { + PICKUP, QUICK_MOVE, SWAP, CLONE, THROW, QUICK_CRAFT, PICKUP_ALL; + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAbilities.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAbilities.java new file mode 100644 index 000000000..6a406276f --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAbilities.java @@ -0,0 +1,99 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerAbilities extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ABILITIES; + + public WrapperPlayServerAbilities() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerAbilities(PacketContainer packet) { + super(packet, TYPE); + } + + public boolean isInvulnerable() { + return handle.getBooleans().read(0); + } + + public void setInvulnerable(boolean value) { + handle.getBooleans().write(0, value); + } + + /**Misspelled. + * @see #isInvulnerable() + */ + @Deprecated + public boolean isInvulnurable() { + return handle.getBooleans().read(0); + } + + /**Misspelled. + * @see #setInvulnerable(boolean) + */ + @Deprecated + public void setInvulnurable(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean isFlying() { + return handle.getBooleans().read(1); + } + + public void setFlying(boolean value) { + handle.getBooleans().write(1, value); + } + + public boolean canFly() { + return handle.getBooleans().read(2); + } + + public void setCanFly(boolean value) { + handle.getBooleans().write(2, value); + } + + public boolean canInstantlyBuild() { + return handle.getBooleans().read(3); + } + + public void setCanInstantlyBuild(boolean value) { + handle.getBooleans().write(3, value); + } + + public float getFlyingSpeed() { + return handle.getFloat().read(0); + } + + public void setFlyingSpeed(float value) { + handle.getFloat().write(0, value); + } + + public float getWalkingSpeed() { + return handle.getFloat().read(1); + } + + public void setWalkingSpeed(float value) { + handle.getFloat().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAdvancements.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAdvancements.java new file mode 100644 index 000000000..7d00790d7 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAdvancements.java @@ -0,0 +1,148 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.Date; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.*; + +import org.bukkit.advancement.Advancement; +import org.bukkit.inventory.ItemStack; + +import static com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass; + +public class WrapperPlayServerAdvancements extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.ADVANCEMENTS; + + public WrapperPlayServerAdvancements() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerAdvancements(PacketContainer packet) { + super(packet, TYPE); + } + + public static class SerializedAdvancement { + public MinecraftKey key; + public Advancement advancement; + public AdvancementDisplay display; + public Object rewards; + public Map criteria; + public String[][] requirements; + } + + public static class AdvancementDisplay { + public WrappedChatComponent title; + public WrappedChatComponent description; + public ItemStack icon; + public MinecraftKey background; + public FrameType frame; + public boolean showToast; + public boolean announceToChat; + public boolean hidden; + public float xCoord; + public float yCoord; + } + + public enum FrameType { + TASK, + CHALLENGE, + GOAL + } + + public static class AdvancementProgress { + public Map progress; + public String[][] array2d; + } + + public static class CriterionProgress { + public AdvancementProgress progress; + public Date date; + } + + private static final AutoWrapper DISPLAY = AutoWrapper + .wrap(AdvancementDisplay.class, "AdvancementDisplay") + .field(0, BukkitConverters.getWrappedChatComponentConverter()) + .field(1, BukkitConverters.getWrappedChatComponentConverter()) + .field(2, BukkitConverters.getItemStackConverter()) + .field(3, MinecraftKey.getConverter()) + .field(4, EnumWrappers.getGenericConverter(getMinecraftClass("AdvancementFrameType"), FrameType.class)); + + private static final AutoWrapper WRAPPER = AutoWrapper + .wrap(SerializedAdvancement.class,"Advancement$SerializedAdvancement") + .field(0, MinecraftKey.getConverter()) + .field(1, BukkitConverters.getAdvancementConverter()) + .field(2, DISPLAY); + + private static final AutoWrapper CRITERION = AutoWrapper + .wrap(CriterionProgress.class, "CriterionProgress"); + + private static final AutoWrapper PROGRESS = AutoWrapper + .wrap(AdvancementProgress.class, "AdvancementProgress") + .field(0, BukkitConverters.getMapConverter(Converters.passthrough(String.class), CRITERION)); + + static { + CRITERION.field(0, PROGRESS); + } + + /** + * Retrieve Reset/Clear. + *

+ * Notes: whether to reset/clear the current advancements + * @return The current Reset/Clear + */ + public boolean isReset() { + return handle.getBooleans().read(0); + } + + /** + * Set Reset/Clear. + * @param value - new value. + */ + public void setReset(boolean value) { + handle.getBooleans().write(0, value); + } + + public Optional> getAdvancements() { + return handle.getMaps(MinecraftKey.getConverter(), WRAPPER).optionRead(0); + } + + public void setAdvancements(Map value) { + handle.getMaps(MinecraftKey.getConverter(), WRAPPER).writeSafely(0, value); + } + + public Optional> getKeys() { + return handle.getSets(MinecraftKey.getConverter()).optionRead(0); + } + + public void setKeys(Set value) { + handle.getSets(MinecraftKey.getConverter()).writeSafely(0, value); + } + + public Optional> getProgress() { + return handle.getMaps(MinecraftKey.getConverter(), PROGRESS).optionRead(1); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAnimation.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAnimation.java new file mode 100644 index 000000000..f199e77d8 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAnimation.java @@ -0,0 +1,100 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerAnimation extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ANIMATION; + + public WrapperPlayServerAnimation() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerAnimation(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Animation. + *

+ * Notes: animation ID + * + * @return The current Animation + */ + public int getAnimation() { + return handle.getIntegers().read(1); + } + + /** + * Set Animation. + * + * @param value - new value. + */ + public void setAnimation(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAttachEntity.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAttachEntity.java new file mode 100644 index 000000000..f8800355e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAttachEntity.java @@ -0,0 +1,99 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerAttachEntity extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ATTACH_ENTITY; + + public WrapperPlayServerAttachEntity() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerAttachEntity(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Vehicle ID. + *

+ * Notes: vehicle's Entity ID + * + * @return The current Vehicle ID + */ + public int getVehicleId() { + return handle.getIntegers().read(1); + } + + /** + * Set Vehicle ID. + * + * @param value - new value. + */ + public void setVehicleId(int value) { + handle.getIntegers().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAutoRecipe.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAutoRecipe.java new file mode 100644 index 000000000..8c1cc678b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerAutoRecipe.java @@ -0,0 +1,54 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerAutoRecipe extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.AUTO_RECIPE; + + public WrapperPlayServerAutoRecipe() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerAutoRecipe(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + // Wrapper for recipe can be created upon request +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBed.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBed.java new file mode 100644 index 000000000..a86efa5c3 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBed.java @@ -0,0 +1,101 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerBed extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.BED; + + public WrapperPlayServerBed() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerBed(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Location. + *

+ * Notes: block location of the head part of the bed + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockAction.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockAction.java new file mode 100644 index 000000000..34db77e07 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockAction.java @@ -0,0 +1,119 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.Material; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerBlockAction extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.BLOCK_ACTION; + + public WrapperPlayServerBlockAction() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerBlockAction(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + *

+ * Notes: block Coordinates + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + /** + * Retrieve Byte 1. + *

+ * Notes: varies depending on block - see Block_Actions + * + * @return The current Byte 1 + */ + public int getByte1() { + return handle.getIntegers().read(0); + } + + /** + * Set Byte 1. + * + * @param value - new value. + */ + public void setByte1(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Byte 2. + *

+ * Notes: varies depending on block - see Block_Actions + * + * @return The current Byte 2 + */ + public int getByte2() { + return handle.getIntegers().read(1); + } + + /** + * Set Byte 2. + * + * @param value - new value. + */ + public void setByte2(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Block Type. + *

+ * Notes: the block type for the block + * + * @return The current Block Type + */ + public Material getBlockType() { + return handle.getBlocks().read(0); + } + + /** + * Set Block Type. + * + * @param value - new value. + */ + public void setBlockType(Material value) { + handle.getBlocks().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockBreakAnimation.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockBreakAnimation.java new file mode 100644 index 000000000..a9a72b773 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockBreakAnimation.java @@ -0,0 +1,122 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerBlockBreakAnimation extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.BLOCK_BREAK_ANIMATION; + + public WrapperPlayServerBlockBreakAnimation() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerBlockBreakAnimation(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Location. + *

+ * Notes: block Position + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + /** + * Retrieve Destroy Stage. + *

+ * Notes: 0 - 9 + * + * @return The current Destroy Stage + */ + public int getDestroyStage() { + return handle.getIntegers().read(1); + } + + /** + * Set Destroy Stage. + * + * @param value - new value. + */ + public void setDestroyStage(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockChange.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockChange.java new file mode 100644 index 000000000..c3a2beb64 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBlockChange.java @@ -0,0 +1,88 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.Location; +import org.bukkit.World; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.comphenix.protocol.wrappers.WrappedBlockData; + +public class WrapperPlayServerBlockChange extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.BLOCK_CHANGE; + + public WrapperPlayServerBlockChange() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerBlockChange(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + *

+ * Notes: block Coordinates + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + /** + * Retrieve the Bukkit Location. + * + * @param world World for the location + * @return Bukkit Location + */ + public Location getBukkitLocation(World world) { + return getLocation().toVector().toLocation(world); + } + + /** + * Retrieve Block Data. + * + * @return The current Block Data + */ + public WrappedBlockData getBlockData() { + return handle.getBlockData().read(0); + } + + /** + * Set Block Data. + * + * @param value - new value. + */ + public void setBlockData(WrappedBlockData value) { + handle.getBlockData().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBoss.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBoss.java new file mode 100644 index 000000000..a161222d5 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerBoss.java @@ -0,0 +1,133 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.UUID; + +import org.bukkit.boss.BarColor; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerBoss extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.BOSS; + + public WrapperPlayServerBoss() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerBoss(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve UUID. + *

+ * Notes: unique ID for this bar + * + * @return The current UUID + */ + public UUID getUniqueId() { + return handle.getUUIDs().read(0); + } + + /** + * Set UUID. + * + * @param value - new value. + */ + public void setUniqueId(UUID value) { + handle.getUUIDs().write(0, value); + } + + public Action getAction() { + return handle.getEnumModifier(Action.class, 1).read(0); + } + + public void setAction(Action value) { + handle.getEnumModifier(Action.class, 1).write(0, value); + } + + public WrappedChatComponent getTitle() { + return handle.getChatComponents().read(0); + } + + public void setTitle(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + public float getHealth() { + return handle.getFloat().read(0); + } + + public void setHealth(float value) { + handle.getFloat().write(0, value); + } + + public BarColor getColor() { + return handle.getEnumModifier(BarColor.class, 4).read(0); + } + + public void setColor(BarColor value) { + handle.getEnumModifier(BarColor.class, 4).write(0, value); + } + + public BarStyle getStyle() { + return handle.getEnumModifier(BarStyle.class, 5).read(0); + } + + public void setStyle(BarStyle value) { + handle.getEnumModifier(BarStyle.class, 5).write(0, value); + } + + public boolean isDarkenSky() { + return handle.getBooleans().read(0); + } + + public void setDarkenSky(boolean value) { + handle.getBooleans().write(0, value); + } + + public boolean isPlayMusic() { + return handle.getBooleans().read(1); + } + + public void setPlayMusic(boolean value) { + handle.getBooleans().write(1, value); + } + + public boolean isCreateFog() { + return handle.getBooleans().read(2); + } + + public void setCreateFog(boolean value) { + handle.getBooleans().write(2, value); + } + + public static enum Action { + ADD, REMOVE, UPDATE_PCT, UPDATE_NAME, UPDATE_STYLE, UPDATE_PROPERTIES; + } + + public static enum BarStyle { + PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12, NOTCHED_20; + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCamera.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCamera.java new file mode 100644 index 000000000..b5a03808a --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCamera.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerCamera extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.CAMERA; + + public WrapperPlayServerCamera() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCamera(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Camera ID. + * + * @return The current Camera ID + */ + public int getCameraId() { + return handle.getIntegers().read(0); + } + + /** + * Set Camera ID. + * + * @param value - new value. + */ + public void setCameraId(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerChat.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerChat.java new file mode 100644 index 000000000..415bb2399 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerChat.java @@ -0,0 +1,104 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.Arrays; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers; +import com.comphenix.protocol.wrappers.EnumWrappers.ChatType; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerChat extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.CHAT; + + public WrapperPlayServerChat() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerChat(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve the chat message. + *

+ * Limited to 32767 bytes + * + * @return The current message + */ + public WrappedChatComponent getMessage() { + return handle.getChatComponents().read(0); + } + + /** + * Set the message. + * + * @param value - new value. + */ + public void setMessage(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + public ChatType getChatType() { + return handle.getChatTypes().read(0); + } + + public void setChatType(ChatType type) { + handle.getChatTypes().write(0, type); + } + + /** + * Retrieve Position. + *

+ * Notes: 0 - Chat (chat box) ,1 - System Message (chat box), 2 - Above + * action bar + * + * @return The current Position + * @deprecated Magic values replaced by enum + */ + @Deprecated + public byte getPosition() { + Byte position = handle.getBytes().readSafely(0); + if (position != null) { + return position; + } else { + return getChatType().getId(); + } + } + + /** + * Set Position. + * + * @param value - new value. + * @deprecated Magic values replaced by enum + */ + @Deprecated + public void setPosition(byte value) { + handle.getBytes().writeSafely(0, value); + + if (EnumWrappers.getChatTypeClass() != null) + { + Arrays.stream(ChatType.values()).filter(t -> t.getId() == value).findAny() + .ifPresent(t -> handle.getChatTypes().writeSafely(0, t)); + } + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCloseWindow.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCloseWindow.java new file mode 100644 index 000000000..1962cccbe --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCloseWindow.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerCloseWindow extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.CLOSE_WINDOW; + + public WrapperPlayServerCloseWindow() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCloseWindow(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: this is the id of the window that was closed. 0 for inventory. + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCollect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCollect.java new file mode 100644 index 000000000..c02c315ad --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCollect.java @@ -0,0 +1,72 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerCollect extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.COLLECT; + + public WrapperPlayServerCollect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCollect(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Collected Entity ID. + * + * @return The current Collected Entity ID + */ + public int getCollectedEntityId() { + return handle.getIntegers().read(0); + } + + /** + * Set Collected Entity ID. + * + * @param value - new value. + */ + public void setCollectedEntityId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Collector Entity ID. + * + * @return The current Collector Entity ID + */ + public int getCollectorEntityId() { + return handle.getIntegers().read(1); + } + + /** + * Set Collector Entity ID. + * + * @param value - new value. + */ + public void setCollectorEntityId(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCombatEvent.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCombatEvent.java new file mode 100644 index 000000000..b6b4fdfe0 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCombatEvent.java @@ -0,0 +1,136 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.CombatEventType; + +public class WrapperPlayServerCombatEvent extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.COMBAT_EVENT; + + public WrapperPlayServerCombatEvent() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCombatEvent(PacketContainer packet) { + super(packet, TYPE); + } + + // ---- All + + /** + * Retrieve Event. + *

+ * Notes: 0 ENTER_COMBAT, 1 END_COMBAT, 2 ENTITY_DEAD + * + * @return The current Event + */ + public CombatEventType getEvent() { + return handle.getCombatEvents().read(0); + } + + /** + * Set Event. + * + * @param value - new value. + */ + public void setEvent(CombatEventType value) { + handle.getCombatEvents().write(0, value); + } + + // ---- END_COMBAT + + public int getDuration() { + if (getEvent() != CombatEventType.END_COMBAT) + throw new IllegalStateException( + "Duration only exists for END_COMBAT"); + + return handle.getIntegers().read(0); + } + + public void setDuration(int value) { + if (getEvent() != CombatEventType.END_COMBAT) + throw new IllegalStateException( + "Duration only exists for END_COMBAT"); + + handle.getIntegers().write(0, value); + } + + // ---- ENTITY_DIED + + public int getPlayerID() { + if (getEvent() != CombatEventType.ENTITY_DIED) + throw new IllegalStateException( + "Player ID only exists for ENTITY_DEAD"); + + return handle.getIntegers().read(0); + } + + public void setPlayerId(int value) { + if (getEvent() != CombatEventType.ENTITY_DIED) + throw new IllegalStateException( + "Player ID only exists for ENTITY_DEAD"); + + handle.getIntegers().write(0, value); + } + + public int getEntityID() { + CombatEventType event = getEvent(); + switch (event) { + case END_COMBAT: + case ENTITY_DIED: + return handle.getIntegers().read(1); + default: + throw new IllegalStateException("Entity ID does not exist for " + + event); + + } + } + + public void setEntityId(int value) { + CombatEventType event = getEvent(); + switch (event) { + case END_COMBAT: + case ENTITY_DIED: + handle.getIntegers().write(1, value); + default: + throw new IllegalStateException("Entity ID does not exist for " + + event); + + } + } + + public String getMessage() { + if (getEvent() != CombatEventType.ENTITY_DIED) + throw new IllegalStateException( + "Message only exists for ENTITY_DEAD"); + + return handle.getStrings().read(0); + } + + public void setMessage(String value) { + if (getEvent() != CombatEventType.ENTITY_DIED) + throw new IllegalStateException( + "Message only exists for ENTITY_DEAD"); + + handle.getStrings().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java new file mode 100644 index 000000000..317cb0767 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCommands.java @@ -0,0 +1,49 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.mojang.brigadier.tree.RootCommandNode; + +public class WrapperPlayServerCommands extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.COMMANDS; + + public WrapperPlayServerCommands() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCommands(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Mojang's brigadier library isn't versioned inside craftbukkit, + * so it should be safe to use here. + */ + public RootCommandNode getRoot() { + return (RootCommandNode) handle.getModifier().read(0); + } + + public void setRoot(RootCommandNode node) { + handle.getModifier().write(0, node); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomPayload.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomPayload.java new file mode 100644 index 000000000..741b7062d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomPayload.java @@ -0,0 +1,103 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.utility.MinecraftReflection; +import com.comphenix.protocol.wrappers.MinecraftKey; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +public class WrapperPlayServerCustomPayload extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.CUSTOM_PAYLOAD; + + public WrapperPlayServerCustomPayload() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCustomPayload(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Channel. + *

+ * Notes: name of the "channel" used to send the data. + * + * @return The current Channel + */ + public MinecraftKey getChannel() { + return handle.getMinecraftKeys().read(0); + } + + /** + * Starting in 1.13, channel names need to be lower case, in the new identifier format, + * i.e. {@code minecraft:brand}. The previously standard {@code |} is no longer allowed. + */ + public void setChannel(MinecraftKey value) { + handle.getMinecraftKeys().write(0, value); + } + + /** + * Retrieve payload contents as a raw Netty buffer + * + * @return Payload contents as a Netty buffer + */ + public ByteBuf getContentsBuffer() { + return (ByteBuf) handle.getModifier().withType(ByteBuf.class).read(0); + } + + /** + * Retrieve payload contents + * + * @return Payload contents as a byte array + */ + public byte[] getContents() { + ByteBuf buffer = getContentsBuffer(); + byte[] array = new byte[buffer.readableBytes()]; + buffer.readBytes(array); + return array; + } + + /** + * Update payload contents with a Netty buffer + * + * @param contents - new payload content + */ + public void setContentsBuffer(ByteBuf contents) { + if (MinecraftReflection.is(MinecraftReflection.getPacketDataSerializerClass(), contents)) { + handle.getModifier().withType(ByteBuf.class).write(0, contents); + } else { + Object serializer = MinecraftReflection.getPacketDataSerializer(contents); + handle.getModifier().withType(ByteBuf.class).write(0, serializer); + } + } + + /** + * Update payload contents with a byte array + * + * @param content - new payload content + */ + public void setContents(byte[] content) { + setContentsBuffer(Unpooled.copiedBuffer(content)); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomSoundEffect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomSoundEffect.java new file mode 100644 index 000000000..70698137d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerCustomSoundEffect.java @@ -0,0 +1,183 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory; +import com.comphenix.protocol.wrappers.MinecraftKey; + +public class WrapperPlayServerCustomSoundEffect extends AbstractPacket { + + public static final PacketType TYPE = + PacketType.Play.Server.CUSTOM_SOUND_EFFECT; + + public WrapperPlayServerCustomSoundEffect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerCustomSoundEffect(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Sound Name. + *

+ * Notes: all known sound effect names can be seen here. + * + * @return The current Sound Name + */ + public MinecraftKey getSoundName() { + return handle.getMinecraftKeys().read(0); + } + + /** + * Set Sound Name. + * + * @param value - new value. + */ + public void setSoundName(MinecraftKey value) { + handle.getMinecraftKeys().write(0, value); + } + + /** + * Retrieve Sound Category. + *

+ * Notes: the category that this sound will be played from (current + * categories) + * + * @return The current Sound Category + */ + public SoundCategory getSoundCategory() { + return handle.getSoundCategories().read(0); + } + + /** + * Set Sound Category. + * + * @param value - new value. + */ + public void setSoundCategory(SoundCategory value) { + handle.getSoundCategories().write(0, value); + } + + /** + * Retrieve Effect Position X. + *

+ * Notes: effect X multiplied by 8 (fixed-point number with only 3 bits + * dedicated to the fractional part) + * + * @return The current Effect Position X + */ + public int getX() { + return handle.getIntegers().read(0); + } + + /** + * Set Effect Position X. + * + * @param value - new value. + */ + public void setX(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Effect Position Y. + *

+ * Notes: effect Y multiplied by 8 (fixed-point number with only 3 bits + * dedicated to the fractional part) + * + * @return The current Effect Position Y + */ + public int getY() { + return handle.getIntegers().read(1); + } + + /** + * Set Effect Position Y. + * + * @param value - new value. + */ + public void setY(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Effect Position Z. + *

+ * Notes: effect Z multiplied by 8 (fixed-point number with only 3 bits + * dedicated to the fractional part) + * + * @return The current Effect Position Z + */ + public int getZ() { + return handle.getIntegers().read(2); + } + + /** + * Set Effect Position Z. + * + * @param value - new value. + */ + public void setZ(int value) { + handle.getIntegers().write(2, value); + } + + /** + * Retrieve Volume. + *

+ * Notes: 1 is 100%, can be more + * + * @return The current Volume + */ + public float getVolume() { + return handle.getFloat().read(0); + } + + /** + * Set Volume. + * + * @param value - new value. + */ + public void setVolume(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: 63 is 100%, can be more + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntity.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntity.java new file mode 100644 index 000000000..0577ae983 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntity.java @@ -0,0 +1,79 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntity extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ENTITY; + + public WrapperPlayServerEntity() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntity(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityDestroy.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityDestroy.java new file mode 100644 index 000000000..4f854541e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityDestroy.java @@ -0,0 +1,67 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerEntityDestroy extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ENTITY_DESTROY; + + public WrapperPlayServerEntityDestroy() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityDestroy(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Count. + *

+ * Notes: length of following array + * + * @return The current Count + */ + public int getCount() { + return handle.getIntegerArrays().read(0).length; + } + + /** + * Retrieve Entity IDs. + *

+ * Notes: the list of entities of destroy + * + * @return The current Entity IDs + */ + public int[] getEntityIDs() { + return handle.getIntegerArrays().read(0); + } + + /** + * Set Entity IDs. + * + * @param value - new value. + */ + public void setEntityIds(int[] value) { + handle.getIntegerArrays().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEffect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEffect.java new file mode 100644 index 000000000..cd9b6dc6d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEffect.java @@ -0,0 +1,154 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntityEffect extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ENTITY_EFFECT; + + public WrapperPlayServerEntityEffect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityEffect(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Effect ID. + *

+ * Notes: see [[1]] + * + * @return The current Effect ID + */ + public byte getEffectID() { + return handle.getBytes().read(0); + } + + /** + * Set Effect ID. + * + * @param value - new value. + */ + public void setEffectID(byte value) { + handle.getBytes().write(0, (byte) (value & 255)); + } + + /** + * Retrieve Amplifier. + * + * @return The current Amplifier + */ + public byte getAmplifier() { + return handle.getBytes().read(1); + } + + /** + * Set Amplifier. + * + * @param value - new value. + */ + public void setAmplifier(byte value) { + handle.getBytes().write(1, (byte) (value & 255)); + } + + /** + * Retrieve Duration. + * + * @return The current Duration + */ + public int getDuration() { + return handle.getIntegers().read(1); + } + + /** + * Set Duration. + * + * @param value - new value. + */ + public void setDuration(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Hide Particles. + * + * @return The current Hide Particles + */ + public boolean getHideParticles() { + return handle.getBytes().read(2) == 0; + } + + /** + * Set Hide Particles. + * + * @param value - new value. + */ + public void setHideParticles(boolean value) { + handle.getBytes().write(2, (byte) (value ? 0 : 1)); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEquipment.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEquipment.java new file mode 100644 index 000000000..87d038657 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityEquipment.java @@ -0,0 +1,110 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.inventory.ItemStack; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot; + +public class WrapperPlayServerEntityEquipment extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.ENTITY_EQUIPMENT; + + public WrapperPlayServerEntityEquipment() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityEquipment(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + public ItemSlot getSlot() { + return handle.getItemSlots().read(0); + } + + public void setSlot(ItemSlot value) { + handle.getItemSlots().write(0, value); + } + + /** + * Retrieve Item. + *

+ * Notes: item in slot format + * + * @return The current Item + */ + public ItemStack getItem() { + return handle.getItemModifier().read(0); + } + + /** + * Set Item. + * + * @param value - new value. + */ + public void setItem(ItemStack value) { + handle.getItemModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityHeadRotation.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityHeadRotation.java new file mode 100644 index 000000000..8b7b07931 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityHeadRotation.java @@ -0,0 +1,100 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntityHeadRotation extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.ENTITY_HEAD_ROTATION; + + public WrapperPlayServerEntityHeadRotation() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityHeadRotation(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Head Yaw. + *

+ * Notes: head yaw in steps of 2p/256 + * + * @return The current Head Yaw + */ + public byte getHeadYaw() { + return handle.getBytes().read(0); + } + + /** + * Set Head Yaw. + * + * @param value - new value. + */ + public void setHeadYaw(byte value) { + handle.getBytes().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityLook.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityLook.java new file mode 100644 index 000000000..c9d0b4786 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityLook.java @@ -0,0 +1,133 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntityLook extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ENTITY_LOOK; + + public WrapperPlayServerEntityLook() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityLook(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve the yaw of the current entity. + * + * @return The current Yaw + */ + public float getYaw() { + return (handle.getBytes().read(0) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the current entity. + * + * @param value - new yaw. + */ + public void setYaw(float value) { + handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the pitch of the current entity. + * + * @return The current pitch + */ + public float getPitch() { + return (handle.getBytes().read(1) * 360.F) / 256.0F; + } + + /** + * Set the pitch of the current entity. + * + * @param value - new pitch. + */ + public void setPitch(float value) { + handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve On Ground. + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java new file mode 100644 index 000000000..3f0d78498 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java @@ -0,0 +1,101 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.List; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.WrappedWatchableObject; + +public class WrapperPlayServerEntityMetadata extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.ENTITY_METADATA; + + public WrapperPlayServerEntityMetadata() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityMetadata(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Metadata. + * + * @return The current Metadata + */ + public List getMetadata() { + return handle.getWatchableCollectionModifier().read(0); + } + + /** + * Set Metadata. + * + * @param value - new value. + */ + public void setMetadata(List value) { + handle.getWatchableCollectionModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityStatus.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityStatus.java new file mode 100644 index 000000000..edfc8dd44 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityStatus.java @@ -0,0 +1,99 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntityStatus extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.ENTITY_STATUS; + + public WrapperPlayServerEntityStatus() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityStatus(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Entity Status. + *

+ * Notes: see below + * + * @return The current Entity Status + */ + public byte getEntityStatus() { + return handle.getBytes().read(0); + } + + /** + * Set Entity Status. + * + * @param value - new value. + */ + public void setEntityStatus(byte value) { + handle.getBytes().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityTeleport.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityTeleport.java new file mode 100644 index 000000000..c0e17a228 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityTeleport.java @@ -0,0 +1,146 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntityTeleport extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.ENTITY_TELEPORT; + + public WrapperPlayServerEntityTeleport() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityTeleport(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve entity ID. + * + * @return The current EID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity. + * + * @param world - the current world of the entity. + * @return The entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity. + * + * @param event - the packet event. + * @return The entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + public double getX() { + return handle.getDoubles().read(0); + } + + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + public double getY() { + return handle.getDoubles().read(1); + } + + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + public double getZ() { + return handle.getDoubles().read(2); + } + + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve the yaw of the current entity. + * + * @return The current Yaw + */ + public float getYaw() { + return (handle.getBytes().read(0) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the current entity. + * + * @param value - new yaw. + */ + public void setYaw(float value) { + handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the pitch of the current entity. + * + * @return The current pitch + */ + public float getPitch() { + return (handle.getBytes().read(1) * 360.F) / 256.0F; + } + + /** + * Set the pitch of the current entity. + * + * @param value - new pitch. + */ + public void setPitch(float value) { + handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F)); + } + + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityVelocity.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityVelocity.java new file mode 100644 index 000000000..282fe8fcb --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityVelocity.java @@ -0,0 +1,134 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerEntityVelocity extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.ENTITY_VELOCITY; + + public WrapperPlayServerEntityVelocity() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerEntityVelocity(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve the velocity in the x axis. + * + * @return The current velocity X + */ + public double getVelocityX() { + return handle.getIntegers().read(1) / 8000.0D; + } + + /** + * Set the velocity in the x axis. + * + * @param value - new value. + */ + public void setVelocityX(double value) { + handle.getIntegers().write(1, (int) (value * 8000.0D)); + } + + /** + * Retrieve the velocity in the y axis. + * + * @return The current velocity y + */ + public double getVelocityY() { + return handle.getIntegers().read(2) / 8000.0D; + } + + /** + * Set the velocity in the y axis. + * + * @param value - new value. + */ + public void setVelocityY(double value) { + handle.getIntegers().write(2, (int) (value * 8000.0D)); + } + + /** + * Retrieve the velocity in the z axis. + * + * @return The current velocity z + */ + public double getVelocityZ() { + return handle.getIntegers().read(3) / 8000.0D; + } + + /** + * Set the velocity in the z axis. + * + * @param value - new value. + */ + public void setVelocityZ(double value) { + handle.getIntegers().write(3, (int) (value * 8000.0D)); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExperience.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExperience.java new file mode 100644 index 000000000..067c707d7 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExperience.java @@ -0,0 +1,92 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerExperience extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.EXPERIENCE; + + public WrapperPlayServerExperience() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerExperience(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Experience bar. + *

+ * Notes: between 0 and 1 + * + * @return The current Experience bar + */ + public float getExperienceBar() { + return handle.getFloat().read(0); + } + + /** + * Set Experience bar. + * + * @param value - new value. + */ + public void setExperienceBar(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Level. + * + * @return The current Level + */ + public int getLevel() { + return handle.getIntegers().read(1); + } + + /** + * Set Level. + * + * @param value - new value. + */ + public void setLevel(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Total Experience. + * + * @return The current Total Experience + */ + public int getTotalExperience() { + return handle.getIntegers().read(0); + } + + /** + * Set Total Experience. + * + * @param value - new value. + */ + public void setTotalExperience(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExplosion.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExplosion.java new file mode 100644 index 000000000..ac960e7dd --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerExplosion.java @@ -0,0 +1,171 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.List; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerExplosion extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.EXPLOSION; + + public WrapperPlayServerExplosion() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerExplosion(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve X. + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve Y. + * + * @return The current Y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set Y. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Z. + * + * @return The current Z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Radius. + *

+ * Notes: currently unused in the client + * + * @return The current Radius + */ + public float getRadius() { + return handle.getFloat().read(0); + } + + /** + * Set Radius. + * + * @param value - new value. + */ + public void setRadius(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Record count. + *

+ * Notes: this is the count, not the size. The size is 3 times this value. + * + * @return The current Record count + */ + public List getRecords() { + return handle.getBlockPositionCollectionModifier().read(0); + } + + /** + * Retrieve Record count. + *

+ * Notes: this is the count, not the size. The size is 3 times this value. + * + * @return The current Record count + * @deprecated Misspelled. + * @see #getRecords() + */ + @Deprecated + public List getRecors() { + return handle.getBlockPositionCollectionModifier().read(0); + } + + /** + * Set Record count. + * + * @param value - new value. + */ + public void setRecords(List value) { + handle.getBlockPositionCollectionModifier().write(0, value); + } + + public float getPlayerVelocityX() { + return handle.getFloat().read(0); + } + + public void setPlayerVelocityX(float value) { + handle.getFloat().write(0, value); + } + + public float getPlayerVelocityY() { + return handle.getFloat().read(1); + } + + public void setPlayerVelocityY(float value) { + handle.getFloat().write(1, value); + } + + public float getPlayerVelocityZ() { + return handle.getFloat().read(2); + } + + public void setPlayerVelocityZ(float value) { + handle.getFloat().write(2, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerGameStateChange.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerGameStateChange.java new file mode 100644 index 000000000..d96ec31b5 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerGameStateChange.java @@ -0,0 +1,75 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerGameStateChange extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.GAME_STATE_CHANGE; + + public WrapperPlayServerGameStateChange() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerGameStateChange(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Reason. + * + * @return The current Reason + */ + public int getReason() { + return handle.getIntegers().read(0); + } + + /** + * Set Reason. + * + * @param value - new value. + */ + public void setReason(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Value. + *

+ * Notes: depends on reason + * + * @return The current Value + */ + public float getValue() { + return handle.getFloat().read(0); + } + + /** + * Set Value. + * + * @param value - new value. + */ + public void setValue(float value) { + handle.getFloat().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerHeldItemSlot.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerHeldItemSlot.java new file mode 100644 index 000000000..fc290432b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerHeldItemSlot.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerHeldItemSlot extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.HELD_ITEM_SLOT; + + public WrapperPlayServerHeldItemSlot() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerHeldItemSlot(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Slot. + *

+ * Notes: the slot which the player has selected (0-8) + * + * @return The current Slot + */ + public int getSlot() { + return handle.getIntegers().read(0); + } + + /** + * Set Slot. + * + * @param value - new value. + */ + public void setSlot(int value) { + handle.getIntegers().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKeepAlive.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKeepAlive.java new file mode 100644 index 000000000..0aa09d75b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKeepAlive.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerKeepAlive extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.KEEP_ALIVE; + + public WrapperPlayServerKeepAlive() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerKeepAlive(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Keep Alive ID. + * + * @return The current Keep Alive ID + */ + public long getKeepAliveId() { + return handle.getLongs().read(0); + } + + /** + * Set Keep Alive ID. + * + * @param value - new value. + */ + public void setKeepAliveId(long value) { + handle.getLongs().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKickDisconnect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKickDisconnect.java new file mode 100644 index 000000000..d26c349a6 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerKickDisconnect.java @@ -0,0 +1,59 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerKickDisconnect extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.KICK_DISCONNECT; + + public WrapperPlayServerKickDisconnect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerKickDisconnect(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Reason. + *

+ * Notes: displayed to the client when the connection terminates. Must be + * valid JSON. + * + * @return The current Reason + */ + public WrappedChatComponent getReason() { + return handle.getChatComponents().read(0); + } + + /** + * Set Reason. + * + * @param value - new value. + */ + public void setReason(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLogin.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLogin.java new file mode 100644 index 000000000..583ff14ea --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLogin.java @@ -0,0 +1,201 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.WorldType; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty; +import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; + +public class WrapperPlayServerLogin extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.LOGIN; + + public WrapperPlayServerLogin() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerLogin(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Gamemode. + *

+ * Notes: 0: survival, 1: creative, 2: adventure. Bit 3 (0x8) is the + * hardcore flag + * + * @return The current Gamemode + */ + public NativeGameMode getGamemode() { + return handle.getGameModes().read(0); + } + + /** + * Set Gamemode. + * + * @param value - new value. + */ + public void setGamemode(NativeGameMode value) { + handle.getGameModes().write(0, value); + } + + /** + * Retrieve Dimension. + *

+ * Notes: -1: nether, 0: overworld, 1: end + * + * @return The current Dimension + */ + public int getDimension() { + return handle.getIntegers().read(0); + } + + /** + * Set Dimension. + * + * @param value - new value. + */ + public void setDimension(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Difficulty. + *

+ * Notes: 0 thru 3 for Peaceful, Easy, Normal, Hard + * + * @return The current Difficulty + */ + public Difficulty getDifficulty() { + return handle.getDifficulties().read(0); + } + + /** + * Set Difficulty. + * + * @param value - new value. + */ + public void setDifficulty(Difficulty value) { + handle.getDifficulties().write(0, value); + } + + /** + * Retrieve Max Players. + *

+ * Notes: used by the client to draw the player list + * + * @return The current Max Players + */ + public int getMaxPlayers() { + return handle.getIntegers().read(1); + } + + /** + * Set Max Players. + * + * @param value - new value. + */ + public void setMaxPlayers(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Level Type. + *

+ * Notes: default, flat, largeBiomes, amplified, default_1_1 + * + * @return The current Level Type + */ + public WorldType getLevelType() { + return handle.getWorldTypeModifier().read(0); + } + + /** + * Set Level Type. + * + * @param value - new value. + */ + public void setLevelType(WorldType value) { + handle.getWorldTypeModifier().write(0, value); + } + + /** + * Retrieve Reduced Debug Info. + * + * @return The current Reduced Debug Info + */ + public boolean getReducedDebugInfo() { + return handle.getBooleans().read(0); + } + + /** + * Set Reduced Debug Info. + * + * @param value - new value. + */ + public void setReducedDebugInfo(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLookAt.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLookAt.java new file mode 100644 index 000000000..49423c549 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerLookAt.java @@ -0,0 +1,194 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + *

+ * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.utility.MinecraftReflection; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +public class WrapperPlayServerLookAt extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.LOOK_AT; + + public WrapperPlayServerLookAt() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerLookAt(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Feet/eyes. + *

+ * Notes: values are feet=0, eyes=1. If set to eyes, aims using the head position; otherwise aims using the feet position. + * @return The current Feet/eyes + */ + public Anchor getAnchor() { + return handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor")) + .readSafely(0); + } + + /** + * Set Feet/eyes. + * @param value - new value. + */ + public void setAnchor(Anchor value) { + handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor")) + .writeSafely(0, value); + } + + /** + * Retrieve Target x. + *

+ * Notes: x coordinate of the point to face towards + * @return The current Target x + */ + public double getTargetX() { + return handle.getDoubles().read(0); + } + + /** + * Set Target x. + * @param value - new value. + */ + public void setTargetX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve Target y. + *

+ * Notes: y coordinate of the point to face towards + * @return The current Target y + */ + public double getTargetY() { + return handle.getDoubles().read(1); + } + + /** + * Set Target y. + * @param value - new value. + */ + public void setTargetY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Target z. + *

+ * Notes: z coordinate of the point to face towards + * @return The current Target z + */ + public double getTargetZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Target z. + * @param value - new value. + */ + public void setTargetZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Is entity. + *

+ * Notes: if true, additional information about an entity is provided. + * @return The current Is entity + */ + public boolean getIsEntity() { + return handle.getBooleans().read(0); + } + + /** + * Set Is entity. + * @param value - new value. + */ + public void setIsEntity(boolean value) { + handle.getBooleans().write(0, value); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: only if is entity is true — the entity to face towards + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity involved in this event. + * @param world - the current world of the entity. + * @return The involved entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(6); + } + + /** + * Retrieve the entity involved in this event. + * @param event - the packet event. + * @return The involved entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Entity feet/eyes. + *

+ * Notes: whether to look at the entity's eyes or feet. Same values and meanings as before, just for the entity's head/feet. + * @return The current Entity feet/eyes + */ + public Anchor getEntityAnchor() { + return handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor")) + .readSafely(1); + } + + /** + * Set Entity feet/eyes. + * @param value - new value. + */ + public void setEntityAnchor(Anchor value) { + handle.getEnumModifier(Anchor.class, MinecraftReflection.getMinecraftClass("ArgumentAnchor$Anchor")) + .writeSafely(1, value); + } + + public enum Anchor { + FEET, + EYES + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMap.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMap.java new file mode 100644 index 000000000..6b466bc49 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMap.java @@ -0,0 +1,129 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerMap extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.MAP; + + public WrapperPlayServerMap() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerMap(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Item Damage. + *

+ * Notes: the damage value of the map being modified + * + * @return The current Item Damage + */ + public int getItemDamage() { + return handle.getIntegers().read(0); + } + + /** + * Set Item Damage. + * + * @param value - new value. + */ + public void setItemDamage(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Scale. + * + * @return The current Scale + */ + public byte getScale() { + return handle.getBytes().read(0); + } + + /** + * Set Scale. + * + * @param value - new value. + */ + public void setScale(byte value) { + handle.getBytes().write(0, value); + } + + public boolean getTrackingPosition() { + return handle.getBooleans().read(0); + } + + public void setTrackingPosition(boolean value) { + handle.getBooleans().write(0, value); + } + + public Object[] getMapIcons() { + return (Object[]) handle.getModifier().read(3); + } + + public void setMapIcons(Object[] value) { + handle.getModifier().write(3, value); + } + + public int getColumns() { + return handle.getIntegers().read(3); + } + + public void setColumns(int value) { + handle.getIntegers().write(3, value); + } + + public int getRows() { + return handle.getIntegers().read(4); + } + + public void setRows(int value) { + handle.getIntegers().write(4, value); + } + + public int getX() { + return handle.getIntegers().read(1); + } + + public void setX(int value) { + handle.getIntegers().write(1, value); + } + + public int getZ() { + return handle.getIntegers().read(2); + } + + public void setZ(int value) { + handle.getIntegers().write(2, value); + } + + public byte[] getData() { + return handle.getByteArrays().read(0); + } + + public void setData(byte[] value) { + handle.getByteArrays().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java new file mode 100644 index 000000000..091ba8659 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMapChunk.java @@ -0,0 +1,138 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.List; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.nbt.NbtBase; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; + +public class WrapperPlayServerMapChunk extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.MAP_CHUNK; + + public WrapperPlayServerMapChunk() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerMapChunk(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Chunk X. + *

+ * Notes: chunk X coordinate + * + * @return The current Chunk X + */ + public int getChunkX() { + return handle.getIntegers().read(0); + } + + /** + * Set Chunk X. + * + * @param value - new value. + */ + public void setChunkX(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Chunk Z. + *

+ * Notes: chunk Z coordinate + * + * @return The current Chunk Z + */ + public int getChunkZ() { + return handle.getIntegers().read(1); + } + + /** + * Set Chunk Z. + * + * @param value - new value. + */ + public void setChunkZ(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Ground-Up continuous. + *

+ * Notes: this is True if the packet represents all sections in this + * vertical column, where the primary bit map specifies exactly which + * sections are included, and which are air + * + * @return The current Ground-Up continuous + */ + public boolean getGroundUpContinuous() { + return handle.getBooleans().read(0); + } + + /** + * Set Ground-Up continuous. + * + * @param value - new value. + */ + public void setGroundUpContinuous(boolean value) { + handle.getBooleans().write(0, value); + } + + /** + * Bitmask with bits set to 1 for every 16×16×16 chunk section whose data is + * included in Data. The least significant bit represents the chunk section at + * the bottom of the chunk column (from y=0 to y=15). + * @return the bitmask + */ + public int getBitmask() { + return handle.getIntegers().read(2); + } + + public void setBitmask(int value) { + handle.getIntegers().write(2, value); + } + + /** + * See the wiki + * @return the data array + */ + public byte[] getData() { + return handle.getByteArrays().read(0); + } + + public void setData(byte[] value) { + handle.getByteArrays().write(0, value); + } + + /** + * @return all block entities in the chunk + */ + public List> getTileEntities() { + return handle.getListNbtModifier().read(0); + } + + public void setTileEntities(List> value) { + handle.getListNbtModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMount.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMount.java new file mode 100644 index 000000000..3e6eb4a9c --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMount.java @@ -0,0 +1,121 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerMount extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.MOUNT; + + public WrapperPlayServerMount() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerMount(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: vehicle's EID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Retrieve the entity involved in this event. + * + * @param world - the current world of the entity. + * @return The involved entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity involved in this event. + * + * @param event - the packet event. + * @return The involved entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + public int[] getPassengerIds() { + return handle.getIntegerArrays().read(0); + } + + public void setPassengerIds(int[] value) { + handle.getIntegerArrays().write(0, value); + } + + public List getPassengers(PacketEvent event) { + return getPassengers(event.getPlayer().getWorld()); + } + + public List getPassengers(World world) { + int[] ids = getPassengerIds(); + List passengers = new ArrayList<>(); + ProtocolManager manager = ProtocolLibrary.getProtocolManager(); + + for (int id : ids) { + Entity entity = manager.getEntityFromID(world, id); + if (entity != null) { + passengers.add(entity); + } + } + + return passengers; + } + + public void setPassengers(List value) { + int[] array = new int[value.size()]; + for (int i = 0; i < value.size(); i++) { + array[i] = value.get(i).getEntityId(); + } + + setPassengerIds(array); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMultiBlockChange.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMultiBlockChange.java new file mode 100644 index 000000000..84e6b0660 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerMultiBlockChange.java @@ -0,0 +1,74 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.ChunkCoordIntPair; +import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; + +public class WrapperPlayServerMultiBlockChange extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.MULTI_BLOCK_CHANGE; + + public WrapperPlayServerMultiBlockChange() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerMultiBlockChange(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve the chunk that has been altered. + * + * @return The current chunk + */ + public ChunkCoordIntPair getChunk() { + return handle.getChunkCoordIntPairs().read(0); + } + + /** + * Set the chunk that has been altered. + * + * @param value - new value + */ + public void setChunk(ChunkCoordIntPair value) { + handle.getChunkCoordIntPairs().write(0, value); + } + + /** + * Retrieve a copy of the record data as a block change array. + * + * @return The copied block change array. + */ + public MultiBlockChangeInfo[] getRecords() { + return handle.getMultiBlockChangeInfoArrays().read(0); + } + + /** + * Set the record data using the given helper array. + * + * @param value - new value + */ + public void setRecords(MultiBlockChangeInfo[] value) { + handle.getMultiBlockChangeInfoArrays().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedEntitySpawn.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedEntitySpawn.java new file mode 100644 index 000000000..100477478 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedEntitySpawn.java @@ -0,0 +1,204 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.UUID; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.util.Vector; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; + +public class WrapperPlayServerNamedEntitySpawn extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.NAMED_ENTITY_SPAWN; + + public WrapperPlayServerNamedEntitySpawn() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerNamedEntitySpawn(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Player UUID. + *

+ * Notes: player's UUID + * + * @return The current Player UUID + */ + public UUID getPlayerUUID() { + return handle.getUUIDs().read(0); + } + + /** + * Set Player UUID. + * + * @param value - new value. + */ + public void setPlayerUUID(UUID value) { + handle.getUUIDs().write(0, value); + } + + /** + * Retrieve the position of the spawned entity as a vector. + * + * @return The position as a vector. + */ + public Vector getPosition() { + return new Vector(getX(), getY(), getZ()); + } + + /** + * Set the position of the spawned entity using a vector. + * + * @param position - the new position. + */ + public void setPosition(Vector position) { + setX(position.getX()); + setY(position.getY()); + setZ(position.getZ()); + } + + public double getX() { + return handle.getDoubles().read(0); + } + + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + public double getY() { + return handle.getDoubles().read(1); + } + + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + public double getZ() { + return handle.getDoubles().read(2); + } + + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve the yaw of the spawned entity. + * + * @return The current Yaw + */ + public float getYaw() { + return (handle.getBytes().read(0) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the spawned entity. + * + * @param value - new yaw. + */ + public void setYaw(float value) { + handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the pitch of the spawned entity. + * + * @return The current pitch + */ + public float getPitch() { + return (handle.getBytes().read(1) * 360.F) / 256.0F; + } + + /** + * Set the pitch of the spawned entity. + * + * @param value - new pitch. + */ + public void setPitch(float value) { + handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve Metadata. + *

+ * Notes: the client will crash if no metadata is sent + * + * @return The current Metadata + */ + public WrappedDataWatcher getMetadata() { + return handle.getDataWatcherModifier().read(0); + } + + /** + * Set Metadata. + * + * @param value - new value. + */ + public void setMetadata(WrappedDataWatcher value) { + handle.getDataWatcherModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedSoundEffect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedSoundEffect.java new file mode 100644 index 000000000..e2f1848b0 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNamedSoundEffect.java @@ -0,0 +1,156 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.Sound; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory; + +public class WrapperPlayServerNamedSoundEffect extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.NAMED_SOUND_EFFECT; + + public WrapperPlayServerNamedSoundEffect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerNamedSoundEffect(PacketContainer packet) { + super(packet, TYPE); + } + + public Sound getSoundEffect() { + return handle.getSoundEffects().read(0); + } + + public void setSoundEffect(Sound value) { + handle.getSoundEffects().write(0, value); + } + + public SoundCategory getSoundCategory() { + return handle.getSoundCategories().read(0); + } + + public void setSoundCategory(SoundCategory value) { + handle.getSoundCategories().write(0, value); + } + + /** + * Retrieve Effect position X. + *

+ * Notes: effect X multiplied by 8 + * + * @return The current Effect position X + */ + public int getEffectPositionX() { + return handle.getIntegers().read(0); + } + + /** + * Set Effect position X. + * + * @param value - new value. + */ + public void setEffectPositionX(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Effect position Y. + *

+ * Notes: effect Y multiplied by 8 + * + * @return The current Effect position Y + */ + public int getEffectPositionY() { + return handle.getIntegers().read(1); + } + + /** + * Set Effect position Y. + * + * @param value - new value. + */ + public void setEffectPositionY(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Effect position Z. + *

+ * Notes: effect Z multiplied by 8 + * + * @return The current Effect position Z + */ + public int getEffectPositionZ() { + return handle.getIntegers().read(2); + } + + /** + * Set Effect position Z. + * + * @param value - new value. + */ + public void setEffectPositionZ(int value) { + handle.getIntegers().write(2, value); + } + + /** + * Retrieve Volume. + *

+ * Notes: 1 is 100%, can be more + * + * @return The current Volume + */ + public float getVolume() { + return handle.getFloat().read(0); + } + + /** + * Set Volume. + * + * @param value - new value. + */ + public void setVolume(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: 63 is 100%, can be more + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNbtQuery.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNbtQuery.java new file mode 100644 index 000000000..20fc22cf0 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerNbtQuery.java @@ -0,0 +1,74 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.nbt.NbtBase; + +public class WrapperPlayServerNbtQuery extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.NBT_QUERY; + + public WrapperPlayServerNbtQuery() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerNbtQuery(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Transaction ID. + *

+ * Notes: can be compared to the one sent in the original query packet. + * @return The current Transaction ID + */ + public int getTransactionId() { + return handle.getIntegers().read(0); + } + + /** + * Set Transaction ID. + * @param value - new value. + */ + public void setTransactionId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve NBT. + *

+ * Notes: the NBT of the block or entity. May be a TAG_END (0) in which case no NBT is present. + * @return The current NBT + */ + public NbtBase getNbt() { + return handle.getNbtModifier().read(0); + } + + /** + * Set NBT. + * @param value - new value. + */ + public void setNbt(NbtBase value) { + handle.getNbtModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenSignEditor.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenSignEditor.java new file mode 100644 index 000000000..e4318a1e5 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenSignEditor.java @@ -0,0 +1,57 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerOpenSignEditor extends AbstractPacket { + + public static final PacketType TYPE = + PacketType.Play.Server.OPEN_SIGN_EDITOR; + + public WrapperPlayServerOpenSignEditor() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerOpenSignEditor(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenWindow.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenWindow.java new file mode 100644 index 000000000..6112939f5 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerOpenWindow.java @@ -0,0 +1,162 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerOpenWindow extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.OPEN_WINDOW; + + public WrapperPlayServerOpenWindow() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerOpenWindow(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window id. + *

+ * Notes: a unique id number for the window to be displayed. Notchian server + * implementation is a counter, starting at 1. + * + * @return The current Window id + */ + public int getWindowID() { + return handle.getIntegers().read(0); + } + + /** + * Set Window id. + * + * @param value - new value. + */ + public void setWindowID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Inventory Type. + *

+ * Notes: the window type to use for display. Check below + * + * @return The current Inventory Type + */ + public String getInventoryType() { + return handle.getStrings().read(0); + } + + /** + * Set Inventory Type. + * + * @param value - new value. + */ + public void setInventoryType(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Window title. + *

+ * Notes: the title of the window. + * + * @return The current Window title + */ + public WrappedChatComponent getWindowTitle() { + return handle.getChatComponents().read(0); + } + + /** + * Set Window title. + * + * @param value - new value. + */ + public void setWindowTitle(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + /** + * Retrieve Number of Slots. + *

+ * Notes: number of slots in the window (excluding the number of slots in + * the player inventory). + * + * @return The current Number of Slots + */ + public int getNumberOfSlots() { + return handle.getIntegers().read(1); + } + + /** + * Set Number of Slots. + * + * @param value - new value. + */ + public void setNumberOfSlots(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerInfo.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerInfo.java new file mode 100644 index 000000000..003de435e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerInfo.java @@ -0,0 +1,55 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.List; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; +import com.comphenix.protocol.wrappers.PlayerInfoData; + +public class WrapperPlayServerPlayerInfo extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.PLAYER_INFO; + + public WrapperPlayServerPlayerInfo() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerPlayerInfo(PacketContainer packet) { + super(packet, TYPE); + } + + public PlayerInfoAction getAction() { + return handle.getPlayerInfoAction().read(0); + } + + public void setAction(PlayerInfoAction value) { + handle.getPlayerInfoAction().write(0, value); + } + + public List getData() { + return handle.getPlayerInfoDataLists().read(0); + } + + public void setData(List value) { + handle.getPlayerInfoDataLists().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerListHeaderFooter.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerListHeaderFooter.java new file mode 100644 index 000000000..83dc0f8d9 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPlayerListHeaderFooter.java @@ -0,0 +1,74 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerPlayerListHeaderFooter extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER; + + public WrapperPlayServerPlayerListHeaderFooter() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerPlayerListHeaderFooter(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Header. + * + * @return The current Header + */ + public WrappedChatComponent getHeader() { + return handle.getChatComponents().read(0); + } + + /** + * Set Header. + * + * @param value - new value. + */ + public void setHeader(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + /** + * Retrieve Footer. + * + * @return The current Footer + */ + public WrappedChatComponent getFooter() { + return handle.getChatComponents().read(1); + } + + /** + * Set Footer. + * + * @param value - new value. + */ + public void setFooter(WrappedChatComponent value) { + handle.getChatComponents().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPosition.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPosition.java new file mode 100644 index 000000000..4a8ab805f --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerPosition.java @@ -0,0 +1,161 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.Set; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.utility.MinecraftReflection; +import com.comphenix.protocol.wrappers.EnumWrappers; + +public class WrapperPlayServerPosition extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.POSITION; + + public WrapperPlayServerPosition() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerPosition(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve X. + *

+ * Notes: absolute/Relative position + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve Y. + *

+ * Notes: absolute/Relative position + * + * @return The current Y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set Y. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: absolute/Relative position + * + * @return The current Z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Yaw. + *

+ * Notes: absolute/Relative rotation on the X Axis, in degrees + * + * @return The current Yaw + */ + public float getYaw() { + return handle.getFloat().read(0); + } + + /** + * Set Yaw. + * + * @param value - new value. + */ + public void setYaw(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: absolute/Relative rotation on the Y Axis, in degrees + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } + + private static final Class FLAGS_CLASS = MinecraftReflection + .getMinecraftClass("EnumPlayerTeleportFlags", + "PacketPlayOutPosition$EnumPlayerTeleportFlags"); + + public enum PlayerTeleportFlag { + X, Y, Z, Y_ROT, X_ROT + } + + private StructureModifier> getFlagsModifier() { + return handle.getSets( + EnumWrappers.getGenericConverter(FLAGS_CLASS, PlayerTeleportFlag.class)); + } + + public Set getFlags() { + return getFlagsModifier().read(0); + } + + public void setFlags(Set value) { + getFlagsModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipeUpdate.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipeUpdate.java new file mode 100644 index 000000000..1a35ac7dc --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipeUpdate.java @@ -0,0 +1,38 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerRecipeUpdate extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.RECIPE_UPDATE; + + public WrapperPlayServerRecipeUpdate() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerRecipeUpdate(PacketContainer packet) { + super(packet, TYPE); + } + + // TODO manually upon request +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipes.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipes.java new file mode 100644 index 000000000..c8de409a1 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRecipes.java @@ -0,0 +1,98 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerRecipes extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.RECIPES; + + public WrapperPlayServerRecipes() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerRecipes(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Action. + *

+ * Notes: 0: init, 1: add, 2: remove + * @return The current Action + */ + public Action getAction() { + return handle.getEnumModifier(Action.class, 0).readSafely(0); + } + + /** + * Set Action. + * @param value - new value. + */ + public void setAction(Action value) { + handle.getEnumModifier(Action.class, 0).writeSafely(0, value); + } + + /** + * Retrieve Crafting Book Open. + *

+ * Notes: if true, then the crafting book will be open when the player opens its inventory. + * @return The current Crafting Book Open + */ + public boolean getCraftingBookOpen() { + return handle.getBooleans().read(0); + } + + /** + * Set Crafting Book Open. + * @param value - new value. + */ + public void setCraftingBookOpen(boolean value) { + handle.getBooleans().write(0, value); + } + + /** + * Retrieve Filtering Craftable. + *

+ * Notes: if true, then the filtering option is active when the players opens its inventory. + * @return The current Filtering Craftable + */ + public boolean getFilteringCraftable() { + return handle.getBooleans().read(0); + } + + /** + * Set Filtering Craftable. + * @param value - new value. + */ + public void setFilteringCraftable(boolean value) { + handle.getBooleans().write(0, value); + } + + // recipe ids + + public enum Action { + INIT, + ADD, + REMOVE; + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMove.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMove.java new file mode 100644 index 000000000..db8efae31 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMove.java @@ -0,0 +1,122 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerRelEntityMove extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.REL_ENTITY_MOVE; + + public WrapperPlayServerRelEntityMove() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerRelEntityMove(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + public int getDx() { + return handle.getIntegers().read(1); + } + + public void setDx(int value) { + handle.getIntegers().write(1, value); + } + + public int getDy() { + return handle.getIntegers().read(2); + } + + public void setDy(int value) { + handle.getIntegers().write(2, value); + } + + public int getDz() { + return handle.getIntegers().read(3); + } + + public void setDz(int value) { + handle.getIntegers().write(3, value); + } + + /** + * Retrieve On Ground. + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMoveLook.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMoveLook.java new file mode 100644 index 000000000..1627fe5ce --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRelEntityMoveLook.java @@ -0,0 +1,188 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerRelEntityMoveLook extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.REL_ENTITY_MOVE_LOOK; + + public WrapperPlayServerRelEntityMoveLook() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerRelEntityMoveLook(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve DX. + * + * @return The current DX + */ + public double getDx() { + return handle.getIntegers().read(1) / 4096D; + } + + /** + * Set DX. + * + * @param value - new value. + */ + public void setDx(double value) { + handle.getIntegers().write(1, (int) (value * 4096)); + } + + /** + * Retrieve DY. + * + * @return The current DY + */ + public double getDy() { + return handle.getIntegers().read(2) / 4096D; + } + + /** + * Set DY. + * + * @param value - new value. + */ + public void setDy(double value) { + handle.getIntegers().write(2, (int) (value * 4096)); + } + + /** + * Retrieve DZ. + * + * @return The current DZ + */ + public double getDz() { + return handle.getIntegers().read(3) / 4096D; + } + + /** + * Set DZ. + * + * @param value - new value. + */ + public void setDz(double value) { + handle.getIntegers().write(3, (int) (value * 4096)); + } + + /** + * Retrieve the yaw of the current entity. + * + * @return The current Yaw + */ + public float getYaw() { + return (handle.getBytes().read(0) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the current entity. + * + * @param value - new yaw. + */ + public void setYaw(float value) { + handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the pitch of the current entity. + * + * @return The current pitch + */ + public float getPitch() { + return (handle.getBytes().read(1) * 360.F) / 256.0F; + } + + /** + * Set the pitch of the current entity. + * + * @param value - new pitch. + */ + public void setPitch(float value) { + handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve On Ground. + * + * @return The current On Ground + */ + public boolean getOnGround() { + return handle.getBooleans().read(0); + } + + /** + * Set On Ground. + * + * @param value - new value. + */ + public void setOnGround(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRemoveEntityEffect.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRemoveEntityEffect.java new file mode 100644 index 000000000..a8765f9f6 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRemoveEntityEffect.java @@ -0,0 +1,89 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.potion.PotionEffectType; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerRemoveEntityEffect extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.REMOVE_ENTITY_EFFECT; + + public WrapperPlayServerRemoveEntityEffect() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerRemoveEntityEffect(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + public PotionEffectType getEffect() { + return handle.getEffectTypes().read(0); + } + + public void setEffect(PotionEffectType value) { + handle.getEffectTypes().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerResourcePackSend.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerResourcePackSend.java new file mode 100644 index 000000000..2d0a31416 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerResourcePackSend.java @@ -0,0 +1,81 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerResourcePackSend extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.RESOURCE_PACK_SEND; + + public WrapperPlayServerResourcePackSend() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerResourcePackSend(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve URL. + *

+ * Notes: the URL to the resource pack. + * + * @return The current URL + */ + public String getUrl() { + return handle.getStrings().read(0); + } + + /** + * Set URL. + * + * @param value - new value. + */ + public void setUrl(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Hash. + *

+ * Notes: a 40 character hexadecimal and lower-case SHA-1 hash of the + * resource pack file. (must be lower case in order to work) If it's not a + * 40 character hexadecimal string, the client will not use it for hash + * verification and likely waste bandwidth - but it will still treat it as a + * unique id + * + * @return The current Hash + */ + public String getHash() { + return handle.getStrings().read(1); + } + + /** + * Set Hash. + * + * @param value - new value. + */ + public void setHash(String value) { + handle.getStrings().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRespawn.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRespawn.java new file mode 100644 index 000000000..8500de97a --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerRespawn.java @@ -0,0 +1,121 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.WorldType; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty; +import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; + +public class WrapperPlayServerRespawn extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.RESPAWN; + + public WrapperPlayServerRespawn() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerRespawn(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Dimension. + *

+ * Notes: -1: The Nether, 0: The Overworld, 1: The End + * + * @return The current Dimension + */ + public int getDimension() { + return handle.getIntegers().read(0); + } + + /** + * Set Dimension. + * + * @param value - new value. + */ + public void setDimension(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Difficulty. + *

+ * Notes: 0 thru 3 for Peaceful, Easy, Normal, Hard. + * + * @return The current Difficulty + */ + public Difficulty getDifficulty() { + return handle.getDifficulties().read(0); + } + + /** + * Set Difficulty. + * + * @param value - new value. + */ + public void setDifficulty(Difficulty value) { + handle.getDifficulties().write(0, value); + } + + /** + * Retrieve Gamemode. + *

+ * Notes: 0: survival, 1: creative, 2: adventure. The hardcore flag is not + * included + * + * @return The current Gamemode + */ + public NativeGameMode getGamemode() { + return handle.getGameModes().read(0); + } + + /** + * Set Gamemode. + * + * @param value - new value. + */ + public void setGamemode(NativeGameMode value) { + handle.getGameModes().write(0, value); + } + + /** + * Retrieve Level Type. + *

+ * Notes: same as Join Game + * + * @return The current Level Type + */ + public WorldType getLevelType() { + return handle.getWorldTypeModifier().read(0); + } + + /** + * Set Level Type. + * + * @param value - new value. + */ + public void setLevelType(WorldType value) { + handle.getWorldTypeModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardDisplayObjective.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardDisplayObjective.java new file mode 100644 index 000000000..f21a2f3fc --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardDisplayObjective.java @@ -0,0 +1,78 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerScoreboardDisplayObjective extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE; + + public WrapperPlayServerScoreboardDisplayObjective() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerScoreboardDisplayObjective(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Position. + *

+ * Notes: the position of the scoreboard. 0 = list, 1 = sidebar, 2 = + * belowName. + * + * @return The current Position + */ + public int getPosition() { + return handle.getIntegers().read(0); + } + + /** + * Set Position. + * + * @param value - new value. + */ + public void setPosition(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Score Name. + *

+ * Notes: the unique name for the scoreboard to be displayed. + * + * @return The current Score Name + */ + public String getScoreName() { + return handle.getStrings().read(0); + } + + /** + * Set Score Name. + * + * @param value - new value. + */ + public void setScoreName(String value) { + handle.getStrings().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardObjective.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardObjective.java new file mode 100644 index 000000000..91521eade --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardObjective.java @@ -0,0 +1,141 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.IntEnum; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerScoreboardObjective extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SCOREBOARD_OBJECTIVE; + + public WrapperPlayServerScoreboardObjective() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerScoreboardObjective(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Enum containing all known packet modes. + * + * @author dmulloy2 + */ + public static class Mode extends IntEnum { + public static final int ADD_OBJECTIVE = 0; + public static final int REMOVE_OBJECTIVE = 1; + public static final int UPDATE_VALUE = 2; + + private static final Mode INSTANCE = new Mode(); + + public static Mode getInstance() { + return INSTANCE; + } + } + + /** + * Retrieve Objective name. + *

+ * Notes: an unique name for the objective + * + * @return The current Objective name + */ + public String getName() { + return handle.getStrings().read(0); + } + + /** + * Set Objective name. + * + * @param value - new value. + */ + public void setName(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Objective DisplayName. + *

+ * Notes: only if mode is 0 or 2. The text to be displayed for the score. + * + * @return The current Objective value + */ + public WrappedChatComponent getDisplayName() { + return handle.getChatComponents().read(0); + } + + /** + * Set Objective DisplayName. + * + * @param value - new value. + */ + public void setDisplayName(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + /** + * Retrieve health display. + *

+ * Notes: Can be either INTEGER or HEARTS + * + * @return the current health display value + */ + public HealthDisplay getHealthDisplay() { + return handle.getEnumModifier(HealthDisplay.class, 2).read(0); + } + + /** + * Set health display. + * + * @param value - value + * @see #getHealthDisplay() + */ + public void setHealthDisplay(HealthDisplay value) { + handle.getEnumModifier(HealthDisplay.class, 2).write(0, value); + } + + /** + * Retrieve Mode. + *

+ * Notes: 0 to create the scoreboard. 1 to remove the scoreboard. 2 to + * update the display text. + * + * @return The current Mode + */ + public int getMode() { + return handle.getIntegers().read(0); + } + + /** + * Set Mode. + * + * @param value - new value. + */ + public void setMode(int value) { + handle.getIntegers().write(0, value); + } + + public enum HealthDisplay { + INTEGER, HEARTS + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardScore.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardScore.java new file mode 100644 index 000000000..03f662ae0 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardScore.java @@ -0,0 +1,107 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.ScoreboardAction; + +public class WrapperPlayServerScoreboardScore extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SCOREBOARD_SCORE; + + public WrapperPlayServerScoreboardScore() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerScoreboardScore(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Score name. + *

+ * Notes: the name of the score to be updated or removed. + * + * @return The current Score name + */ + public String getScoreName() { + return handle.getStrings().read(0); + } + + /** + * Set Score name. + * + * @param value - new value. + */ + public void setScoreName(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Objective Name. + *

+ * Notes: the name of the objective the score belongs to. + * + * @return The current Objective Name + */ + public String getObjectiveName() { + return handle.getStrings().read(1); + } + + /** + * Set Objective Name. + * + * @param value - new value. + */ + public void setObjectiveName(String value) { + handle.getStrings().write(1, value); + } + + /** + * Retrieve Value. + *

+ * Notes: the score to be displayed next to the entry. Only sent when + * Update/Remove does not equal 1. + * + * @return The current Value + */ + public int getValue() { + return handle.getIntegers().read(0); + } + + /** + * Set Value. + * + * @param value - new value. + */ + public void setValue(int value) { + handle.getIntegers().write(0, value); + } + + public ScoreboardAction getAction() { + return handle.getScoreboardActions().read(0); + } + + public void setScoreboardAction(ScoreboardAction value) { + handle.getScoreboardActions().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardTeam.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardTeam.java new file mode 100644 index 000000000..3c5cb53b8 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerScoreboardTeam.java @@ -0,0 +1,279 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.Collection; +import java.util.List; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.IntEnum; +import com.comphenix.protocol.utility.MinecraftReflection; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +import org.bukkit.ChatColor; + +public class WrapperPlayServerScoreboardTeam extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SCOREBOARD_TEAM; + + public WrapperPlayServerScoreboardTeam() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerScoreboardTeam(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Enum containing all known modes. + * + * @author dmulloy2 + */ + public static class Mode extends IntEnum { + public static final int TEAM_CREATED = 0; + public static final int TEAM_REMOVED = 1; + public static final int TEAM_UPDATED = 2; + public static final int PLAYERS_ADDED = 3; + public static final int PLAYERS_REMOVED = 4; + + private static final Mode INSTANCE = new Mode(); + + public static Mode getInstance() { + return INSTANCE; + } + } + + /** + * Retrieve Team Name. + *

+ * Notes: a unique name for the team. (Shared with scoreboard). + * + * @return The current Team Name + */ + public String getName() { + return handle.getStrings().read(0); + } + + /** + * Set Team Name. + * + * @param value - new value. + */ + public void setName(String value) { + handle.getStrings().write(0, value); + } + + /** + * Retrieve Team Display Name. + *

+ * Notes: only if Mode = 0 or 2. + * + * @return The current Team Display Name + */ + public WrappedChatComponent getDisplayName() { + return handle.getChatComponents().read(0); + } + + /** + * Set Team Display Name. + * + * @param value - new value. + */ + public void setDisplayName(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + /** + * Retrieve Team Prefix. + *

+ * Notes: only if Mode = 0 or 2. Displayed before the players' name that are + * part of this team. + * + * @return The current Team Prefix + */ + public WrappedChatComponent getPrefix() { + return handle.getChatComponents().read(1); + } + + /** + * Set Team Prefix. + * + * @param value - new value. + */ + public void setPrefix(WrappedChatComponent value) { + handle.getChatComponents().write(1, value); + } + + /** + * Retrieve Team Suffix. + *

+ * Notes: only if Mode = 0 or 2. Displayed after the players' name that are + * part of this team. + * + * @return The current Team Suffix + */ + public WrappedChatComponent getSuffix() { + return handle.getChatComponents().read(2); + } + + /** + * Set Team Suffix. + * + * @param value - new value. + */ + public void setSuffix(WrappedChatComponent value) { + handle.getChatComponents().write(2, value); + } + + /** + * Retrieve Name Tag Visibility. + *

+ * Notes: only if Mode = 0 or 2. always, hideForOtherTeams, hideForOwnTeam, + * never. + * + * @return The current Name Tag Visibility + */ + public String getNameTagVisibility() { + return handle.getStrings().read(1); + } + + /** + * Set Name Tag Visibility. + * + * @param value - new value. + */ + public void setNameTagVisibility(String value) { + handle.getStrings().write(1, value); + } + + /** + * Retrieve Color. + *

+ * Notes: only if Mode = 0 or 2. Same as Chat colors. + * + * @return The current Color + */ + public ChatColor getColor() { + return handle.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).read(0); + } + + /** + * Set Color. + * + * @param value - new value. + */ + public void setColor(ChatColor value) { + handle.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, value); + } + + /** + * Get the collision rule. + * Notes: only if Mode = 0 or 2. always, pushOtherTeams, pushOwnTeam, never. + * @return The current collision rule + */ + public String getCollisionRule() { + return handle.getStrings().read(2); + } + + /** + * Sets the collision rule. + * @param value - new value. + */ + public void setCollisionRule(String value) { + handle.getStrings().write(2, value); + } + + /** + * Retrieve Players. + *

+ * Notes: only if Mode = 0 or 3 or 4. Players to be added/remove from the + * team. Max 40 characters so may be uuid's later + * + * @return The current Players + */ + @SuppressWarnings("unchecked") + public List getPlayers() { + return (List) handle.getSpecificModifier(Collection.class) + .read(0); + } + + /** + * Set Players. + * + * @param value - new value. + */ + public void setPlayers(List value) { + handle.getSpecificModifier(Collection.class).write(0, value); + } + + /** + * Retrieve Mode. + *

+ * Notes: if 0 then the team is created. If 1 then the team is removed. If 2 + * the team team information is updated. If 3 then new players are added to + * the team. If 4 then players are removed from the team. + * + * @return The current Mode + */ + public int getMode() { + return handle.getIntegers().read(0); + } + + /** + * Set Mode. + * + * @param value - new value. + */ + public void setMode(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve pack option data. Pack data is calculated as follows: + * + *

+	 * 
+	 * int data = 0;
+	 * if (team.allowFriendlyFire()) {
+	 *     data |= 1;
+	 * }
+	 * if (team.canSeeFriendlyInvisibles()) {
+	 *     data |= 2;
+	 * }
+	 * 
+	 * 
+ * + * @return The current pack option data + */ + public int getPackOptionData() { + return handle.getIntegers().read(1); + } + + /** + * Set pack option data. + * + * @param value - new value + * @see #getPackOptionData() + */ + public void setPackOptionData(int value) { + handle.getIntegers().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSelectAdvancementTab.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSelectAdvancementTab.java new file mode 100644 index 000000000..fb9631af9 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSelectAdvancementTab.java @@ -0,0 +1,45 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.MinecraftKey; + +public class WrapperPlayServerSelectAdvancementTab extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.SELECT_ADVANCEMENT_TAB; + + public WrapperPlayServerSelectAdvancementTab() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSelectAdvancementTab(PacketContainer packet) { + super(packet, TYPE); + } + + public MinecraftKey getKey() { + return handle.getMinecraftKeys().readSafely(0); + } + + public void setKey(MinecraftKey key) { + handle.getMinecraftKeys().writeSafely(0, key); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerServerDifficulty.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerServerDifficulty.java new file mode 100644 index 000000000..e5853edd0 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerServerDifficulty.java @@ -0,0 +1,58 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty; + +public class WrapperPlayServerServerDifficulty extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SERVER_DIFFICULTY; + + public WrapperPlayServerServerDifficulty() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerServerDifficulty(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Difficulty. + *

+ * Notes: 0:PEACEFUL, 1:EASY, 2:NORMAL, 3: HARD + * + * @return The current Difficulty + */ + public Difficulty getDifficulty() { + return handle.getDifficulties().read(0); + } + + /** + * Set Difficulty. + * + * @param value - new value. + */ + public void setDifficulty(Difficulty value) { + handle.getDifficulties().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetCooldown.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetCooldown.java new file mode 100644 index 000000000..b46a70ed2 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetCooldown.java @@ -0,0 +1,96 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.Material; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.EquivalentConverter; +import com.comphenix.protocol.reflect.accessors.Accessors; +import com.comphenix.protocol.reflect.accessors.MethodAccessor; +import com.comphenix.protocol.utility.MinecraftReflection; + +public class WrapperPlayServerSetCooldown extends AbstractPacket { + private static final Class ITEM_CLASS = MinecraftReflection + .getMinecraftClass("Item"); + public static final PacketType TYPE = PacketType.Play.Server.SET_COOLDOWN; + + public WrapperPlayServerSetCooldown() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSetCooldown(PacketContainer packet) { + super(packet, TYPE); + } + + public Material getItem() { + return handle.getModifier() + . withType(ITEM_CLASS, new ItemConverter()).read(0); + } + + public void setItem(Material value) { + handle.getModifier() + . withType(ITEM_CLASS, new ItemConverter()) + .write(0, value); + } + + public int getTicks() { + return handle.getIntegers().read(0); + } + + public void setTicks(int value) { + handle.getIntegers().write(0, value); + } + + private static class ItemConverter implements EquivalentConverter { + private static MethodAccessor getMaterial = null; + private static MethodAccessor getItem = null; + + @Override + public Material getSpecific(Object generic) { + if (getMaterial == null) { + getMaterial = + Accessors.getMethodAccessor(MinecraftReflection + .getCraftBukkitClass("util.CraftMagicNumbers"), + "getMaterial", ITEM_CLASS); + } + + return (Material) getMaterial.invoke(null, generic); + } + + @Override + public Object getGeneric(Material specific) { + if (getItem == null) { + getItem = + Accessors.getMethodAccessor(MinecraftReflection + .getCraftBukkitClass("util.CraftMagicNumbers"), + "getItem", Material.class); + } + + return getItem.invoke(null, specific); + } + + @Override + public Class getSpecificType() { + return Material.class; + } + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetSlot.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetSlot.java new file mode 100644 index 000000000..051ae9898 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSetSlot.java @@ -0,0 +1,101 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.inventory.ItemStack; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerSetSlot extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.SET_SLOT; + + public WrapperPlayServerSetSlot() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSetSlot(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the window which is being updated. 0 for player inventory. Note + * that all known window types include the player inventory. This packet + * will only be sent for the currently opened window while the player is + * performing actions, even if it affects the player inventory. After the + * window is closed, a number of these packets are sent to update the + * player's inventory window (0). + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Slot. + *

+ * Notes: the slot that should be updated + * + * @return The current Slot + */ + public int getSlot() { + return handle.getIntegers().read(1); + } + + /** + * Set Slot. + * + * @param value - new value. + */ + public void setSlot(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Slot data. + * + * @return The current Slot data + */ + public ItemStack getSlotData() { + return handle.getItemModifier().read(0); + } + + /** + * Set Slot data. + * + * @param value - new value. + */ + public void setSlotData(ItemStack value) { + handle.getItemModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java new file mode 100644 index 000000000..b66522e60 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java @@ -0,0 +1,378 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.UUID; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.injector.PacketConstructor; +import com.comphenix.protocol.reflect.IntEnum; + +public class WrapperPlayServerSpawnEntity extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.SPAWN_ENTITY; + + private static PacketConstructor entityConstructor; + + /** + * Represents the different object types. + * + * @author Kristian + */ + public static class ObjectTypes extends IntEnum { + public static final int BOAT = 1; + public static final int ITEM_STACK = 2; + public static final int AREA_EFFECT_CLOUD = 3; + public static final int MINECART = 10; + public static final int ACTIVATED_TNT = 50; + public static final int ENDER_CRYSTAL = 51; + public static final int TIPPED_ARROW_PROJECTILE = 60; + public static final int SNOWBALL_PROJECTILE = 61; + public static final int EGG_PROJECTILE = 62; + public static final int GHAST_FIREBALL = 63; + public static final int BLAZE_FIREBALL = 64; + public static final int THROWN_ENDERPEARL = 65; + public static final int WITHER_SKULL_PROJECTILE = 66; + public static final int SHULKER_BULLET = 67; + public static final int FALLING_BLOCK = 70; + public static final int ITEM_FRAME = 71; + public static final int EYE_OF_ENDER = 72; + public static final int THROWN_POTION = 73; + public static final int THROWN_EXP_BOTTLE = 75; + public static final int FIREWORK_ROCKET = 76; + public static final int LEASH_KNOT = 77; + public static final int ARMORSTAND = 78; + public static final int FISHING_FLOAT = 90; + public static final int SPECTRAL_ARROW = 91; + public static final int DRAGON_FIREBALL = 93; + + /** + * The singleton instance. Can also be retrieved from the parent class. + */ + private static ObjectTypes INSTANCE = new ObjectTypes(); + + /** + * Retrieve an instance of the object types enum. + * + * @return Object type enum. + */ + public static ObjectTypes getInstance() { + return INSTANCE; + } + } + + public WrapperPlayServerSpawnEntity() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSpawnEntity(PacketContainer packet) { + super(packet, TYPE); + } + + public WrapperPlayServerSpawnEntity(Entity entity, int type, int objectData) { + super(fromEntity(entity, type, objectData), TYPE); + } + + // Useful constructor + private static PacketContainer fromEntity(Entity entity, int type, + int objectData) { + if (entityConstructor == null) + entityConstructor = + ProtocolLibrary.getProtocolManager() + .createPacketConstructor(TYPE, entity, type, + objectData); + return entityConstructor.createPacket(entity, type, objectData); + } + + /** + * Retrieve entity ID of the Object. + * + * @return The current EID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Retrieve the entity that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Set entity ID of the Object. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + public UUID getUniqueId() { + return handle.getUUIDs().read(0); + } + + public void setUniqueId(UUID value) { + handle.getUUIDs().write(0, value); + } + + /** + * Retrieve the x position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set the x position of the object. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve the y position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set the y position of the object. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve the z position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set the z position of the object. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve the optional speed x. + *

+ * This is ignored if {@link #getObjectData()} is zero. + * + * @return The optional speed x. + */ + public double getOptionalSpeedX() { + return handle.getIntegers().read(1) / 8000.0D; + } + + /** + * Set the optional speed x. + * + * @param value - new value. + */ + public void setOptionalSpeedX(double value) { + handle.getIntegers().write(1, (int) (value * 8000.0D)); + } + + /** + * Retrieve the optional speed y. + *

+ * This is ignored if {@link #getObjectData()} is zero. + * + * @return The optional speed y. + */ + public double getOptionalSpeedY() { + return handle.getIntegers().read(2) / 8000.0D; + } + + /** + * Set the optional speed y. + * + * @param value - new value. + */ + public void setOptionalSpeedY(double value) { + handle.getIntegers().write(2, (int) (value * 8000.0D)); + } + + /** + * Retrieve the optional speed z. + *

+ * This is ignored if {@link #getObjectData()} is zero. + * + * @return The optional speed z. + */ + public double getOptionalSpeedZ() { + return handle.getIntegers().read(3) / 8000.0D; + } + + /** + * Set the optional speed z. + * + * @param value - new value. + */ + public void setOptionalSpeedZ(double value) { + handle.getIntegers().write(3, (int) (value * 8000.0D)); + } + + /** + * Retrieve the pitch. + * + * @return The current pitch. + */ + public float getPitch() { + return (handle.getIntegers().read(4) * 360.F) / 256.0F; + } + + /** + * Set the pitch. + * + * @param value - new pitch. + */ + public void setPitch(float value) { + handle.getIntegers().write(4, (int) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the yaw. + * + * @return The current Yaw + */ + public float getYaw() { + return (handle.getIntegers().read(5) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the object spawned. + * + * @param value - new yaw. + */ + public void setYaw(float value) { + handle.getIntegers().write(5, (int) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the type of object. See {@link ObjectTypes} + * + * @return The current Type + */ + public int getType() { + return handle.getIntegers().read(6); + } + + /** + * Set the type of object. See {@link ObjectTypes}. + * + * @param value - new value. + */ + public void setType(int value) { + handle.getIntegers().write(6, value); + } + + /** + * Retrieve object data. + *

+ * The content depends on the object type: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Object Type:Name:Description
ITEM_FRAMEOrientation0-3: South, West, North, East
FALLING_BLOCKBlock TypeBlockID | (Metadata << 0xC)
ProjectilesEntity IDThe entity ID of the thrower
Splash PotionsData ValuePotion data value.
+ * + * @return The current object Data + */ + public int getObjectData() { + return handle.getIntegers().read(7); + } + + /** + * Set object Data. + *

+ * The content depends on the object type. See {@link #getObjectData()} for + * more information. + * + * @param value - new object data. + */ + public void setObjectData(int value) { + handle.getIntegers().write(7, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityExperienceOrb.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityExperienceOrb.java new file mode 100644 index 000000000..2a314ea75 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityExperienceOrb.java @@ -0,0 +1,160 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerSpawnEntityExperienceOrb extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB; + + public WrapperPlayServerSpawnEntityExperienceOrb() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSpawnEntityExperienceOrb(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve the x position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set the x position of the object. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve the y position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set the y position of the object. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve the z position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set the z position of the object. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Count. + *

+ * Notes: the amount of experience this orb will reward once collected + * + * @return The current Count + */ + public int getCount() { + return handle.getIntegers().read(1); + } + + /** + * Set Count. + * + * @param value - new value. + */ + public void setCount(int value) { + handle.getIntegers().write(1, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityLiving.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityLiving.java new file mode 100644 index 000000000..3c2aad945 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityLiving.java @@ -0,0 +1,315 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.UUID; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.injector.PacketConstructor; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; + +public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SPAWN_ENTITY_LIVING; + + private static PacketConstructor entityConstructor; + + public WrapperPlayServerSpawnEntityLiving() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSpawnEntityLiving(PacketContainer packet) { + super(packet, TYPE); + } + + public WrapperPlayServerSpawnEntityLiving(Entity entity) { + super(fromEntity(entity), TYPE); + } + + // Useful constructor + private static PacketContainer fromEntity(Entity entity) { + if (entityConstructor == null) + entityConstructor = + ProtocolLibrary.getProtocolManager() + .createPacketConstructor(TYPE, entity); + return entityConstructor.createPacket(entity); + } + + /** + * Retrieve entity ID. + * + * @return The current EID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Retrieve the entity that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + public UUID getUniqueId() { + return handle.getUUIDs().read(0); + } + + public void setUniqueId(UUID value) { + handle.getUUIDs().write(0, value); + } + + /** + * Set entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the type of mob. + * + * @return The current Type + */ + @SuppressWarnings("deprecation") + public EntityType getType() { + return EntityType.fromId(handle.getIntegers().read(1)); + } + + /** + * Set the type of mob. + * + * @param value - new value. + */ + @SuppressWarnings("deprecation") + public void setType(EntityType value) { + handle.getIntegers().write(1, (int) value.getTypeId()); + } + + /** + * Retrieve the x position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set the x position of the object. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve the y position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set the y position of the object. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve the z position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set the z position of the object. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve the yaw. + * + * @return The current Yaw + */ + public float getYaw() { + return (handle.getBytes().read(0) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the spawned mob. + * + * @param value - new yaw. + */ + public void setYaw(float value) { + handle.getBytes().write(0, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the pitch. + * + * @return The current pitch + */ + public float getPitch() { + return (handle.getBytes().read(1) * 360.F) / 256.0F; + } + + /** + * Set the pitch of the spawned mob. + * + * @param value - new pitch. + */ + public void setPitch(float value) { + handle.getBytes().write(1, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the yaw of the mob's head. + * + * @return The current yaw. + */ + public float getHeadPitch() { + return (handle.getBytes().read(2) * 360.F) / 256.0F; + } + + /** + * Set the yaw of the mob's head. + * + * @param value - new yaw. + */ + public void setHeadPitch(float value) { + handle.getBytes().write(2, (byte) (value * 256.0F / 360.0F)); + } + + /** + * Retrieve the velocity in the x axis. + * + * @return The current velocity X + */ + public double getVelocityX() { + return handle.getIntegers().read(2) / 8000.0D; + } + + /** + * Set the velocity in the x axis. + * + * @param value - new value. + */ + public void setVelocityX(double value) { + handle.getIntegers().write(2, (int) (value * 8000.0D)); + } + + /** + * Retrieve the velocity in the y axis. + * + * @return The current velocity y + */ + public double getVelocityY() { + return handle.getIntegers().read(3) / 8000.0D; + } + + /** + * Set the velocity in the y axis. + * + * @param value - new value. + */ + public void setVelocityY(double value) { + handle.getIntegers().write(3, (int) (value * 8000.0D)); + } + + /** + * Retrieve the velocity in the z axis. + * + * @return The current velocity z + */ + public double getVelocityZ() { + return handle.getIntegers().read(4) / 8000.0D; + } + + /** + * Set the velocity in the z axis. + * + * @param value - new value. + */ + public void setVelocityZ(double value) { + handle.getIntegers().write(4, (int) (value * 8000.0D)); + } + + /** + * Retrieve the data watcher. + *

+ * Content varies by mob, see Entities. + * + * @return The current Metadata + */ + public WrappedDataWatcher getMetadata() { + return handle.getDataWatcherModifier().read(0); + } + + /** + * Set the data watcher. + * + * @param value - new value. + */ + public void setMetadata(WrappedDataWatcher value) { + handle.getDataWatcherModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityPainting.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityPainting.java new file mode 100644 index 000000000..10e2a9b6d --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityPainting.java @@ -0,0 +1,118 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.comphenix.protocol.wrappers.EnumWrappers.Direction; + +public class WrapperPlayServerSpawnEntityPainting extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SPAWN_ENTITY_PAINTING; + + public WrapperPlayServerSpawnEntityPainting() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSpawnEntityPainting(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Location. + *

+ * Notes: center coordinates + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + public Direction getDirection() { + return handle.getDirections().read(0); + } + + public void setDirection(Direction value) { + handle.getDirections().write(0, value); + } + + public int getPaintingId() { + return handle.getIntegers().read(0); + } + + public void setPaintingId(int value) { + handle.getIntegers().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityWeather.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityWeather.java new file mode 100644 index 000000000..c84817aeb --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityWeather.java @@ -0,0 +1,160 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; + +public class WrapperPlayServerSpawnEntityWeather extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.SPAWN_ENTITY_WEATHER; + + public WrapperPlayServerSpawnEntityWeather() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSpawnEntityWeather(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve Type. + *

+ * Notes: the global entity type, currently always 1 for thunderbolt. + * + * @return The current Type + */ + public int getType() { + return handle.getIntegers().read(1); + } + + /** + * Set Type. + * + * @param value - new value. + */ + public void setType(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve the x position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set the x position of the object. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve the y position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set the y position of the object. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve the z position of the object. + *

+ * Note that the coordinate is rounded off to the nearest 1/32 of a meter. + * + * @return The current z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set the z position of the object. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnPosition.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnPosition.java new file mode 100644 index 000000000..7b23e269e --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnPosition.java @@ -0,0 +1,57 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerSpawnPosition extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.SPAWN_POSITION; + + public WrapperPlayServerSpawnPosition() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerSpawnPosition(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + *

+ * Notes: spawn location + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStatistic.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStatistic.java new file mode 100644 index 000000000..31ba2a43f --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStatistic.java @@ -0,0 +1,37 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerStatistic extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.STATISTIC; + + public WrapperPlayServerStatistic() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerStatistic(PacketContainer packet) { + super(packet, TYPE); + } + + // TODO fix upon request +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStopSound.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStopSound.java new file mode 100644 index 000000000..1244dcc15 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerStopSound.java @@ -0,0 +1,54 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers; +import com.comphenix.protocol.wrappers.MinecraftKey; + +public class WrapperPlayServerStopSound extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.STOP_SOUND; + + public WrapperPlayServerStopSound() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerStopSound(PacketContainer packet) { + super(packet, TYPE); + } + + public MinecraftKey getSoundEffect() { + return handle.getMinecraftKeys().readSafely(0); + } + + public void setSoundEffect(MinecraftKey value) { + handle.getMinecraftKeys().writeSafely(0, value); + } + + public EnumWrappers.SoundCategory getCategory() { + return handle.getSoundCategories().readSafely(0); + } + + public void setCategory(EnumWrappers.SoundCategory value) { + handle.getSoundCategories().writeSafely(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTabComplete.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTabComplete.java new file mode 100644 index 000000000..d0b2729f7 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTabComplete.java @@ -0,0 +1,53 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.mojang.brigadier.suggestion.Suggestions; + +public class WrapperPlayServerTabComplete extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.TAB_COMPLETE; + + public WrapperPlayServerTabComplete() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerTabComplete(PacketContainer packet) { + super(packet, TYPE); + } + + public int getTransactionId() { + return handle.getIntegers().read(0); + } + + public void setTransactionId(int value) { + handle.getIntegers().write(0, value); + } + + public Suggestions getSuggestions() { + return handle.getSpecificModifier(Suggestions.class).read(0); + } + + public void setSuggestions(Suggestions value) { + handle.getSpecificModifier(Suggestions.class).write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTags.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTags.java new file mode 100644 index 000000000..5cc50f580 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTags.java @@ -0,0 +1,40 @@ +/** + * This file is part of PacketWrapper. + * Copyright (C) 2012-2015 Kristian S. Strangeland + * Copyright (C) 2015 dmulloy2 + * + * PacketWrapper is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PacketWrapper is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with PacketWrapper. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerTags extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.TAGS; + + public WrapperPlayServerTags() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerTags(PacketContainer packet) { + super(packet, TYPE); + } + + // Cannot find type for a + // Cannot find type for a + // Cannot find type for a +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTileEntityData.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTileEntityData.java new file mode 100644 index 000000000..a4b308d68 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTileEntityData.java @@ -0,0 +1,97 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; +import com.comphenix.protocol.wrappers.nbt.NbtBase; + +public class WrapperPlayServerTileEntityData extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.TILE_ENTITY_DATA; + + public WrapperPlayServerTileEntityData() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerTileEntityData(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Location. + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + /** + * Retrieve Action. + *

+ * Notes: the type of update to perform + * + * @return The current Action + */ + public int getAction() { + return handle.getIntegers().read(0); + } + + /** + * Set Action. + * + * @param value - new value. + */ + public void setAction(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve NBT Data. + *

+ * Notes: if not present then its TAG_END (0) + * + * @return The current NBT Data + */ + public NbtBase getNbtData() { + return handle.getNbtModifier().read(0); + } + + /** + * Set NBT Data. + * + * @param value - new value. + */ + public void setNbtData(NbtBase value) { + handle.getNbtModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTitle.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTitle.java new file mode 100644 index 000000000..453d12ee7 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTitle.java @@ -0,0 +1,131 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +public class WrapperPlayServerTitle extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.TITLE; + + public WrapperPlayServerTitle() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerTitle(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Action. + * + * @return The current Action + */ + public TitleAction getAction() { + return handle.getTitleActions().read(0); + } + + /** + * Set Action. + * + * @param value - new value. + */ + public void setAction(TitleAction value) { + handle.getTitleActions().write(0, value); + } + + /** + * Retrieve 0 (TITLE). + *

+ * Notes: chat + * + * @return The current 0 (TITLE) + */ + public WrappedChatComponent getTitle() { + return handle.getChatComponents().read(0); + } + + /** + * Set 0 (TITLE). + * + * @param value - new value. + */ + public void setTitle(WrappedChatComponent value) { + handle.getChatComponents().write(0, value); + } + + /** + * Retrieve 2 (TIMES). + *

+ * Notes: int + * + * @return The current 2 (TIMES) + */ + public int getFadeIn() { + return handle.getIntegers().read(0); + } + + /** + * Set 2 (TIMES). + * + * @param value - new value. + */ + public void setFadeIn(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Stay. + * + * @return The current Stay + */ + public int getStay() { + return handle.getIntegers().read(1); + } + + /** + * Set Stay. + * + * @param value - new value. + */ + public void setStay(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Fade Out. + * + * @return The current Fade Out + */ + public int getFadeOut() { + return handle.getIntegers().read(2); + } + + /** + * Set Fade Out. + * + * @param value - new value. + */ + public void setFadeOut(int value) { + handle.getIntegers().write(2, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTransaction.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTransaction.java new file mode 100644 index 000000000..68dcc5e60 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerTransaction.java @@ -0,0 +1,97 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerTransaction extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.TRANSACTION; + + public WrapperPlayServerTransaction() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerTransaction(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the id of the window that the action occurred in. + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Action number. + *

+ * Notes: every action that is to be accepted has a unique number. This + * field corresponds to that number. + * + * @return The current Action number + */ + public short getActionNumber() { + return handle.getShorts().read(0); + } + + /** + * Set Action number. + * + * @param value - new value. + */ + public void setActionNumber(short value) { + handle.getShorts().write(0, value); + } + + /** + * Retrieve Accepted. + *

+ * Notes: whether the action was accepted. + * + * @return The current Accepted + */ + public boolean getAccepted() { + return handle.getBooleans().read(0); + } + + /** + * Set Accepted. + * + * @param value - new value. + */ + public void setAccepted(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUnloadChunk.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUnloadChunk.java new file mode 100644 index 000000000..17d6fc3bd --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUnloadChunk.java @@ -0,0 +1,77 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerUnloadChunk extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.UNLOAD_CHUNK; + + public WrapperPlayServerUnloadChunk() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerUnloadChunk(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Chunk X. + *

+ * Notes: block coordinate divided by 16, rounded down + * + * @return The current Chunk X + */ + public int getChunkX() { + return handle.getIntegers().read(0); + } + + /** + * Set Chunk X. + * + * @param value - new value. + */ + public void setChunkX(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Chunk Z. + *

+ * Notes: block coordinate divided by 16, rounded down + * + * @return The current Chunk Z + */ + public int getChunkZ() { + return handle.getIntegers().read(1); + } + + /** + * Set Chunk Z. + * + * @param value - new value. + */ + public void setChunkZ(int value) { + handle.getIntegers().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateAttributes.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateAttributes.java new file mode 100644 index 000000000..b82cec29a --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateAttributes.java @@ -0,0 +1,101 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.List; + +import org.bukkit.World; +import org.bukkit.entity.Entity; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.wrappers.WrappedAttribute; + +public class WrapperPlayServerUpdateAttributes extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.UPDATE_ATTRIBUTES; + + public WrapperPlayServerUpdateAttributes() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerUpdateAttributes(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Entity ID. + *

+ * Notes: entity's ID + * + * @return The current Entity ID + */ + public int getEntityID() { + return handle.getIntegers().read(0); + } + + /** + * Set Entity ID. + * + * @param value - new value. + */ + public void setEntityID(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param world - the current world of the entity. + * @return The spawned entity. + */ + public Entity getEntity(World world) { + return handle.getEntityModifier(world).read(0); + } + + /** + * Retrieve the entity of the painting that will be spawned. + * + * @param event - the packet event. + * @return The spawned entity. + */ + public Entity getEntity(PacketEvent event) { + return getEntity(event.getPlayer().getWorld()); + } + + /** + * Retrieve the collection of attributes associated with the entity. + * + * @return The current attributes. + */ + public List getAttributes() { + return handle.getAttributeCollectionModifier().read(0); + } + + /** + * Set the new or updated attributes associated with the entity. + * + * @param value - new/updated attributes. + */ + public void setAttributes(List value) { + handle.getAttributeCollectionModifier().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateHealth.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateHealth.java new file mode 100644 index 000000000..7e8a01868 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateHealth.java @@ -0,0 +1,96 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerUpdateHealth extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.UPDATE_HEALTH; + + public WrapperPlayServerUpdateHealth() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerUpdateHealth(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Health. + *

+ * Notes: 0 or less = dead, 20 = full HP + * + * @return The current Health + */ + public float getHealth() { + return handle.getFloat().read(0); + } + + /** + * Set Health. + * + * @param value - new value. + */ + public void setHealth(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Food. + *

+ * Notes: 0 - 20 + * + * @return The current Food + */ + public int getFood() { + return handle.getIntegers().read(0); + } + + /** + * Set Food. + * + * @param value - new value. + */ + public void setFood(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Food Saturation. + *

+ * Notes: seems to vary from 0.0 to 5.0 in integer increments + * + * @return The current Food Saturation + */ + public float getFoodSaturation() { + return handle.getFloat().read(1); + } + + /** + * Set Food Saturation. + * + * @param value - new value. + */ + public void setFoodSaturation(float value) { + handle.getFloat().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateTime.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateTime.java new file mode 100644 index 000000000..85fbb1962 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerUpdateTime.java @@ -0,0 +1,77 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerUpdateTime extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.UPDATE_TIME; + + public WrapperPlayServerUpdateTime() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerUpdateTime(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Age of the world. + *

+ * Notes: in ticks; not changed by server commands + * + * @return The current Age of the world + */ + public long getAgeOfTheWorld() { + return handle.getLongs().read(0); + } + + /** + * Set Age of the world. + * + * @param value - new value. + */ + public void setAgeOfTheWorld(long value) { + handle.getLongs().write(0, value); + } + + /** + * Retrieve Time of day. + *

+ * Notes: the world (or region) time, in ticks. If negative the sun will + * stop moving at the Math.abs of the time + * + * @return The current Time of day + */ + public long getTimeOfDay() { + return handle.getLongs().read(1); + } + + /** + * Set Time of day. + * + * @param value - new value. + */ + public void setTimeOfDay(long value) { + handle.getLongs().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerVehicleMove.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerVehicleMove.java new file mode 100644 index 000000000..f4a0619cf --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerVehicleMove.java @@ -0,0 +1,137 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerVehicleMove extends AbstractPacket { + + public static final PacketType TYPE = PacketType.Play.Server.VEHICLE_MOVE; + + public WrapperPlayServerVehicleMove() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerVehicleMove(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve X. + *

+ * Notes: absolute position (X coordinate) + * + * @return The current X + */ + public double getX() { + return handle.getDoubles().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(double value) { + handle.getDoubles().write(0, value); + } + + /** + * Retrieve Y. + *

+ * Notes: absolute position (Y coordinate) + * + * @return The current Y + */ + public double getY() { + return handle.getDoubles().read(1); + } + + /** + * Set Y. + * + * @param value - new value. + */ + public void setY(double value) { + handle.getDoubles().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: absolute position (Z coordinate) + * + * @return The current Z + */ + public double getZ() { + return handle.getDoubles().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(double value) { + handle.getDoubles().write(2, value); + } + + /** + * Retrieve Yaw. + *

+ * Notes: absolute rotation on the vertical axis, in degrees + * + * @return The current Yaw + */ + public float getYaw() { + return handle.getFloat().read(0); + } + + /** + * Set Yaw. + * + * @param value - new value. + */ + public void setYaw(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Pitch. + *

+ * Notes: absolute rotation on the horizontal axis, in degrees + * + * @return The current Pitch + */ + public float getPitch() { + return handle.getFloat().read(1); + } + + /** + * Set Pitch. + * + * @param value - new value. + */ + public void setPitch(float value) { + handle.getFloat().write(1, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowData.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowData.java new file mode 100644 index 000000000..389ddd8be --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowData.java @@ -0,0 +1,96 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerWindowData extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.WINDOW_DATA; + + public WrapperPlayServerWindowData() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerWindowData(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the id of the window. + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Property. + *

+ * Notes: which property should be updated. + * + * @return The current Property + */ + public int getProperty() { + return handle.getIntegers().read(1); + } + + /** + * Set Property. + * + * @param value - new value. + */ + public void setProperty(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Value. + *

+ * Notes: the new value for the property. + * + * @return The current Value + */ + public int getValue() { + return handle.getIntegers().read(2); + } + + /** + * Set Value. + * + * @param value - new value. + */ + public void setValue(int value) { + handle.getIntegers().write(2, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowItems.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowItems.java new file mode 100644 index 000000000..986ae0e15 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWindowItems.java @@ -0,0 +1,79 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import java.util.List; + +import org.bukkit.inventory.ItemStack; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperPlayServerWindowItems extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.WINDOW_ITEMS; + + public WrapperPlayServerWindowItems() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerWindowItems(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Window ID. + *

+ * Notes: the id of window which items are being sent for. 0 for player + * inventory. + * + * @return The current Window ID + */ + public int getWindowId() { + return handle.getIntegers().read(0); + } + + /** + * Set Window ID. + * + * @param value - new value. + */ + public void setWindowId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Slot data. + * + * @return The current Slot data + */ + public List getSlotData() { + return handle.getItemListModifier().read(0); + } + + /** + * Set Slot data. + * + * @param value - new value. + */ + public void setSlotData(List value) { + handle.getItemListModifier().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldBorder.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldBorder.java new file mode 100644 index 000000000..bdefcdd8b --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldBorder.java @@ -0,0 +1,108 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.WorldBorderAction; + +public class WrapperPlayServerWorldBorder extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.WORLD_BORDER; + + public WrapperPlayServerWorldBorder() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerWorldBorder(PacketContainer packet) { + super(packet, TYPE); + } + + public WorldBorderAction getAction() { + return handle.getWorldBorderActions().read(0); + } + + public void setAction(WorldBorderAction value) { + handle.getWorldBorderActions().write(0, value); + } + + public int getPortalTeleportBoundary() { + return handle.getIntegers().read(0); + } + + public void setPortalTeleportBoundary(int value) { + handle.getIntegers().write(0, value); + } + + public double getCenterX() { + return handle.getDoubles().read(0); + } + + public void setCenterX(double value) { + handle.getDoubles().write(0, value); + } + + public double getCenterZ() { + return handle.getDoubles().read(1); + } + + public void setCenterZ(double value) { + handle.getDoubles().write(1, value); + } + + public double getOldRadius() { + return handle.getDoubles().read(2); + } + + public void setOldRadius(double value) { + handle.getDoubles().write(2, value); + } + + public double getRadius() { + return handle.getDoubles().read(3); + } + + public void setRadius(double value) { + handle.getDoubles().write(3, value); + } + + public long getSpeed() { + return handle.getLongs().read(0); + } + + public void setSpeed(long value) { + handle.getLongs().write(0, value); + } + + public int getWarningTime() { + return handle.getIntegers().read(1); + } + + public void setWarningTime(int value) { + handle.getIntegers().write(1, value); + } + + public int getWarningDistance() { + return handle.getIntegers().read(2); + } + + public void setWarningDistance(int value) { + handle.getIntegers().write(2, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldEvent.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldEvent.java new file mode 100644 index 000000000..5dfe08668 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldEvent.java @@ -0,0 +1,117 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.BlockPosition; + +public class WrapperPlayServerWorldEvent extends AbstractPacket { + public static final PacketType TYPE = PacketType.Play.Server.WORLD_EVENT; + + public WrapperPlayServerWorldEvent() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerWorldEvent(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Effect ID. + *

+ * Notes: the ID of the effect, see below. + * + * @return The current Effect ID + */ + public int getEffectId() { + return handle.getIntegers().read(0); + } + + /** + * Set Effect ID. + * + * @param value - new value. + */ + public void setEffectId(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Location. + *

+ * Notes: the location of the effect + * + * @return The current Location + */ + public BlockPosition getLocation() { + return handle.getBlockPositionModifier().read(0); + } + + /** + * Set Location. + * + * @param value - new value. + */ + public void setLocation(BlockPosition value) { + handle.getBlockPositionModifier().write(0, value); + } + + /** + * Retrieve Data. + *

+ * Notes: extra data for certain effects, see below. + * + * @return The current Data + */ + public int getData() { + return handle.getIntegers().read(1); + } + + /** + * Set Data. + * + * @param value - new value. + */ + public void setData(int value) { + handle.getIntegers().write(1, value); + } + + /** + * Retrieve Disable relative volume. + *

+ * Notes: see above + * + * @return The current Disable relative volume + */ + public boolean getDisableRelativeVolume() { + return handle.getBooleans().read(0); + } + + /** + * Set Disable relative volume. + * + * @param value - new value. + */ + public void setDisableRelativeVolume(boolean value) { + handle.getBooleans().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles.java b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles.java new file mode 100644 index 000000000..3232c8bbb --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerWorldParticles.java @@ -0,0 +1,238 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedParticle; + +public class WrapperPlayServerWorldParticles extends AbstractPacket { + public static final PacketType TYPE = + PacketType.Play.Server.WORLD_PARTICLES; + + public WrapperPlayServerWorldParticles() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperPlayServerWorldParticles(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve the particle. + * + * @return The current particle + */ + public WrappedParticle getParticle() { + return handle.getNewParticles().read(0); + } + + /** + * Set the particle. + * + * @param value - new value. + */ + public void setParticleType(WrappedParticle value) { + handle.getNewParticles().write(0, value); + } + + /** + * Retrieve X. + *

+ * Notes: x position of the particle + * + * @return The current X + */ + public float getX() { + return handle.getFloat().read(0); + } + + /** + * Set X. + * + * @param value - new value. + */ + public void setX(float value) { + handle.getFloat().write(0, value); + } + + /** + * Retrieve Y. + *

+ * Notes: y position of the particle + * + * @return The current Y + */ + public float getY() { + return handle.getFloat().read(1); + } + + /** + * Set Y. + * + * @param value - new value. + */ + public void setY(float value) { + handle.getFloat().write(1, value); + } + + /** + * Retrieve Z. + *

+ * Notes: z position of the particle + * + * @return The current Z + */ + public float getZ() { + return handle.getFloat().read(2); + } + + /** + * Set Z. + * + * @param value - new value. + */ + public void setZ(float value) { + handle.getFloat().write(2, value); + } + + /** + * Retrieve Offset X. + *

+ * Notes: this is added to the X position after being multiplied by + * random.nextGaussian() + * + * @return The current Offset X + */ + public float getOffsetX() { + return handle.getFloat().read(3); + } + + /** + * Set Offset X. + * + * @param value - new value. + */ + public void setOffsetX(float value) { + handle.getFloat().write(3, value); + } + + /** + * Retrieve Offset Y. + *

+ * Notes: this is added to the Y position after being multiplied by + * random.nextGaussian() + * + * @return The current Offset Y + */ + public float getOffsetY() { + return handle.getFloat().read(4); + } + + /** + * Set Offset Y. + * + * @param value - new value. + */ + public void setOffsetY(float value) { + handle.getFloat().write(4, value); + } + + /** + * Retrieve Offset Z. + *

+ * Notes: this is added to the Z position after being multiplied by + * random.nextGaussian() + * + * @return The current Offset Z + */ + public float getOffsetZ() { + return handle.getFloat().read(5); + } + + /** + * Set Offset Z. + * + * @param value - new value. + */ + public void setOffsetZ(float value) { + handle.getFloat().write(5, value); + } + + /** + * Retrieve Particle data. + *

+ * Notes: the data of each particle + * + * @return The current Particle data + */ + public float getParticleData() { + return handle.getFloat().read(6); + } + + /** + * Set Particle data. + * + * @param value - new value. + */ + public void setParticleData(float value) { + handle.getFloat().write(6, value); + } + + /** + * Retrieve Number of particles. + *

+ * Notes: the number of particles to create + * + * @return The current Number of particles + */ + public int getNumberOfParticles() { + return handle.getIntegers().read(0); + } + + /** + * Set Number of particles. + * + * @param value - new value. + */ + public void setNumberOfParticles(int value) { + handle.getIntegers().write(0, value); + } + + /** + * Retrieve Long Distance. + *

+ * Notes: if true, particle distance increases from 256 to 65536. + * + * @return The current Long Distance + */ + public boolean getLongDistance() { + return handle.getBooleans().read(0); + } + + /** + * Set Long Distance. + * + * @param value - new value. + */ + public void setLongDistance(boolean value) { + handle.getBooleans().write(0, value); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientPing.java b/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientPing.java new file mode 100644 index 000000000..6468a04db --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientPing.java @@ -0,0 +1,54 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperStatusClientPing extends AbstractPacket { + public static final PacketType TYPE = PacketType.Status.Client.PING; + + public WrapperStatusClientPing() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperStatusClientPing(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Time. + * + * @return The current Time + */ + public long getTime() { + return handle.getLongs().read(0); + } + + /** + * Set Time. + * + * @param value - new value. + */ + public void setTime(long value) { + handle.getLongs().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientStart.java b/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientStart.java new file mode 100644 index 000000000..4c320b9c6 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperStatusClientStart.java @@ -0,0 +1,35 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperStatusClientStart extends AbstractPacket { + public static final PacketType TYPE = PacketType.Status.Client.START; + + public WrapperStatusClientStart() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperStatusClientStart(PacketContainer packet) { + super(packet, TYPE); + } +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerPong.java b/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerPong.java new file mode 100644 index 000000000..bdf6909f5 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerPong.java @@ -0,0 +1,56 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; + +public class WrapperStatusServerPong extends AbstractPacket { + public static final PacketType TYPE = PacketType.Status.Server.PONG; + + public WrapperStatusServerPong() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperStatusServerPong(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve Time. + *

+ * Notes: should be the same as sent by the client + * + * @return The current Time + */ + public long getTime() { + return handle.getLongs().read(0); + } + + /** + * Set Time. + * + * @param value - new value. + */ + public void setTime(long value) { + handle.getLongs().write(0, value); + } + +} diff --git a/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerServerInfo.java b/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerServerInfo.java new file mode 100644 index 000000000..852421089 --- /dev/null +++ b/src/main/java/com/comphenix/packetwrapper/WrapperStatusServerServerInfo.java @@ -0,0 +1,57 @@ +/** + * PacketWrapper - ProtocolLib wrappers for Minecraft packets + * Copyright (C) dmulloy2 + * Copyright (C) Kristian S. Strangeland + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.comphenix.packetwrapper; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedServerPing; + +public class WrapperStatusServerServerInfo extends AbstractPacket { + public static final PacketType TYPE = PacketType.Status.Server.SERVER_INFO; + + public WrapperStatusServerServerInfo() { + super(new PacketContainer(TYPE), TYPE); + handle.getModifier().writeDefaults(); + } + + public WrapperStatusServerServerInfo(PacketContainer packet) { + super(packet, TYPE); + } + + /** + * Retrieve JSON Response. + *

+ * Notes: https://gist.github.com/thinkofdeath/6927216 + * + * @return The current JSON Response + */ + public WrappedServerPing getJsonResponse() { + return handle.getServerPings().read(0); + } + + /** + * Set JSON Response. + * + * @param value - new value. + */ + public void setJsonResponse(WrappedServerPing value) { + handle.getServerPings().write(0, value); + } + +} diff --git a/src/main/java/org/maxgamer/quickshop/Command/QS.java b/src/main/java/org/maxgamer/quickshop/Command/QS.java index 1ead78ca2..ddc11c88f 100644 --- a/src/main/java/org/maxgamer/quickshop/Command/QS.java +++ b/src/main/java/org/maxgamer/quickshop/Command/QS.java @@ -24,6 +24,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.BlockIterator; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.Database.Database; @@ -49,22 +50,30 @@ public class QS implements CommandExecutor { } public void signGUIApi(ArrayList data, String arg) { - Shop shop = (Shop) data.get(0); - String type = (String) data.get(1); - Player player = Bukkit.getPlayer(UUID.fromString(String.valueOf(data.get(2)))); - Util.debugLog(String.valueOf(data.size())); - switch (type) { - case "owner": - uiOwner(shop, arg, player); - break; - case "refill": - uiRefill(shop, arg, player); - break; - case "price": - uiPrice(shop, arg, player); - default: - break; - } + new BukkitRunnable() { + + @Override + public void run() { + Shop shop = (Shop) data.get(0); + String type = (String) data.get(1); + Player player = Bukkit.getPlayer(UUID.fromString(String.valueOf(data.get(2)))); + Util.debugLog(String.valueOf(data.size())); + switch (type) { + case "owner": + uiOwner(shop, arg, player); + break; + case "refill": + uiRefill(shop, arg, player); + break; + case "price": + uiPrice(shop, arg, player); + default: + break; + } + + } + }; + } private void uiPrice(Shop shop, String arg, Player sender) { @@ -250,7 +259,10 @@ public class QS implements CommandExecutor { data.add(type); data.add(((Player) sender).getUniqueId()); signPlayerCache.put(((Player) sender).getUniqueId(), data); + try { Util.sendSignEditForGUI((Player) sender, texts); + }catch (Exception e) { + } } private void remove(CommandSender sender, String[] args) { diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index aa5666171..7e9f901ab 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -185,7 +185,7 @@ public class Util { return null; } - public static void sendSignEditForGUI(Player player, String[] lines) { + public static void sendSignEditForGUI(Player player, String[] lines) throws InvocationTargetException { debugLog("SignEdit"); ProtocolManager manager = plugin.getProtocolLib(); BlockPosition position = new BlockPosition(player.getLocation().getBlockX(), 255, @@ -200,14 +200,9 @@ public class Util { PacketContainer open = manager.createPacket(PacketType.Play.Server.OPEN_SIGN_ENTITY); open.getBlockPositionModifier().write(0, position); - try { manager.sendServerPacket(player, blockChange); manager.sendServerPacket(player, updateSign); manager.sendServerPacket(player, open); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } }