public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if (count($args) !== 0) { return false; } if ($cmd->getName() != "back") { return false; } if (!MPMU::inGame($sender)) { return true; } $pos = $this->getState($sender, null); if ($pos == null) { $sender->sendMessage(mc::_("No recorded death position to return to")); return true; } list($x, $y, $z, $world) = $pos; $level = TPUtils::getLevelByName($this->owner->getServer(), $world); if ($level === null) { $sender->sendMessage(mc::_("Can not return to your death location")); $this->unsetState($sender); return true; } $sender->sendMessage(mc::_("Teleporting to the place of your demise")); TPUtils::tpNearBy($sender, new Position($x, $y, $z, $level)); $this->unsetState($sender); return true; }
public function cmdSummon(CommandSender $c, $args) { if (count($args) == 0) { return false; } if (!MPMU::inGame($c)) { return true; } $pl = $this->owner->getServer()->getPlayer($args[0]); if (!$pl) { $c->sendMessage(mc::_("%1% can not be found.", $args[0])); return true; } array_shift($args); if (count($args)) { $pl->sendMessage(implode(" ", $args)); } else { $pl->sendMessage(mc::_("You have been summoned by %1%", $c->getName())); } // Do we need to save current location? $state = $this->getState($c, []); $pn = strtolower($pl->getName()); if (!isset($state[$pn])) { $state[$pn] = new Position($pl->getX(), $pl->getY(), $pl->getZ(), $pl->getLevel()); } $this->setState($c, $state); $c->sendMessage(mc::_("Summoning %1%....", $pn)); TPUtils::tpNearBy($pl, $c); return true; }
public function cmdPushTp(CommandSender $c, $args) { if (!MPMU::inGame($c)) { return true; } // Determine target... if (count($args) == 3 && is_numeric($args[0]) && is_numeric($args[1]) && is_numeric($args[2])) { $target = new Vector3($args[0], $args[1], $args[2]); } elseif (count($args) == 1 || count($args) == 4) { // is it a person or a world?... if (count($args) == 1 && ($pl = $this->owner->getServer()->getPlayer($args[0]))) { $target = $pl; } else { // Assume it is a level... $world = array_shift($args); if (count($args) == 3) { if (!(is_numeric($args[0]) && is_numeric($args[1]) && is_numeric($args[2]))) { $c->sendMessage(mc::_("Invalid coordinate set")); return true; } $cc = new Vector3($args[0], $args[1], $args[2]); } else { $cc = null; } $level = TPUtils::getLevelByName($this->owner->getServer(), $world); if (!$level) { $c->sendMesage(mc::_("%1% not found.", $level)); return true; } $target = $level->getSafeSpawn($cc); } } elseif (count($args) == 0) { $target = null; } else { return false; } // save location... $stack = $this->getState($c, []); array_push($stack, new Position($c->getX(), $c->getY(), $c->getZ(), $c->getLevel())); $this->setState($c, $stack); $c->sendMessage(mc::_("Position saved!")); if ($target) { $c->sendMessage(mc::_("Teleporting...")); $c->teleport($target); } return true; }
private function approach($f, $l) { // "f=$f l=$l\n";//##DEBUG if (!$f instanceof Player) { $f = $this->owner->getServer()->getPlayer($f); if (!$f) { return; } // Couldn't find this guy! } if (!$l instanceof Player) { $l = $this->owner->getServer()->getPlayer($l); if (!$l) { return; } // Couldn't find this guy! } if (!$l->isonGround()) { return; } // We don't approach if leader is flying... if ($f->getLevel() === $l->getLevel()) { $dist = $f->distance($l); // $f->getName()." - ".$l->getName()." DIST:$dist\n";//##DEBUG if ($dist < $this->maxdist) { return; } // Close enough } TPUtils::tpNearBy($f, $l, $this->maxdist, $this->maxdist); }
private function cmdSet($sender, $args) { switch (count($args)) { case 0: return false; case 1: $n = strtolower($args[0]); $pos = $sender; break; default: $n = strtolower(array_shift($args)); $pos = explode(":", implode(" ", $args), 2); if (count($pos) == 2) { $world = $pos[1]; $level = TPUtils::getLevelByName($this->owner->getServer(), $world); if ($level === null) { $sender->sendMessage(mc::_("World %1% does not exist", $world)); return true; } } else { if (MPMU::inGame($sender, false)) { $level = $sender->getLevel(); } else { $level = $this->owner->getServer()->getDefaultLevel(); } } $pos = explode(",", $pos[0]); if (count($pos) != 3) { $sender->sendMessage(mc::_("Invalid position")); return true; } $pos = new Position(intval($pos[0]), intval($pos[1]), intval($pos[2]), $level); } $warp = $this->getWarp($n); if ($warp == null) { if (!MPMU::access($sender, "gb.cmd.setwarp.new")) { return true; } PermUtils::add($this->owner, "gb.warp." . $n, "warp to " . $n, self::defaultWarpPerm); } else { if (!MPMU::access($sender, "gb.cmd.setwarp.move")) { return true; } } if ($this->setWarp($n, $pos)) { $sender->sendMessage(mc::_("Warp %1% created", $n)); } else { $sender->sendMessage(mc::_("Unable to create Warp %1%", $n)); } return true; }