pocketmine\inventory\PlayerInventory::clearAll PHP Метод

clearAll() публичный Метод

public clearAll ( )
    public function clearAll()
    {
        $limit = $this->getSize() + 4;
        for ($index = 0; $index < $limit; ++$index) {
            $this->clear($index, false);
        }
        $this->hotbar = range(0, $this->getHotbarSize() - 1, 1);
        $this->sendContents($this->getViewers());
    }

Usage Example

Пример #1
0
 public function equip(PlayerInventory $inv, PvpSessionData $data, $send = true)
 {
     $inv->clearAll();
     $messages = [];
     $info = Settings::kitpvp_getKitUpgradeInfo("helmet", $this->helmet);
     $inv->setHelmet($info->getItem());
     $messages[] = $info->itemsToString();
     $info = Settings::kitpvp_getKitUpgradeInfo("chestplate", $this->chestplate);
     $inv->setChestplate($info->getItem());
     $messages[] = $info->itemsToString();
     $info = Settings::kitpvp_getKitUpgradeInfo("leggings", $this->leggings);
     $inv->setLeggings($info->getItem());
     $messages[] = $info->itemsToString();
     $info = Settings::kitpvp_getKitUpgradeInfo("boots", $this->boots);
     $inv->setBoots($info->getItem());
     $messages[] = $info->itemsToString();
     $inv->sendArmorContents($inv->getViewers());
     if ($data->isUsingBowKit()) {
         $weapon = $data->getBowLevel() > 0 ? new Bow() : Item::get(Item::AIR);
         $messages[] = "a bow";
     } else {
         $info = Settings::kitpvp_getKitUpgradeInfo("weapon", $this->weapon);
         $weapon = $info->getItem();
         $messages[] = $info->itemsToString();
     }
     $info = Settings::kitpvp_getKitUpgradeInfo("food", $this->food);
     $food = $info->getItem();
     $messages[] = $info->itemsToString();
     $info = Settings::kitpvp_getKitUpgradeInfo("arrows", $this->arrows);
     $arrows = $info->getItem();
     $messages[] = $info->itemsToString();
     /** @var \pocketmine\item\Item[] $items */
     $items = [];
     if ($weapon->getId() !== Item::AIR) {
         $items[] = $weapon;
     }
     if ($food->getId() !== 0) {
         $items[] = $food;
     }
     if ($arrows->getId() !== 0) {
         $items[] = $arrows;
     }
     $inv->addItem(...$items);
     $cnt = Settings::easter_getSnowballCount($data->getSession());
     if ($cnt > 0) {
         $inv->addItem(new Snowball(0, $cnt));
     }
     if ($data->getKills() <= 500) {
         $inv->addItem(new Snowball(0, 8));
     }
     if ($send) {
         $inv->sendHeldItem($inv->getViewers());
         $inv->sendArmorContents($inv->getViewers());
     }
 }