private function checkPlenty($player, $item) { echo __METHOD__ . "," . __LINE__ . "\n"; //##DEBUG if (!$this->getState($player, false)) { return; } echo __METHOD__ . "," . __LINE__ . "\n"; //##DEBUG $count = InvUtils::countInvItem($player, $item); echo __METHOD__ . "," . __LINE__ . " count={$count}\n"; //##DEBUG if ($count > 3) { return; } echo __METHOD__ . "," . __LINE__ . "\n"; //##DEBUG $item->setCount(3); $player->getInventory()->addItem(clone $item); $player->getInventory()->sendContents($player); }
private function rmInvItem(CommandSender $sender, array $args) { if (count($args) == 0) { return false; } if (($target = $this->owner->getServer()->getPlayer($args[0])) === null) { if (!MPMU::inGame($sender)) { return true; } $target = $sender; $other = false; } else { if (!MPMU::access($sender, "gb.cmd.rminv.others")) { return true; } array_shift($args); $other = true; } if (count($args) == 0) { return false; } if ($target->isCreative() || $target->isSpectator()) { $sender->sendMessage(mc::_("%1% is in %2% mode", $target->getDisplayName(), MPMU::gamemodeStr($target->getGamemode()))); return true; } $count = null; if (count($args) > 1 && is_numeric($args[count($args) - 1])) { $count = array_pop($args); } $args = strtolower(implode("_", $args)); if ($args == "hand") { $item = clone $target->getInventory()->getItemInHand(); if ($item->getId() == 0) { $sender->sendMessage(mc::_("Must be holding something")); return true; } } else { $item = Item::fromString($args); if ($item->getId() == 0) { $sender->sendMessage(mc::_("There is no item called %1%", $args)); return true; } } $k = InvUtils::rmInvItem($target, $item, $count); if ($k) { $sender->sendMessage(mc::n(mc::_("one item of %1% removed", ItemName::str($item)), mc::_("%2% items of %1% removed", ItemName::str($item), $k), $k)); if ($other) { $target->sendMessage(mc::n(mc::_("%2% took one item of %1% from you", ItemName::str($item), $sender->getName()), mc::_("%3% took %2% items of %1% from you", ItemName::str($item), $k, $sender->getName()), $k)); } } else { $sender->sendMessage(mc::_("No items were removed!")); } return true; }