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

Skywars Enchant

Discussion in 'Development' started by ZackyVN, Dec 13, 2018.

  1. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    So i have this code
    PHP:
        public function fillChests() {

            
    $fillInv = function (ChestInventory $inv) {
                
    $fillSlot = function (ChestInventory $invint $slot) {
                    
    $id self::getChestItems()[$index rand(05)][rand(0, (int)(count(self::getChestItems()[$index])-1))];
                    switch (
    $index) {
                        case 
    0:
                            
    $count 1;
                            break;
                        case 
    1:
                            
    $count 1;
                            break;
                        case 
    2:
                            
    $count rand(12);
                            break;
                        case 
    3:
                            
    $count rand(12);
                            break;
                        case 
    4:
                            
    $count rand(164);
                        case 
    5:
                            
    $count rand(12);
                            break;
                        default:
                            
    $count 0;
                            break;
                    }
                    
    $inv->setItem($slotItem::get($id0$count));
                };

                
    $inv->clearAll();

                for(
    $x 0$x <= 26$x++) {
                    if(
    rand(13) == 1) {
                        
    $fillSlot($inv$x);
                    }
                }
            };
    And This code
    PHP:
        public static function getChestItems(): array {
            
    $chestItems = [];
            
    //Weapon
            
    $weapons = [
                
    276,267
            
    ];
            
    //TOOLS
            
    $tools = [
                
    258,279
            
    ];
            
    //THROWABLE
            
    $throwable = [
                
    344,332
            
    ];
            
    //FOOD
            
    $food = [
                
    260297,320,322,364,366
            
    ];
            
    //BLOCKS
            
    $blocks = [
                
    5,4,1
            
    ];
            
    //Armor
            
    $armors = [
              
    306,307,308,309,310,311,312,313
            
    ];
        
    $level5 rand(15);
        
    $level3 rand(13);
        
    $level2 rand(12);
        
    $Sharpness Enchantment::getEnchantment(9);
        
    $Sharpness1 = new EnchantmentInstance($Sharpness$level5);
        
    $Protection Enchantment::getEnchantment(0);
        
    $Protection1 = new EnchantmentInstance($Protection$level5);
        
    $Efficiency Enchantment::getEnchantment(15);
        
    $Efficiency1 = new EnchantmentInstance($Efficiency$level5);
        
    $Unbreaking Enchantment::getEnchantment(17);
        
    $Unbreaking1 = new EnchantmentInstance($Unbreaking$level3);
        
    $Fire Enchantment::getEnchantment(13);
        
    $Fire1 = new EnchantmentInstance($Fire$level2);
        foreach(
    $weapons as $weapon){
        
    Item::get($weapon)->addEnchantment($Sharpness1);
        
    Item::get($weapon)->addEnchantment($Unbreaking1);
        
    Item::get($weapon)->addEnchantment($Fire1);
        }
        
    array_push($chestItems$weapons);
        
    //TOOLS Enchant
        
    foreach($tools as $tool){
        
    Item::get($tool)->addEnchantment($Unbreaking1);
        
    Item::get($tool)->addEnchantment($Efficiency1);
        }
        
    array_push($chestItems$tools);
        
    //Armors Enchant
        
    foreach($armors as $armor){
        
    Item::get($armor)->addEnchantment($Protection1);
        
    Item::get($armor)->addEnchantment($Unbreaking1);
        
    array_push($chestItems$armors);
        }
        return 
    $chestItems;
        }
    It work but when the sw game start i didnt see any enchanted items just none enchant item and only tools + armor + weapon. Can someone help me at this?
     
  2. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Whos SW plugin is this?
     
  3. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    If its GamakCZ's Skywars, you can buy the PRO version in his selly
     
  4. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    But i dont want to buy it can u help me?
     
  5. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
  6. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
  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.