mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Added API for transferring players to other servers (#355)
* Added API method `Player->transfer()` and PlayerTransferEvent
This commit is contained in:
@ -57,6 +57,7 @@ use pocketmine\command\defaults\TeleportCommand;
|
||||
use pocketmine\command\defaults\TellCommand;
|
||||
use pocketmine\command\defaults\TimeCommand;
|
||||
use pocketmine\command\defaults\TimingsCommand;
|
||||
use pocketmine\command\defaults\TransferServerCommand;
|
||||
use pocketmine\command\defaults\VanillaCommand;
|
||||
use pocketmine\command\defaults\VersionCommand;
|
||||
use pocketmine\command\defaults\WhitelistCommand;
|
||||
@ -115,6 +116,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
$this->register("pocketmine", new TimeCommand("time"));
|
||||
$this->register("pocketmine", new TimingsCommand("timings"));
|
||||
$this->register("pocketmine", new ReloadCommand("reload"));
|
||||
$this->register("pocketmine", new TransferServerCommand("transferserver"));
|
||||
|
||||
if($this->server->getProperty("debug.commands", false)){
|
||||
$this->register("pocketmine", new StatusCommand("status"));
|
||||
|
56
src/pocketmine/command/defaults/TransferServerCommand.php
Normal file
56
src/pocketmine/command/defaults/TransferServerCommand.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\command\defaults;
|
||||
|
||||
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Player;
|
||||
|
||||
class TransferServerCommand extends VanillaCommand{
|
||||
|
||||
public function __construct($name){
|
||||
parent::__construct(
|
||||
$name,
|
||||
"%pocketmine.command.transferserver.description",
|
||||
"%pocketmine.command.transferserver.usage"
|
||||
);
|
||||
$this->setPermission("pocketmine.command.transferserver");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $commandLabel, array $args){
|
||||
if(count($args) < 1){
|
||||
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
|
||||
|
||||
return false;
|
||||
}elseif(!($sender instanceof Player)){
|
||||
$sender->sendMessage("This command must be executed as a player");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$sender->transfer($args[0], (int) ($args[1] ?? 19132));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user