/* * PacketWrapper - Contains wrappers for each packet in Minecraft. * Copyright (C) 2012 Kristian S. Stangeland * * This program 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA */ package org.royaldev.royalcommands.protocol.packets; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import org.bukkit.inventory.ItemStack; public class WrapperPlayServerSetSlot extends AbstractPacket { public static final PacketType TYPE = PacketType.Play.Server.SET_SLOT; public WrapperPlayServerSetSlot() { super(new PacketContainer(WrapperPlayServerSetSlot.TYPE), WrapperPlayServerSetSlot.TYPE); this.handle.getModifier().writeDefaults(); } public WrapperPlayServerSetSlot(PacketContainer packet) { super(packet, WrapperPlayServerSetSlot.TYPE); } /** * Retrieve the index of the slot that should be changed. * * @return The current slot */ public short getSlot() { return this.handle.getIntegers().read(1).shortValue(); } /** * Set the index of the slot that should be changed. * * @param value - new value. */ public void setSlot(short value) { this.handle.getIntegers().write(1, (int) value); } /** * Retrieve the new updated item stack. * * @return The current Slot data */ public ItemStack getSlotData() { return this.handle.getItemModifier().read(0); } /** * Set the new item stack. * * @param value - new value. */ public void setSlotData(ItemStack value) { this.handle.getItemModifier().write(0, value); } /** * Retrieve the window which is being updated. * <p/> * Use 0 for 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. * * @return The current Window id */ public byte getWindowId() { return this.handle.getIntegers().read(0).byteValue(); } /** * Set the window which is being updated. * <p/> * Use 0 for 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. * * @param value - new value. */ public void setWindowId(byte value) { this.handle.getIntegers().write(0, (int) value); } }