1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Settings items in chest from config

Discussion in 'Development' started by Junkdude, May 1, 2019.

  1. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    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++;

                    }
     
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    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(202020)]
    [
    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);
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.