Esempio n. 1
0
 public function run(WorldEditSession $session, array $args)
 {
     $params = new FormattedArguments($args);
     if ($params->enabled("b")) {
         $pos = $session->getBookmark();
         $level = $pos->getLevel($session->getMain()->getServer());
     } elseif (($name = $params->opt("b")) !== null) {
         $pos = $session->getBookmark($name);
         $level = $pos->getLevel($session->getMain()->getServer());
     } elseif (($name = $params->opt("p")) !== null) {
         $pos = $session->getMain()->getServer()->getPlayer($name);
         $level = $pos->getLevel();
         if (!$pos instanceof Player) {
             return Lang::ERR_OFFLINE;
         }
     } else {
         $pos = $session->getLocation();
         $level = $pos->getLevel();
     }
     $name = $params->opt("n", "default");
     $sel = $session->getSelection($name);
     $X = "x";
     $Y = "y";
     $Z = "z";
     if ($this->isTwo) {
         $X .= "2";
         $Y .= "2";
         $Z .= "2";
     } else {
         $X .= "1";
         $Y .= "1";
         $Z .= "1";
     }
     if (!$sel instanceof CuboidSpace) {
         $sel = new CuboidSpace();
         $sel->setLevelName($level->getName());
         $session->setSelection($sel, $name);
     }
     $sel->{$X} = $pos->x;
     $sel->{$Y} = $pos->y;
     $sel->{$Z} = $pos->z;
     $session->sendMessage(Lang::SELECTION_POS_SUCCESS, ["COORD_X" => $pos->x, "COORD_Y" => $pos->y, "COORD_Z" => $pos->z, "POINT_ID" => $this->isTwo ? "2" : "1"]);
     $session->sendMessage(Lang::SELECTION_POS_INFO);
     $session->sendMessageDirect($sel->name($session));
     return null;
 }
Esempio n. 2
0
 public function run(WorldEditSession $session, array $args)
 {
     $params = new FormattedArguments($args);
     $sel = $session->getSelection($params->opt("n", "default"));
     if ($sel === null) {
         return Lang::ERR_NO_SEL;
     }
     $coll = new BlockCollection();
     while (($string = $params->nextPlain()) !== null) {
         $entry = BlockEntry::fromString($string);
         // TODO handle exception
         $coll->addBlock($entry);
     }
     $bb = $sel->iteratorAllBlocks($coll);
     $rheostat = new Rheostat($session->getQueue(), $bb, $session->translate(Lang::SPACE_SET_BLOCKS, ["SPACE" => $sel->name($session)]));
     $session->getQueue()->addTask($rheostat);
     return Lang::EDIT_SET_IN_PROGRESS;
 }
Esempio n. 3
0
 public function run(WorldEditSession $session, array $args)
 {
     $params = new FormattedArguments($args);
     $sel = $session->getSelection($params->opt("n", "default"));
     if ($sel === null) {
         return Lang::ERR_NO_SEL;
     }
     $blocks = $params->nextPlain();
     $sources = [];
     foreach (explode(",", $blocks) as $block) {
         $sources[] = BlockEntry::fromString($block, false);
     }
     $targets = new BlockCollection();
     while (($string = $params->nextPlain()) !== null) {
         $entry = BlockEntry::fromString($string);
         // TODO handle exception
         $targets->addBlock($entry);
     }
     $bb = $sel->iteratorAllBlocks($targets);
     $rheostat = new Rheostat($session->getQueue(), new ArrayBackedBlockFilter($sources), $bb, $session->translate(Lang::SPACE_SET_BLOCKS, ["SPACE" => $sel->name($session)]));
     $session->getQueue()->addTask($rheostat);
     return Lang::EDIT_REPLACE_IN_PROGRESS;
 }
Esempio n. 4
0
 public function run(WorldEditSession $session, array $args)
 {
     $params = new FormattedArguments($args);
     if ($params->enabled("b")) {
         $pos = $session->getBookmark();
         $level = $pos->getLevel($session->getMain()->getServer());
     } elseif (($name = $params->opt("b")) !== null) {
         $pos = $session->getBookmark($name);
         $level = $pos->getLevel($session->getMain()->getServer());
     } elseif (($name = $params->opt("p")) !== null) {
         $pos = $session->getMain()->getServer()->getPlayer($name);
         $level = $pos->getLevel();
         if (!$pos instanceof Player) {
             return Lang::ERR_OFFLINE;
         }
     } else {
         $pos = $session->getLocation();
         $level = $pos->getLevel();
     }
     $name = $params->opt("n", "default");
     $sel = $session->getSelection($name);
     if (!$sel instanceof CylinderSpace) {
         $sel = new CylinderSpace();
         $sel->setLevelName($level->getName());
         $session->setSelection($sel, $name);
     }
     if ($this->isTop) {
         $sel->setTopCenter($pos);
     } else {
         $sel->setBaseCenter($pos);
     }
     $session->sendMessage(Lang::SELECTION_POS_SUCCESS, ["COORD_X" => $pos->x, "COORD_Y" => $pos->y, "COORD_Z" => $pos->z, "TOP_OR_BASE" => $session->translate($this->isTop ? Lang::PHRASE_TOP_CENTER : Lang::PHRASE_BASE_CENTER)]);
     $session->sendMessage(Lang::SELECTION_POS_INFO);
     $session->sendMessageDirect($sel->name($session));
     return null;
 }