示例#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
 /**
  * @param Block[]|Space $blocks
  * @param Position|null $anchor
  * @param string $name
  */
 public function __construct($blocks = [], Position $anchor = null, $name = "default")
 {
     $this->name = $name;
     $this->creationTime = microtime(true);
     if ($blocks instanceof Space) {
         $anchor = $anchor->round();
         foreach ($blocks->getBlockList() as $b) {
             $this->add($b->subtract($anchor), $b);
         }
     } else {
         $this->blocks = $blocks;
     }
 }
示例#3
0
 public function onRun(array $args, Space $space)
 {
     if (!isset($args[0])) {
         return self::WRONG_USE;
     }
     $name = array_shift($args);
     $perc = strpos($name, "%") !== false;
     if (($pos = strpos($name, ",")) !== false) {
         if (strpos(substr($name, $pos), ",") === false) {
             if (!$this->twoNo and !$perc) {
                 return "Setting two block types without percentage is disabled on this server.";
             }
             if (!$this->twoYes and $perc) {
                 return "Setting two block types with percentage is disabled on this server.";
             }
             if (!$this->mulNo and !$perc) {
                 return "Setting multiple block types without percentage is disabled on this server.";
             }
             if (!$this->mulYes and $perc) {
                 return "Setting multiple block types with percentage is disabled on this server.";
             }
         }
         try {
             $list = new BlockList($name);
         } catch (BlockPatternParseException $e) {
             return "The following pattern error occurred: " . $e->getMessage();
         }
     } else {
         $block = BlockList::getBlockFronString($name);
         if ($block === null) {
             return self::NO_BLOCK;
         }
         $list = new SingleList($block);
     }
     $hollow = false;
     $update = false;
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "h":
             case "hollow":
                 $hollow = true;
             case "nu":
             case "no-update":
                 $update = true;
                 break;
         }
     }
     if ($hollow) {
         $cnt = $space->randomHollow($list, $update);
     } else {
         $cnt = $space->randomPlaces($list, $update);
     }
     return "{$cnt} block(s) have been changed.";
 }
 public function __construct(Position $a, Vector3 $b)
 {
     $this->raw0 = $a;
     if (!$b instanceof Position) {
         $b = new Position($b->getX(), $b->getY(), $b->getZ(), $a->getLevel());
     }
     $this->raw1 = $b;
     if ($a->getLevel()->getName() !== $b->getLevel()->getName()) {
         trigger_error("Positions of different levels (\"" . $a->getLevel()->getName() . "\" and \"" . $b->getLevel()->getName() . "\" passed to constructor of " . get_class($this), E_USER_WARNING);
     }
     $this->bake();
     parent::__construct();
     // call this at the last because it has to bake before acquiring
 }
 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.";
 }
 public function __construct(Position $centre, $radius)
 {
     $this->centre = $centre;
     $this->radius = $radius;
     $y = $centre->y;
     $y = [$y + $radius, $y - $radius];
     $maxY = max($y);
     $minY = min($y);
     $maxHeight = 127;
     if (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT")) {
         $maxHeight = constant($path);
         // **** PhpStorm
     }
     if ($maxY > $maxHeight or $minY < 0) {
         throw new SelectionExceedWorldException("SphereSpace");
     }
     parent::__construct();
 }
 public function __construct($axis, $radius, Position $base, $height)
 {
     $this->base = Position::fromObject($base->floor(), $base->getLevel());
     $this->height = $height;
     $this->radius = $radius;
     $this->axis = $axis % 3;
     if ($this->axis === self::Y) {
         $y = [$this->base->getY(), $this->base->getY() + $height];
         $maxY = max($y);
         $minY = min($y);
     } else {
         $y = [$this->base->getY() + $radius, $this->base->getY() - $radius];
         $maxY = max($y);
         $minY = min($y);
     }
     $maxHeight = 127;
     if (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT")) {
         $maxHeight = constant($path);
     }
     if ($maxY > $maxHeight or $minY < 0) {
         throw new SelectionExceedWorldException("CylinderSpace");
     }
     parent::__construct();
 }