├── .gitignore ├── LICENSE ├── README.md ├── config.yml ├── plugin.yml └── src └── Zero └── WorldTpUI ├── Command └── wtpuiCommand.php ├── Main.php └── UI ├── CustomUI.php ├── ListenerUI.php └── UI.php /.gitignore: -------------------------------------------------------------------------------- 1 | # PHPStorm Useless Files 2 | 3 | .idea 4 | .xml 5 | .iml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Plexus Studio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![plexus1](https://user-images.githubusercontent.com/12077835/32135004-85147afe-bbac-11e7-9f67-1c729974016e.png) 2 | 3 | # Notice 4 | This plugin may not be updated in the future. 5 | 6 | If anyone wishes to continue this plugin, they may do so. 7 | 8 | ZeroDevOfficial has moved on to making nukkit plugins, and will not be working on this anymore 9 | 10 | # Download 11 | You can find the phar [here](https://github.com/PlexusStudio/WorldTpUI/releases) 12 | 13 | # Config 14 | *if you want the plugin to load all your worlds change* 15 | ```YML 16 | load_all_worlds: false 17 | ``` 18 | to 19 | ```YML 20 | load_all_worlds: true 21 | ``` 22 | 23 | # World Teleport UI 24 | 25 | > Allows Admins to teleport between worlds with a simple UI in PocketMine 26 | 27 | > Version: v0.0.5 28 | 29 | > PocketMine-MP: api-3.0.0-ALPHA10 30 | 31 | > Minecraft: v1.2.x 32 | 33 | # How to Use 34 | Drop the plugin in your plugins folder, restart your server 35 | 36 | > commands: /wtpui 37 | 38 | ![tp-ui](https://i.imgur.com/r2dqtkl.png) 39 | 40 | # License 41 | ``` 42 | MIT License 43 | 44 | Copyright (c) 2017 Plexus Studio 45 | 46 | Permission is hereby granted, free of charge, to any person obtaining a copy 47 | of this software and associated documentation files (the "Software"), to deal 48 | in the Software without restriction, including without limitation the rights 49 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 50 | copies of the Software, and to permit persons to whom the Software is 51 | furnished to do so, subject to the following conditions: 52 | 53 | The above copyright notice and this permission notice shall be included in all 54 | copies or substantial portions of the Software. 55 | 56 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 57 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 58 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 59 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 60 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 61 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 62 | SOFTWARE. 63 | ``` 64 | -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 0.0.5 3 | load_all_worlds: false 4 | ... -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: WorldTpUI 2 | main: Zero\WorldTpUI\Main 3 | version: 0.0.6 4 | api: [3.0.0-ALPHA10, 3.0.0-ALPHA11] 5 | load: POSTWORLD 6 | author: ZeroDevOfficial 7 | description: Allows Admins to tp between worlds with a simple UI in PocketMine 8 | commands: 9 | wtpui: 10 | description: World Tp UI 11 | -------------------------------------------------------------------------------- /src/Zero/WorldTpUI/Command/wtpuiCommand.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 19 | parent::__construct('wtpui', 'allows admins to tp to any world', '/wtpui'); 20 | $this->setPermission('plugins.command'); 21 | } 22 | 23 | public function execute(CommandSender $sender, $alias, array $args){ 24 | if($sender instanceof Player){ 25 | if($sender->isOp() === true){ 26 | $ui = $this->plugin->ui['world-tp']; 27 | $ui->data = ['type' => 'custom_form', 'title' => 'WorldTpUI ' . $this->plugin->getDescription()->getVersion(), 28 | 'content' => [ 29 | ['type' => 'input', 'text' => 'Type a world name', 'placeholder' => 'WorldName', 'default' => null], 30 | ['type' => 'step_slider', 'text' => 'load area around yourself', 'steps' => array("\n0, load none", "\nload 4x4 area", "\nload 8x8 area")], 31 | ["type" => "label", "text" => "Worlds Loaded:\n" . TextFormat::AQUA . $this->getLevels()] 32 | ]]; 33 | $ui->send($sender); 34 | return true; 35 | }else{ 36 | $sender->sendMessage(TextFormat::RED . "You must be Op to run this Command!"); 37 | return false; 38 | } 39 | }else{ 40 | $sender->sendMessage(TextFormat::RED . "Command must be run in-game!"); 41 | return false; 42 | } 43 | } 44 | 45 | public function getLevels(){ 46 | $levels = $this->plugin->getServer()->getLevels(); 47 | foreach($levels as $level){ 48 | $lvl[$level->getName()] = $level; 49 | } 50 | return implode(", ", array_keys($lvl)); 51 | unset($lvl); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Zero/WorldTpUI/Main.php: -------------------------------------------------------------------------------- 1 | getServer()->getName() === 'PocketMine-MP'){ 22 | if($this->isFirstLoad() === true){ 23 | $this->getLogger()->info(TextFormat::YELLOW . "\nHello and Welcone to WorldTpUI\nEdit the config in 'plugins/WorldTpUI/config.yml'"); 24 | }else{ 25 | $this->getLogger()->info(TextFormat::YELLOW . "is Loading..."); 26 | $this->checkConfigVersion(); 27 | $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML); 28 | if($this->config->get("load_all_worlds") === true){ 29 | $this->loadAllWorlds(); 30 | } 31 | $this->createWorldUI(); 32 | $this->getServer()->getPluginManager()->registerEvents(new ListenerUI($this), $this); 33 | $this->getServer()->getCommandMap()->register('wtpui', new wtpuiCommand($this)); 34 | $this->getLogger()->info(TextFormat::GREEN . "Everything has Loaded!"); 35 | } 36 | }else{ 37 | $this->getLogger()->info(TextFormat::RED . 'Sorry this plugin does not support Spoons'); 38 | $this->getServer()->getPluginManager()->disablePlugin($this); 39 | } 40 | } 41 | 42 | public function isFirstLoad() : bool{ 43 | if(is_file($this->getDataFolder() . "config.yml")){ 44 | return false; 45 | }else{ 46 | @mkdir($this->getDataFolder()); 47 | $config = new Config($this->getDataFolder() . "config.yml", Config::YAML); 48 | $config->setAll(array('version' => $this->getDescription()->getVersion(), "load_all_worlds" => false)); 49 | $config->save(); 50 | return true; 51 | } 52 | } 53 | 54 | public function loadAllWorlds() : void{ 55 | $worlds = $this->getServer()->getDataPath() . "worlds/"; 56 | $allWorlds = array_slice(scandir($worlds), 2); 57 | foreach($allWorlds as $world){ 58 | if(is_dir($this->getServer()->getDataPath() . 'worlds/' . $world . '/')){ 59 | $this->getServer()->loadLevel($world); 60 | } 61 | } 62 | } 63 | 64 | public function createWorldUI() : void{ 65 | $id = $this->getRandId(); 66 | $ui = new CustomUI($id); 67 | $this->ui['world-tp'] = $ui; 68 | } 69 | 70 | public function checkConfigVersion() : void{ 71 | if(isset($this->config)){ 72 | $this->config->getAll(); 73 | }else{ 74 | $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML); 75 | $this->config->getAll(); 76 | } 77 | if($this->getDescription()->getVersion() != $this->config->get('version')){ 78 | $this->getLogger()->info(TextFormat::YELLOW . 'Config is not update-to-date'); 79 | $this->config->set('version', $this->getDescription()->getVersion()); 80 | $this->config->save(); 81 | //$this->setNewConfigItems();//soon 82 | $this->getLogger()->info(TextFormat::AQUA . 'Config is now update-to-date'); 83 | }else{ 84 | $this->getLogger()->info(TextFormat::AQUA . 'Your Config is update-to-date'); 85 | } 86 | } 87 | 88 | public function getRandId() : int{ 89 | $rand = rand(1, 1000); 90 | if(in_array($rand, $this->id)){ 91 | return self::getRandId(); 92 | }else{ 93 | $this->id[] = $rand; 94 | return $rand; 95 | } 96 | } 97 | 98 | public function onDisable() : void{ 99 | $this->getLogger()->info(TextFormat::RED . "unloading plugin..."); 100 | if(isset($this->config)){ 101 | $this->config->save(); 102 | } 103 | $this->getLogger()->info(TextFormat::RED . "has Unloaded, Goodbye!"); 104 | } 105 | } -------------------------------------------------------------------------------- /src/Zero/WorldTpUI/UI/CustomUI.php: -------------------------------------------------------------------------------- 1 | id = $id; 18 | } 19 | 20 | public function getId(){ 21 | return $this->id; 22 | } 23 | 24 | public function send($player){ 25 | $pk = new ModalFormRequestPacket(); 26 | $pk->formId = $this->id; 27 | $pk->formData = json_encode($this->data); 28 | $player->dataPacket($pk); 29 | } 30 | } -------------------------------------------------------------------------------- /src/Zero/WorldTpUI/UI/ListenerUI.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 22 | } 23 | 24 | public function getPlugin(){ 25 | return $this->plugin; 26 | } 27 | 28 | public function onPacketReceived(DataPacketReceiveEvent $e){ 29 | $player = $e->getPlayer(); 30 | if($player instanceof Player){ 31 | $pk = $e->getPacket(); 32 | if($pk instanceof ModalFormResponsePacket){ 33 | $id = $pk->formId; 34 | $data = json_decode($pk->formData, true); 35 | //var_dump($data);//debuggging. 36 | $form = $this->plugin->ui['world-tp']; 37 | if($id === $form->getId()){ 38 | if($data[0] != '' or $data[0] != null){ 39 | if($this->getPlugin()->getServer()->isLevelLoaded($data[0])){ 40 | if($player->getLevel()->getName() != $data[0]){ 41 | $this->loadArea($data[0], $data[1]); 42 | $player->teleport(Server::getInstance()->getLevelByName($data[0])->getSafeSpawn()); 43 | $player->sendMessage(TextFormat::AQUA . 'You have teleported to ' . $data[0]); 44 | }else{ 45 | $player->sendMessage(TextFormat::RED . 'You are already in that world'); 46 | } 47 | }else{ 48 | $player->sendMessage(TextFormat::RED . 'It seems that level is not loaded or does not exist'); 49 | } 50 | }else{ 51 | $player->sendMessage(TextFormat::RED . 'Please type a world in the input box.'); 52 | } 53 | } 54 | } 55 | } 56 | } 57 | 58 | public function loadArea(string $level, int $area){ 59 | $lvl = $this->getPlugin()->getServer()->getLevelByName($level); 60 | $position = new Position($lvl->getSafeSpawn()->x, $lvl->getSafeSpawn()->y, $lvl->getSafeSpawn()->z, $lvl); 61 | switch($area){ 62 | case 1; 63 | for($x = $position->getFloorX() - 4; $x <= $position->getFloorX() + 4; $x++){ 64 | for($z = $position->getFloorZ() - 4; $z <= $position->getFloorZ() + 4; $z++){ 65 | $position->getLevel()->loadChunk($x, $z); 66 | } 67 | } 68 | break; 69 | case 2: 70 | for($x = $position->getFloorX() - 8; $x <= $position->getFloorX() + 8; $x++){ 71 | for($z = $position->getFloorZ() - 8; $z <= $position->getFloorZ() + 8; $z++){ 72 | $position->getLevel()->loadChunk($x, $z); 73 | } 74 | } 75 | break; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /src/Zero/WorldTpUI/UI/UI.php: -------------------------------------------------------------------------------- 1 | id = $id; 17 | } 18 | 19 | public function getId(){ 20 | return $this->id; 21 | } 22 | 23 | public function send($player){ 24 | $pk = new ModalFormRequestPacket(); 25 | $pk->formId = $this->id; 26 | $pk->formData = json_encode($this->data); 27 | $player->dataPacket($pk); 28 | } 29 | } --------------------------------------------------------------------------------