예제 #1
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (count($args) == 0) {
         return false;
     }
     $i = array_pop($args);
     if (($type = ArmorItems::str2quality($i)) == ArmorItems::ERROR) {
         $sender->sendMessage(mc::_("Unknown armor quality %1%", $i));
         return false;
     }
     $slots = [0, 1, 2, 3];
     // All slots
     if (count($args)) {
         $i = ArmorItems::str2part($args[count($args) - 1]);
         if ($i != ArmorItems::ERROR) {
             $slots = [$i];
             array_pop($args);
         }
     }
     $pl = $sender;
     if (count($args)) {
         $i = $this->owner->getServer()->getPlayer($args[count($args) - 1]);
         if ($i) {
             $pl = $i;
             if (!MPMU::access($sender, "gb.cmd.setarmor.others")) {
                 return true;
             }
             array_pop($args);
         }
     }
     if (count($args)) {
         return false;
     }
     if (!MPMU::inGame($pl)) {
         return true;
     }
     foreach ($slots as $i) {
         $pl->getInventory()->setArmorItem($i, new Item(ArmorItems::getItemId($type, $i), 0, 1));
     }
     if ($type == ArmorItems::NONE) {
         $sender->sendMessage(mc::_("Amouring down %1%", $pl->getName()));
     } else {
         $sender->sendMessage(mc::_("Amouring up %1%", $pl->getName()));
     }
     // Make sure inventory is updated...
     $pl->getInventory()->sendArmorContents($pl);
     return true;
 }
예제 #2
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (count($args) == 0) {
         return false;
     }
     $pl = $this->owner->getServer()->getPlayer($args[0]);
     if ($pl !== null) {
         array_shift($args);
         if (count($args) == 0) {
             return false;
         }
         if (!MPMU::access($sender, "gb.cmd.setarmor.others")) {
             return true;
         }
         $others = true;
     } else {
         if (!MPMU::inGame($sender)) {
             return true;
         }
         $pl = $sender;
         $others = false;
     }
     $j = implode("_", $args);
     $item = Item::fromString($j);
     $slot = ArmorItems::getArmorPart($item->getId());
     if ($slot != ArmorItems::ERROR) {
         $pl->getInventory()->setArmorItem($slot, clone $item);
         if ($others) {
             $pl->sendMessage(mc::_("You were equiped an %1% by %2%", ItemName::str($item), $sender->getName()));
             $sender->sendMessage(mc::_("Equiping %1% with %2%", $pl->getDisplayName(), ItemName::str($item)));
         } else {
             $sender->sendMessage(mc::_("Equiping armor %1%", ItemName::str($item)));
         }
         $pl->getInventory()->sendArmorContents($pl);
         return true;
     }
     if (($type = ArmorItems::str2quality($j)) == ArmorItems::ERROR) {
         $sender->sendMessage(mc::_("Unknown armor quality %1%", $j));
         return false;
     }
     foreach ([0, 1, 2, 3] as $slot) {
         $pl->getInventory()->setArmorItem($slot, new Item(ArmorItems::getItemId($type, $slot), 0, 1));
     }
     if ($type == ArmorItems::NONE) {
         if ($others) {
             $pl->sendMessage(mc::_("You were armoured down by %1%", $sender->getName()));
             $sender->sendMessage(mc::_("%1% was armoured down", $pl->getDisplayName()));
         } else {
             $sender->sendMessage(mc::_("Armoured down"));
         }
     } else {
         if ($others) {
             $pl->sendMessage(mc::_("You were armoured up by %1%", $sender->getName()));
             $sender->sendMessage(mc::_("%1% was armoured up", $pl->getDisplayName()));
         } else {
             $sender->sendMessage(mc::_("Armoured up"));
         }
     }
     $pl->getInventory()->sendArmorContents($pl);
     return true;
 }
예제 #3
0
 public function giveArmor(Player $pl)
 {
     $armor = [];
     foreach ($this->armor as $j) {
         $item = Item::fromString($j);
         $slot = ArmorItems::getArmorPart($item->getId());
         if ($slot == ArmorItems::ERROR) {
             $this->getLogger()->error(mc::_("Invalid armor item: %1%", $j));
             continue;
         }
         $armor[$slot] = $item;
     }
     foreach ($armor as $slot => $item) {
         if ($pl->getInventory()->getArmorItem($slot)->getID() != 0) {
             continue;
         }
         $pl->getInventory()->setArmorItem($slot, clone $item);
     }
 }
예제 #4
0
 private function giveArmor($pl)
 {
     if (!$pl->hasPermission("spawnmgr.receive.armor")) {
         return;
     }
     $inventory = [];
     foreach ($this->armor as $j) {
         $item = Item::fromString($j);
         $slot = ArmorItems::getArmorPart($item->getId());
         if ($slot == ArmorItems::ERROR) {
             $this->getLogger()->error(mc::_("Invalid armor item: %1%", $j));
             continue;
         }
         $inventory[$slot] = $item;
     }
     foreach ($inventory as $slot => $item) {
         if ($pl->getInventory()->getArmorItem($slot)->getID() != 0) {
             continue;
         }
         $pl->getInventory()->setArmorItem($slot, clone $item);
     }
 }