I'm currently working on my AuctionHouse plugin and I am trying to figure out how to set all the items in the chest, the current code just sets the same item twice instead of each item, how can I fix this PHP: public function openAH($p){//opens the menu and sets the items, if the amount of items > 54 then create the next page and so on, $menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST); $inv = $menu->getInventory(); foreach($this->ah->getAll() as $key){ // if(count($this->getPlugin()->getServer()->getOnlinePlayers()) == 1){ // var_dump($key); // } $item = Item::get($key["id"],$key["damage"],$key["count"]); $ec = $key["enchants"]; $name = $key["name"]; $cname = $key["customname"]; $seller = $key["seller"]; $lore = $key["lore"]; $nbt = $key["nbt"]; $price = $key["price"]; if($cname !== ""){ $item->setCustomName($cname); } if($ec !== null){ $enchInstance = new EnchantmentInstance($ec); $item->addEnchantment($enchInstance); } $lore2 = ["Price: $price"]; $item->setLore($lore2); $i = 0; while($i < count($this->ah->getAll())){ var_dump($i); $inv->setItem($i, $item); $i++; }
PHP: public function openAH($p){//opens the menu and sets the items, if the amount of items > 54 then create the next page and so on[/COLOR][/SIZE][/LEFT][SIZE=4][COLOR=rgb(20, 20, 20)][LEFT] $menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST); $inv = $menu->getInventory(); foreach($this->ah->getAll() as $key){ // if(count($this->getPlugin()->getServer()->getOnlinePlayers()) == 1){ // var_dump($key); // } $item = Item::get($key["id"],$key["damage"],$key["count"]); $ec = $key["enchants"]; $name = $key["name"]; $cname = $key["customname"]; $seller = $key["seller"]; $lore = $key["lore"]; $nbt = $key["nbt"]; $price = $key["price"]; if($cname !== ""){ $item->setCustomName($cname); } if($ec !== null){ $enchInstance = new EnchantmentInstance($ec); $item->addEnchantment($enchInstance); } $lore2 = ["Price: $price"]; $item->setLore($lore2); $inv->addItem($item);