public GraveInventory(PlayerInventory inventory) {
    this.items = new ItemStack[inventory.getSize()];

    for (int i = 0; i < inventory.getSize(); i++) {
      items[i] = inventory.getItem(i);
    }
  }
示例#2
0
 @EventHandler
 public void onPlayerJoin(PlayerJoinEvent e) {
   Player player = e.getPlayer();
   PlayerInventory in = player.getInventory();
   String locale = Locale.getPlayerLocale(player);
   for (int i = 0; i < in.getSize(); i++) {
     ItemStack item = in.getItem(i);
     if (ItemManager.toRPGItem(item) != null) RPGItem.updateItem(item, locale);
   }
   for (ItemStack item : player.getInventory().getArmorContents()) {
     if (ItemManager.toRPGItem(item) != null) RPGItem.updateItem(item, locale);
   }
 }
示例#3
0
  public boolean clearPlayerInventorySlot(String playerName, int slot) {
    try {
      Player p = getPlayerExact(playerName);
      PlayerInventory inv = p.getInventory();
      int cnt = inv.getSize();

      if (slot == 103) inv.clear(cnt + 3);
      else if (slot == 102) inv.clear(cnt + 2);
      else if (slot == 101) inv.clear(cnt + 1);
      else if (slot == 100) inv.clear(cnt + 0);
      else inv.clear(slot);

      p.saveData();

      return true;
    } catch (NullPointerException e) {
      return false;
    }
  }