gt:         Item[] armor = this.getArmorContents();
context: package cn.nukkit.inventory;
  
  import cn.nukkit.Player;
  import cn.nukkit.Server;
  import cn.nukkit.block.BlockAir;
  import cn.nukkit.entity.EntityHuman;
  import cn.nukkit.entity.EntityHumanType;
  import cn.nukkit.event.entity.EntityArmorChangeEvent;
  import cn.nukkit.event.entity.EntityInventoryChangeEvent;
  import cn.nukkit.event.player.PlayerItemHeldEvent;
  import cn.nukkit.item.Item;
  import cn.nukkit.item.ItemBlock;
  import cn.nukkit.network.protocol.ContainerSetContentPacket;
  import cn.nukkit.network.protocol.ContainerSetSlotPacket;
  import cn.nukkit.network.protocol.MobArmorEquipmentPacket;
  import cn.nukkit.network.protocol.MobEquipmentPacket;
  
  import java.util.Collection;
  
  /**
   * author: MagicDroidX
   * Nukkit Project
   */
  public class PlayerInventory extends BaseInventory {
  
      protected int itemInHandIndex = 0;
  
      protected final int[] hotbar;
  
      public PlayerInventory(EntityHumanType player) {
          super(player, InventoryType.PLAYER);
          this.hotbar = new int[this.getHotbarSize()];
          for (int i = 0; i < this.hotbar.length; i++) {
              this.hotbar[i] = i;
          }
      }
  
      @Override
      public int getSize() {
          return super.getSize() - 4;
      }
  
      @Override
      public void setSize(int size) {
          super.setSize(size + 4);
          this.sendContents(this.getViewers());
      }
  
      public int getHotbarSlotIndex(int index) {
          return (index >= 0 && index < this.getHotbarSize()) ? this.hotbar[index] : -1;
      }
  
      public void setHotbarSlotIndex(int index, int slot) {
          if (index >= 0 && index < this.getHotbarSize() && slot >= -1 && slot < this.getSize()) {
              this.hotbar[index] = slot;
          }
      }
  
      public int getHeldItemIndex() {
          return itemInHandIndex;
      }
  
      public void setHeldItemIndex(int index) {
          if (index >= 0 && index < this.getHotbarSize()) {
              this.itemInHandIndex = index;
  
              this.sendHeldItem(this.getHolder().getViewers().values());
          }
      }
  
      public Item getItemInHand() {
          Item item = this.getItem(this.getHeldItemSlot());
          if (item != null) {
              return item;
          } else {
              return new ItemBlock(new BlockAir(), 0, 0);
          }
      }
  
      public boolean setItemInHand(Item item) {
          return this.setItem(this.getHeldItemSlot(), item);
      }
  
      public int getHeldItemSlot() {
          return this.getHotbarSlotIndex(this.itemInHandIndex);
      }
  
      public void setHeldItemSlot(int slot) {
          if (slot >= -1 && slot < this.getSize()) {
              Item item = this.getItem(slot);
  
              int itemIndex = this.getHeldItemIndex();
  
              if (this.getHolder() instanceof Player) {
                  PlayerItemHeldEvent ev = new PlayerItemHeldEvent((Player) this.getHolder(), item, slot, itemIndex);
                  Server.getInstance().getPluginManager().callEvent(ev);
                  if (ev.isCancelled()) {
                      this.sendContents((Player) this.getHolder());
                      return;
                  }
              }
  
              this.setHotbarSlotIndex(itemIndex, slot);
          }
      }
  
      public void sendHeldItem(Player player) {
          Item item = this.getItemInHand();
  
          MobEquipmentPacket pk = new MobEquipmentPacket();
          pk.eid = this.getHolder().getId();
          pk.item = item;
          pk.slot = (byte) this.getHeldItemSlot();
          pk.selectedSlot = (byte) this.getHeldItemIndex();
  
          player.dataPacket(pk);
          if (player.equals(this.getHolder())) {
              this.sendSlot(this.getHeldItemSlot(), player);
          }
      }
  
      public void sendHeldItem(Player[] players) {
          Item item = this.getItemInHand();
  
          MobEquipmentPacket pk = new MobEquipmentPacket();
          pk.item = item;
          pk.slot = (byte) this.getHeldItemSlot();
          pk.selectedSlot = (byte) this.getHeldItemIndex();
  
          for (Player player : players) {
              pk.eid = this.getHolder().getId();
              if (player.equals(this.getHolder())) {
                  pk.eid = player.getId();
                  this.sendSlot(this.getHeldItemSlot(), player);
              }
  
              player.dataPacket(pk);
          }
      }
  
      public void sendHeldItem(Collection<Player> players) {
          this.sendHeldItem(players.stream().toArray(Player[]::new));
      }
  
      @Override
      public void onSlotChange(int index, Item before) {
          EntityHuman holder = this.getHolder();
          if (holder instanceof Player && !((Player) holder).spawned) {
              return;
          }
  
          super.onSlotChange(index, before);
  
          if (index >= this.getSize()) {
              this.sendArmorSlot(index, this.getViewers());
              this.sendArmorSlot(index, this.getHolder().getViewers().values());
          }
      }
  
      public int getHotbarSize() {
          return 9;
      }
  
      public Item getArmorItem(int index) {
          return this.getItem(this.getSize() + index);
      }
  
      public boolean setArmorItem(int index, Item item) {
          return this.setArmorItem(index, item, false);
      }
  
      public boolean setArmorItem(int index, Item item, boolean ignoreArmorEvents) {
          return this.setItem(this.getSize() + index, item, ignoreArmorEvents);
      }
  
      public Item getHelmet() {
          return this.getItem(this.getSize());
      }
  
      public Item getChestplate() {
          return this.getItem(this.getSize() + 1);
      }
  
      public Item getLeggings() {
          return this.getItem(this.getSize() + 2);
      }
  
      public Item getBoots() {
          return this.getItem(this.getSize() + 3);
      }
  
      public boolean setHelmet(Item helmet) {
          return this.setItem(this.getSize(), helmet);
      }
  
      public boolean setChestplate(Item chestplate) {
          return this.setItem(this.getSize() + 1, chestplate);
      }
  
      public boolean setLeggings(Item leggings) {
          return this.setItem(this.getSize() + 2, leggings);
      }
  
      public boolean setBoots(Item boots) {
          return this.setItem(this.getSize() + 3, boots);
      }
  
      @Override
      public boolean setItem(int index, Item item) {
          return setItem(index, item, false);
      }
  
      private boolean setItem(int index, Item item, boolean ignoreArmorEvents) {
          if (index < 0 || index >= this.size) {
              return false;
          } else if (item.getId() == 0 || item.getCount() <= 0) {
              return this.clear(index);
          }
  
          //Armor change
          if (!ignoreArmorEvents && index >= this.getSize()) {
              EntityArmorChangeEvent ev = new EntityArmorChangeEvent(this.getHolder(), this.getItem(index), item, index);
              Server.getInstance().getPluginManager().callEvent(ev);
              if (ev.isCancelled() && this.getHolder() != null) {
                  this.sendArmorSlot(index, this.getViewers());
                  return false;
              }
              item = ev.getNewItem();
          } else {
              EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent(this.getHolder(), this.getItem(index), item, index);
              Server.getInstance().getPluginManager().callEvent(ev);
              if (ev.isCancelled()) {
                  this.sendSlot(index, this.getViewers());
                  return false;
              }
              item = ev.getNewItem();
          }
  
          Item old = this.getItem(index);
          this.slots.put(index, item.clone());
          this.onSlotChange(index, old);
  
          return true;
      }
  
      @Override
      public boolean clear(int index) {
          if (this.slots.containsKey(index)) {
              Item item = new ItemBlock(new BlockAir(), null, 0);
              Item old = this.slots.get(index);
              if (index >= this.getSize() && index < this.size) {
                  EntityArmorChangeEvent ev = new EntityArmorChangeEvent(this.getHolder(), old, item, index);
                  Server.getInstance().getPluginManager().callEvent(ev);
                  if (ev.isCancelled()) {
                      if (index >= this.size) {
                          this.sendArmorSlot(index, this.getViewers());
                      } else {
                          this.sendSlot(index, this.getViewers());
                      }
                      return false;
                  }
                  item = ev.getNewItem();
              } else {
                  EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent(this.getHolder(), old, item, index);
                  Server.getInstance().getPluginManager().callEvent(ev);
                  if (ev.isCancelled()) {
                      if (index >= this.size) {
                          this.sendArmorSlot(index, this.getViewers());
                      } else {
                          this.sendSlot(index, this.getViewers());
                      }
                      return false;
                  }
                  item = ev.getNewItem();
              }
  
              if (item.getId() != Item.AIR) {
                  this.slots.put(index, item.clone());
              } else {
                  this.slots.remove(index);
              }
  
              this.onSlotChange(index, old);
          }
  
          return true;
      }
  
      public Item[] getArmorContents() {
          Item[] armor = new Item[4];
          for (int i = 0; i < 4; i++) {
              armor[i] = this.getItem(this.getSize() + i);
          }
  
          return armor;
      }
  
      @Override
      public void clearAll() {
          int limit = this.getSize() + 4;
          for (int index = 0; index < limit; ++index) {
              this.clear(index);
          }
      }
  
      public void sendArmorContents(Player player) {
          this.sendArmorContents(new Player[]{player});
      }
  
      public void sendArmorContents(Player[] players) {
  