public function onCommand(Command $cmd, array $args, Session $session) { switch ($cmd->getName()) { case "friend": if (!isset($args[0])) { $session->tell("Usage of /friend:\n" . "/friend add <name>: Add <name> to your friend list if he/she requested you to be friend, or send him/her a request if he/she didn't.\n" . "/friend remove <name>: If you are friends with <name>, you are no longer friends. If one of you sent a friend request to another, the request will be cancelled/denied. If you are not related at all, no warnings will be shown.\n" . "/friend list: View your friend list.\n" . "/friend inbox: View all requests sent to you." . "/friend outbox: View all requests you sent to other players."); return; } $session->tell($this->onFriendCommand($args, $session)); return; case "tpa": if (Settings::kitpvp_isSafeArea($session->getPlayer())) { $session->tell("You can't accept teleport requests from spawn!"); return; } if (!isset($args[0])) { if ($cmd instanceof oldSessionCommand) { $cmd->tellWrongUsage($session); } return; } $other = $this->getMain()->getSessions()->getSession($on = array_shift($args)); if (!$other instanceof Session) { $session->tell("Player {$on} not found!"); return; } if (!isset($this->playerData[$other->getUID()])) { $session->tell("{$other} is no longer in KitPvP, so he can't teleport!"); return; } if ($this->playerData[$other->getUID()]->tpRequestTo !== $session->getUID()) { $session->tell("{$other} cancelled/didn't send his teleport request to you."); return; } $this->playerData[$other->getUID()]->tpRequestTo = -1; $other->tell("You are going to be teleported to {$session} in a few seconds. Hold the handrail!"); $session->tell("{$other} is going to be teleported to you in a few seconds. Don't stand near a cliff!"); $this->getMain()->getServer()->getScheduler()->scheduleDelayedTask(new CallbackPluginTask($this->getMain(), function () use($session, $other) { if ($session->getPlayer() instanceof Player and $session->getPlayer()->isOnline() and $other->getPlayer() instanceof Player and $other->getPlayer()->isOnline()) { // don't quit! don't crash me! $other->teleport($session->getPlayer()); } }), 100); return; case "tpd": if (!isset($args[0])) { if ($cmd instanceof oldSessionCommand) { $cmd->tellWrongUsage($session); } return; } $other = $this->getMain()->getSessions()->getSession($on = array_shift($args)); if (!$other instanceof Session) { $session->tell("Player {$on} not found!"); return; } if (!isset($this->playerData[$other->getUID()])) { $session->tell("{$other} is no longer in KitPvP, so you don't have to do the dirty job to deny it! :D"); return; } if ($this->playerData[$other->getUID()]->tpRequestTo !== $session->getUID()) { $session->tell("{$other} cancelled/didn't send his teleport request to you."); return; } $this->playerData[$other->getUID()]->tpRequestTo = -1; $other->tell("{$session} doesn't want you to teleport to him: \"%s\"", implode(" ", $args)); $session->tell("Dirty job done; {$session}'s teleport request to you has been denied."); return; case "tpr": if (!isset($args[0])) { if ($cmd instanceof oldSessionCommand) { $cmd->tellWrongUsage($session); } return; } $other = $this->getMain()->getSessions()->getSession($on = array_shift($args)); if (!$other instanceof Session) { $session->tell("Player {$on} not found!"); return; } if (!$other->inSession($this)) { $session->tell("{$other} is not in KitPvP!"); return; } $data = $this->cancelTpRequest($session); $data->tpRequestTo = $other->getUID(); $other->tell("{$session} has sent you a teleport request: " . implode(" ", $args)); $session->tell("A teleport request has been sent to {$other}."); return; case "tpc": $this->cancelTpRequest($session, true); return; } }