Created
February 1, 2017 13:18
-
-
Save dktapps/68539c6b841fe2129819678007eae0cc to your computer and use it in GitHub Desktop.
Proof of concept transfer plugin for PocketMine with MCPE 1.0.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @name TransferPlugin | |
* @main dktapps\TransferPlugin\Main | |
* @api 3.0.0-ALPHA3 | |
* @version 1.0.0 | |
* @description Proof-of-concept for server transfer in MCPE 1.0.3 | |
* @author dktapps | |
*/ | |
namespace dktapps\TransferPlugin{ | |
class Main extends \pocketmine\plugin\PluginBase implements \pocketmine\event\Listener{ | |
public function onEnable(){ | |
$this->getServer()->getCommandMap()->register("transfer", new TransferCommand()); | |
} | |
} | |
class TransferCommand extends \pocketmine\command\Command{ | |
public function __construct(){ | |
parent::__construct( | |
"transfer", | |
"Transfer to another server", | |
"/transfer <server address> <server port>" | |
); | |
} | |
public function execute(\pocketmine\command\CommandSender $sender, $currentAlias, array $args){ | |
if(count($args) !== 2){ | |
$sender->sendMessage($this->usageMessage); | |
return false; | |
} | |
if(!($sender instanceof \pocketmine\Player)){ | |
$sender->sendMessage("You can only transfer yourself with this plugin (remember, this is only a proof of concept)"); | |
return false; | |
} | |
$pk = new \pocketmine\network\protocol\TransferPacket(); | |
$pk->address = $args[0]; | |
$pk->port = (int) $args[1]; | |
$sender->dataPacket($pk); | |
$sender->getServer()->broadcastMessage("Transferred " . $sender->getName() . " to " . $args[0] . ":" . $args[1]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment