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 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; }
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); }