Ejemplo 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;
 }
Ejemplo n.º 2
0
 public function standardCuboidOffset($offset, &$x, &$y, &$z)
 {
     $lengthX = $this->space->getLengthX();
     $lengthY = $this->space->getLengthY();
     $lengthZ = $this->space->getLengthZ();
     if ($offset < $lengthX * $lengthY * $lengthZ) {
         $z = $offset % $lengthZ;
         $offset = (int) ($offset / $lengthZ);
         $y = $offset % $lengthY;
         $offset = (int) ($offset / $lengthY);
         $x = $offset;
         $x += $this->space->getMinX();
         $y += $this->space->getMinY();
         $z += $this->space->getMinZ();
         return true;
     }
     return false;
 }