getNewItem() public method

public getNewItem ( )
Ejemplo n.º 1
0
 public function clear($index)
 {
     if (isset($this->slots[$index])) {
         $item = Item::get(Item::AIR, \null, 0);
         $old = $this->slots[$index];
         $holder = $this->getHolder();
         if ($holder instanceof Entity) {
             Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $old, $item, $index));
             if ($ev->isCancelled()) {
                 $this->sendSlot($index, $this->getViewers());
                 return \false;
             }
             $item = $ev->getNewItem();
         }
         if ($item->getId() !== Item::AIR) {
             $this->slots[$index] = clone $item;
         } else {
             unset($this->slots[$index]);
         }
         $this->onSlotChange($index, $old);
     }
     return \true;
 }
 public function clear($index)
 {
     if (isset($this->slots[$index])) {
         $item = Item::get(Item::AIR, null, 0);
         $old = $this->slots[$index];
         if ($index >= $this->getSize() and $index < $this->size) {
             //Armor change
             Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $old, $item, $index));
             if ($ev->isCancelled()) {
                 if ($index >= $this->size) {
                     $this->sendArmorSlot($index, $this->getViewers());
                 } else {
                     $this->sendSlot($index, $this->getViewers());
                 }
                 return false;
             }
             $item = $ev->getNewItem();
         } else {
             Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($this->getHolder(), $old, $item, $index));
             if ($ev->isCancelled()) {
                 if ($index >= $this->size) {
                     $this->sendArmorSlot($index, $this->getViewers());
                 } else {
                     $this->sendSlot($index, $this->getViewers());
                 }
                 return false;
             }
             $item = $ev->getNewItem();
         }
         if ($item->getId() !== Item::AIR) {
             $this->slots[$index] = clone $item;
         } else {
             unset($this->slots[$index]);
         }
         $this->onSlotChange($index, $old);
     }
     return true;
 }
Ejemplo n.º 3
0
 public function onInventoryChange(EntityInventoryChangeEvent $event)
 {
     if ($this->plugin->game && ($Player = $event->getEntity()) && $Player instanceof Human && ($Level = $Player->getLevel()) && $Player->getGamemode() == 0) {
         $OldItem = $event->getOldItem();
         $NewItem = $event->getNewItem();
         if ($this->plugin->game->level_name != $Level->getFolderName()) {
             return;
         }
         switch ($NewItem->getId()) {
             case 336:
                 $this->plugin->game->PopupInfo2->PlayersData[strtolower($Player->getName())][1] += $NewItem->getCount() * $this->plugin->spawner_gives["b"];
                 $event->setCancelled(true);
                 break;
             case 265:
                 $this->plugin->game->PopupInfo2->PlayersData[strtolower($Player->getName())][1] += $NewItem->getCount() * $this->plugin->spawner_gives["i"];
                 $event->setCancelled(true);
                 break;
             case 266:
                 $this->plugin->game->PopupInfo2->PlayersData[strtolower($Player->getName())][1] += $NewItem->getCount() * $this->plugin->spawner_gives["g"];
                 $event->setCancelled(true);
                 break;
         }
     }
 }