コード例 #1
0
 public function onRun(array $args, Space $space, Player $player)
 {
     if (!isset($args[0])) {
         return self::WRONG_USE;
     }
     $name = array_shift($args);
     $block = BlockList::getBlockFronString($name);
     if ($block === null) {
         return self::NO_BLOCK;
     }
     $duration = 300;
     while (isset($args[0])) {
         $arg = array_shift($args);
         if (is_numeric($arg)) {
             $duration = intval($arg) * 20;
         } else {
             $replaces = BlockList::getBlockArrayFromString($arg);
         }
     }
     if (isset($replaces)) {
         $space->replaceBlocks($replaces, $block, true, $player);
     } else {
         $space->setBlocks($block, $player);
     }
     $this->getMain()->getServer()->getScheduler()->scheduleDelayedTask(new UndoTestTask($this->getMain(), $space), $duration);
     return "Previewing the selection for " . $duration / 20 . " seconds.";
 }
コード例 #2
0
 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.";
 }