public function onRun(array $args, Space $space) { if (!isset($args[1])) { return self::WRONG_USE; } $from = BlockList::getBlockArrayFromString(array_shift($args)); $targets = array_shift($args); $perc = strpos($targets, "%") !== false; $pos = strpos($targets, ","); if ($pos === false) { if (strpos(substr($targets, $pos), ",") === false) { if (!$this->twoNo and !$perc) { return "Replacing blocks into two block types without percentage is disabled on this server."; } if (!$this->twoYes and $perc) { return "Replacing blocks into two block types with percentage is disabled on this server."; } } else { if (!$this->mulNo and !$perc) { return "Replacing blocks into multiple block types without percentage is disabled on this server."; } if (!$this->mulYes and $perc) { return "Replacing blocks into multiple block types with percentage is disabled on this server."; } } $to = new BlockList($targets); } else { $to = new SingleList(BlockList::getBlockFronString($targets)); } $hollow = false; $update = true; while (isset($args[0])) { switch ($arg = strtolower(array_shift($args))) { case "h": case "hollow": $hollow = true; break; case "nu": case "no-update": $update = false; break; } } if ($hollow) { $cnt = $space->randomHollowReplace($from, $to, $update); } else { $cnt = $space->randomReplaces($from, $to, $update); } return "{$cnt} block(s) have been changed."; }