public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args) { if ($scmd != "banitem" && $scmd != "unbanitem") { return false; } if (count($args) == 0) { $ids = $this->owner->getCfg($world, "banitem", []); if (count($ids) == 0) { $c->sendMessage(mc::_("[WP] No banned items in %1%", $world)); } else { $ln = mc::_("[WP] Items(%1%):", count($ids)); $q = ""; foreach ($ids as $id => $n) { $ln .= "{$q} {$n}({$id})"; $q = ","; } $c->sendMessage($ln); } return true; } $cc = 0; echo __METHOD__ . "," . __LINE__ . "\n"; //##DEBUG $ids = $this->owner->getCfg($world, "banitem", []); if ($scmd == "unbanitem") { foreach ($args as $i) { $item = Item::fromString($i); if (isset($ids[$item->getId()])) { unset($ids[$item->getId()]); ++$cc; } } } elseif ($scmd == "banitem") { foreach ($args as $i) { $item = Item::fromString($i); if (isset($ids[$item->getId()])) { continue; } $ids[$item->getId()] = ItemName::str($item); ++$cc; } } else { return false; } if (!$cc) { $c->sendMessage(mc::_("No items updated")); return true; } if (count($ids)) { $this->owner->setCfg($world, "banitem", $ids); } else { $this->owner->unsetCfg($world, "banitem"); } $c->sendMessage(mc::_("Items changed: %1%", $cc)); return true; }
public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args) { if ($scmd != "breakable" && $scmd != "unbreakable") { return false; } if (count($args) == 0) { $ids = $this->owner->getCfg($world, "unbreakable", []); if (count($ids) == 0) { $c->sendMessage(mc::_("[WP] No unbreakable blocks in %1%", $world)); } else { $ln = mc::_("[WP] Blocks(%1%):", count($ids)); $q = ""; foreach ($ids as $id => $n) { $ln .= "{$q} {$n}({$id})"; $q = ","; } $c->sendMessage($ln); } return true; } $cc = 0; $ids = $this->owner->getCfg($world, "unbreakable", []); if ($scmd == "breakable") { foreach ($args as $i) { $item = Item::fromString($i); if (isset($ids[$item->getId()])) { unset($ids[$item->getId()]); ++$cc; } } } elseif ($scmd == "unbreakable") { foreach ($args as $i) { $item = Item::fromString($i); if (isset($ids[$item->getId()])) { continue; } $ids[$item->getId()] = ItemName::str($item); ++$cc; } } else { return false; } if (!$cc) { $c->sendMessage(mc::_("No blocks updated")); return true; } if (count($ids)) { $this->owner->setCfg($world, "unbreakable", $ids); } else { $this->owner->unsetCfg($world, "unbreakable"); } $c->sendMessage(mc::_("Blocks changed: %1%", $cc)); return true; }