Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error with own Plugin (Pls help)

Comments in 'Plugin Development' started by Survingo, Dec 7, 2015.

  1. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    So, finally I developed my plugin for Pocketmine. After some hours I tested it and I got some errors.
    I tried mostly everything.

    Code:
    [CODE][PocketMine] Server is starting...
    [PocketMine] Server was started.
    [Server] [21:29:49] [Server thread/INFO]: Loading pocketmine.yml...
    [Server] [21:29:49] [Server thread/INFO]: Loading server properties...
    [Server] [21:29:49] [Server thread/INFO]: Deutsch (deu) als Basissprache ausgewählt
    [Server] [21:29:49] [Server thread/INFO]: Startet Minecraft: PE Server mit Version v0.13.0 alpha
    [Server] [21:29:49] [Server thread/INFO]: Öffne Server auf 0.0.0.0:3306
    [Server] [21:29:50] [Server thread/INFO]: Dieser Server läuft mit Version PocketMine-MP 1.6dev-51 "[REDACTED]" (API: 1.13.0)
    [Server] [21:29:50] [Server thread/INFO]: PocketMine-MP wird unter der LGPL-Lizenz vertrieben
    [Server] [21:29:52] [Server thread/INFO]: Lädt SignShop v1.1.3
    [Server] [21:29:52] [Server thread/INFO]: Lädt SignPortal v1.1.2
    [Server] [21:29:52] [Server thread/INFO]: Lädt MassiveEconomy v1.0 R3
    [Server] [21:29:52] [Server thread/INFO]: Lädt WorldProtect v2.2.0
    [Server] [21:29:52] [Server thread/INFO]: Lädt CustomRanks v1.0.0
    [Server] [21:29:52] [Server thread/INFO]: Lädt EmptyWorld v1.0.0
    [Server] [21:29:52] [Server thread/INFO]: Lädt DevTools v1.10.0
    [Server] [21:29:52] [Server thread/INFO]: Lädt BuyCraft v1.2.1
    [Server] [21:29:52] [Server thread/INFO]: Lädt CustomAlerts v1.6
    [Server] [21:29:52] [Server thread/INFO]: Lädt MCG76_MazeRunner v2.0.1
    [Server] [21:29:52] [Server thread/INFO]: [MCG76_MazeRunner] -MCG76 MazeRunner Loaded
    [Server] [21:29:52] [Server thread/INFO]: Lädt TouchIt v2
    [Server] [21:29:52] [Server thread/INFO]: Lädt WorldEditArt v1.0.0_beta_dev_#048
    [Server] [21:29:52] [Server thread/INFO]: Lädt EasyMessages v1.1.0
    [Server] [21:29:52] [Server thread/INFO]: Lädt PrizeWin v1.0.6
    [Server] [21:29:52] [Server thread/INFO]: Lädt TapToDo v2.2.1
    [Server] [21:29:52] [Server thread/INFO]: Lädt EnderPearl v1.2.3
    [Server] [21:29:52] [Server thread/INFO]: Lädt MSpawns v1.5
    [Server] [21:29:52] [Server thread/INFO]: Lädt MassiveEconomyExample v1
    [Server] [21:29:52] [Server thread/INFO]: Lädt SimpleWarp v2.1.0
    [Server] [21:29:52] [Server thread/INFO]: Lädt SimplePortals v0.0.3
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere MassiveEconomy v1.0 R3
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere WorldProtect v2.2.0
    [Server] [21:29:53] [Server thread/INFO]: [WorldProtect] Enabled 7 features
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere EmptyWorld v1.0.0
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere DevTools v1.10.0
    [Server] [21:29:53] [Server thread/INFO]: Loading source plugin HydraPvP v1.4.0
    [Server] [21:29:53] [Server thread/INFO]: Loading source plugin Lobby v1
    [Server] [21:29:53] [Server thread/INFO]: Loading source plugin ImportMap v2.2-<PMIMPORTER>
    [Server] [21:29:53] [Server thread/INFO]: Loading source plugin HydraAuth v1.4.0
    [Server] [21:29:53] [Server thread/INFO]: [DevTools] Registered folder plugin loader
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere CustomAlerts v1.6
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere MSpawns v1.5
    [Server] [21:29:53] [Server thread/INFO]: Aktiviere MassiveEconomyExample v1
    [Server] [21:29:53] [Server thread/INFO]: [MassiveEconomyExample] Example Plugin using MassiveEconomy (API v0.90)
    [Server] [21:29:53] [Server thread/INFO]: Enabling Lobby v1
    [Server] [21:29:53] [Server thread/WARNING]: RuntimeException: "yaml_parse(): end of stream reached without finding document 0" (E_WARNING) in "/src/pocketmine/utils/Config" at line 143
    [Server] [21:29:53] [Server thread/INFO]: Disabling Lobby v1
    [Server] [21:29:53] [Server thread/INFO]: Enabling HydraAuth v1.4.0
    [Server] [21:29:53] [Server thread/INFO]: [HydraAuth] Alles geladen!
    [Server] [21:29:53] [Server thread/INFO]: Vorbereiten der Welt "Spawn"
    [Server] [21:29:54] [Server thread/INFO]: Aktiviere SignShop v1.1.3
    [Server] [21:29:55] [Server thread/INFO]: SignShop v1.1.3 Enabled!
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere SignPortal v1.1.2
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere CustomRanks v1.0.0
    [Server] [21:29:55] [Server thread/INFO]: [CustomRanks] Loading data...
    [Server] [21:29:55] [Server thread/INFO]: [CustomRanks] Done!
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere BuyCraft v1.2.1
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere MCG76_MazeRunner v2.0.1
    [Server] [21:29:55] [Server thread/INFO]: [MCG76_MazeRunner] -MCG76 Maze Runner Enabled
    [Server] [21:29:55] [Server thread/INFO]: [MCG76_MazeRunner] -config: wallheight =5
    [Server] [21:29:55] [Server thread/INFO]: [MCG76_MazeRunner] -config: enableroof =n
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere TouchIt v2
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere WorldEditArt v1.0.0_beta_dev_#048
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere EasyMessages v1.1.0
    [Server] [21:29:55] [Server thread/INFO]: Enabling EasyMessages v1.1.0...
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere PrizeWin v1.0.6
    [Server] [21:29:55] [Server thread/INFO]: [PrizeWin] PrizeWin - Enabled!
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere TapToDo v2.2.1
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level Parkour because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level Lobby because that level is not loaded.
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere EnderPearl v1.2.3
    [Server] [21:29:55] [Server thread/INFO]: [EnderPearl] EnderPerl loaded!
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere SimpleWarp v2.1.0
    [Server] [21:29:55] [Server thread/INFO]: Aktiviere SimplePortals v0.0.3
    [Server] [21:29:55] [Server thread/INFO]: Enabling HydraPvP v1.4.0
    [Server] [21:29:55] [Server thread/INFO]: [HydraPvP] [HydraPvP] - Starte HGCcore 1.4.0 und den HydraPvP Plugin...
    [Server] [21:29:55] [Server thread/INFO]: [HydraPvP] - Init ArenaManager
    [Server] [21:29:55] [Server thread/INFO]: Vorbereiten der Welt "PvP-Arena"
    [Server] [21:29:55] [Server thread/CRITICAL]: "Event 'pocketmine\event\level\LevelLoadEvent' konnte nicht zu 'SignShop v1.1.3' weitergegeben werden: Illegal offset type in SignShop\EventListener\LevelEvent"
    [Server] [21:29:55] [Server thread/WARNING]: RuntimeException: "Illegal offset type" (E_WARNING) in "/plugin-668.phar/src/SignShop/Manager/SignManager" at line 176
    [Server] [21:29:55] [Server thread/INFO]: [TapToDo] Reloading blocks due to level PvP-Arena loaded...
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level Parkour because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level world because that level is not loaded.
    [Server] [21:29:55] [Server thread/WARNING]: [TapToDo] Could not load block in level Lobby because that level is not loaded.
    [Server] [21:29:55] [Server thread/INFO]: [HydraPvP] [1vs1] - Load signs... 1 signs
    [Server] [21:29:55] [Server thread/INFO]: Enabling ImportMap v2.2-<PMIMPORTER>
    [Server] [21:30:00] [Server thread/INFO]: Starte GS4 Status-Listener
    [Server] [21:30:00] [Server thread/INFO]: Setze Query-Port auf 3306
    [Server] [21:30:00] [Server thread/INFO]: Query läuft auf 0.0.0.0:3306
    [Server] [21:30:00] [Server thread/INFO]: [UPnP] Trying to port forward...
    [Server] [21:30:00] [Server thread/INFO]: Standart-Spielmodus: Abenteuermodus
    [Server] [21:30:00] [Server thread/INFO]: Fertig! (15.106s)! Für Hilfe, tippe "help" oder "?"
    [Server] [21:30:00] [Server thread/INFO]: [Console] Console : Besuche die Account-Section in der Lobby für mehr Informationen!
    [Server] [21:30:05] [Server thread/INFO]: An error occured during authentication.
    [PocketMine] Stopping server...
    [Server] [21:30:11] [Server thread/INFO]: [CONSOLE: Server stoppen]
    [Server] [21:30:13] [Server thread/INFO]: [UPnP] Removing port forward...
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere SignShop v1.1.3
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere SignPortal v1.1.2
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere MassiveEconomy v1.0 R3
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere WorldProtect v2.2.0
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere CustomRanks v1.0.0
    [Server] [21:30:13] [Server thread/INFO]: [CustomRanks] Restoring original names...
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere EmptyWorld v1.0.0
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere DevTools v1.10.0
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere BuyCraft v1.2.1
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere CustomAlerts v1.6
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere MCG76_MazeRunner v2.0.1
    [Server] [21:30:13] [Server thread/INFO]: [MCG76_MazeRunner] -MCG76 MazeRunner Disable
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere TouchIt v2
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere WorldEditArt v1.0.0_beta_dev_#048
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere EasyMessages v1.1.0
    [Server] [21:30:13] [Server thread/INFO]: Disabling EasyMessages v1.1.0...
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere PrizeWin v1.0.6
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere TapToDo v2.2.1
    [Server] [21:30:13] [Server thread/INFO]: [TapToDo] Saving blocks...
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere EnderPearl v1.2.3
    [Server] [21:30:13] [Server thread/INFO]: [EnderPearl] EnderPearl unloaded!
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere MSpawns v1.5
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere MassiveEconomyExample v1
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere SimpleWarp v2.1.0
    [Server] [21:30:13] [Server thread/INFO]: Deaktiviere SimplePortals v0.0.3
    [Server] [21:30:13] [Server thread/INFO]: Disabling HydraPvP v1.4.0
    [Server] [21:30:13] [Server thread/INFO]: Disabling ImportMap v2.2-<PMIMPORTER>
    [Server] [21:30:13] [Server thread/INFO]: [ImportMap] ImportMap Unloaded!
    [Server] [21:30:13] [Server thread/INFO]: Disabling HydraAuth v1.4.0
    [Server] [21:30:13] [Server thread/INFO]: Entladen der Welt "Spawn"
    [Server] [21:30:14] [Server thread/INFO]: Entladen der Welt "PvP-Arena"
    [Server] [21:30:14] [Server thread/INFO]: Stopping other threads
    [PocketMine] Server was stopped.
    
    [/CODE]

    My plugin (Lobby v1.0) crashed. It is a plugin for lobby teleporting. (If this doesen't shows the error maybe I could give you some more info about the plug). Thanks, S
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Post ALL your plugin code.
    HotFireyDeath likes this.
  3. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Geb mal alle config dateien
    Please give all configs
    Hör nicht auf ihn er will nur den code stehlen. Spaß xd
    (For english: dont listen to gamecrafter, he just wants ro steal your code jk xd)
    Last edited: Dec 7, 2015
    CookieSteve and Legoboy0215 like this.
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I have no interest in stealing his code. Use logic and reasoning: How can we pinpoint the problem in his code if we don't even have his code to look at? Delete/edit your post immediately.
    Last edited: Dec 7, 2015
    HotFireyDeath likes this.
  5. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Hmm.. And what if i DON'T delete it?
    You cant do anything about that. Also i was joking, which i also was pointing out. But i know why you misunderstood me: you don't know what fun means.
    Gamecrafter and Survingo like this.
  6. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    src\Lobby\Main.php
    Code:
    <?php
    
    
    
    namespace Lobby;
    
    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\command\CommandExecutor;
    use pocketmine\level\Level;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    class Main extends PluginBase{
        //About Plugin Const
        const PRODUCER = "Survingo and hydra";
        const VERSION = "1.0";
        const MAIN_WEBSITE = "http://localhost";
        //Other Const
        //Prefix
        const PREFIX = "&f [Lobby] ";
        public $cfg;
        public $aliases;
        public $spawns;
       
    
        public function translateColors($symbol, $message){
         
            $message = str_replace($symbol."0", TextFormat::BLACK, $message);
            $message = str_replace($symbol."1", TextFormat::DARK_BLUE, $message);
            $message = str_replace($symbol."2", TextFormat::DARK_GREEN, $message);
            $message = str_replace($symbol."3", TextFormat::DARK_AQUA, $message);
            $message = str_replace($symbol."4", TextFormat::DARK_RED, $message);
            $message = str_replace($symbol."5", TextFormat::DARK_PURPLE, $message);
            $message = str_replace($symbol."6", TextFormat::GOLD, $message);
            $message = str_replace($symbol."7", TextFormat::GRAY, $message);
            $message = str_replace($symbol."8", TextFormat::DARK_GRAY, $message);
            $message = str_replace($symbol."9", TextFormat::BLUE, $message);
            $message = str_replace($symbol."a", TextFormat::GREEN, $message);
            $message = str_replace($symbol."b", TextFormat::AQUA, $message);
            $message = str_replace($symbol."c", TextFormat::RED, $message);
            $message = str_replace($symbol."d", TextFormat::LIGHT_PURPLE, $message);
            $message = str_replace($symbol."e", TextFormat::YELLOW, $message);
            $message = str_replace($symbol."f", TextFormat::WHITE, $message);
         
            $message = str_replace($symbol."k", TextFormat::OBFUSCATED, $message);
            $message = str_replace($symbol."l", TextFormat::BOLD, $message);
            $message = str_replace($symbol."m", TextFormat::STRIKETHROUGH, $message);
            $message = str_replace($symbol."n", TextFormat::UNDERLINE, $message);
            $message = str_replace($symbol."o", TextFormat::ITALIC, $message);
            $message = str_replace($symbol."r", TextFormat::RESET, $message);
         
            return $message;
        }
        public function onEnable(){
            @mkdir($this->getDataFolder());
            $this->saveDefaultConfig();
            $this->cfg = $this->getConfig()->getAll();
            $this->saveResource("aliases.yml");
            $this->saveResource("spawns.yml");
            $this->aliases = new Config($this->getDataFolder() . "aliases.yml", Config::YAML, array());
            $this->spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $this->getCommand("slobby")->setExecutor(new Commands\slobby($this));
            $this->getCommand("lobby")->setExecutor(new Commands\lobby($this));
    
            if($this->cfg["enable-aliases"] == true){
                $this->reloadAliases();
            }
            $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
        }
        public function reloadAliases(){
            $aliases = new Config($this->getDataFolder() . "aliases.yml", Config::YAML, array());
            $aliases = $aliases->getAll();
            foreach($aliases as $cmd => $target){
                $this->getServer()->getCommandMap()->register($cmd, new Aliases($this, $cmd));
            }
        }
        public function getSpawnMessage(Player $player){
            $temp = $this->getConfig()->getAll();
            if($temp["show-prefix"] == true){
                $format = Main::PREFIX . $temp["spawn-message"];
                $format = str_replace("{PLAYER}", $player->getName(), $format);
                $format = str_replace("{WORLD}", $player->getLevel()->getName(), $format);
                return $format;
            }else{
                $format = $temp["spawn-message"];
                $format = str_replace("{PLAYER}", $player->getName(), $format);
                $format = str_replace("{WORLD}", $player->getLevel()->getName(), $format);
                return $format;
            }
        }
        public function getSpawnMessage_2(Player $player, Level $level){
            $temp = $this->getConfig()->getAll();
            if($temp["show-prefix"] == true){
                $format = Main::PREFIX . $temp["spawn-message"];
                $format = str_replace("{PLAYER}", $player->getName(), $format);
                $format = str_replace("{WORLD}", $level->getName(), $format);
                return $format;
            }else{
                $format = $temp["spawn-message"];
                $format = str_replace("{PLAYER}", $player->getName(), $format);
                $format = str_replace("{WORLD}", $level->getName(), $format);
                return $format;
            }
        }
        public function getNoSpawnMessage(){
            $temp = $this->getConfig()->getAll();
            if($temp["show-prefix"] == true){
                $format = Main::PREFIX . "&cNo spawn found in this world";
                return $format;
            }else{
                $format = "&cNo spawn found in this world";
                return $format;
            }
        }
        public function getHubMessage(Player $player){
            $temp = $this->getConfig()->getAll();
            if($temp["show-prefix"] == true){
                $format = Main::PREFIX . $temp["hub-message"];
                $format = str_replace("{PLAYER}", $player->getName(), $format);
                $format = str_replace("{WORLD}", $player->getLevel()->getName(), $format);
                return $format;
            }else{
                $format = $temp["hub-message"];
                $format = str_replace("{PLAYER}", $player->getName(), $format);
                $format = str_replace("{WORLD}", $player->getLevel()->getName(), $format);
                return $format;
            }
        }
        public function getNoHubMessage(){
            $temp = $this->getConfig()->getAll();
            if($temp["show-prefix"] == true){
                $format = Main::PREFIX . "&cNo hub set";
                return $format;
            }else{
                $format = "&cNo hub set";
                return $format;
            }
        }
        public function getNoWorldMessage(){
            $temp = $this->getConfig()->getAll();
            if($temp["show-prefix"] == true){
                $format = Main::PREFIX . "&cWorld not found";
                return $format;
            }else{
                $format = "&cWorld not found";
                return $format;
            }
        }
    
        public function getForceSpawn_OnJoin(){
            $temp = $this->getConfig()->getAll();
            return $temp["force-spawn"];
        }
        /*public function getForceSpawn(){
            $temp = $this->getConfig()->getAll();
            return $temp["force-spawn"];
        }*/
        public function getForceHub_OnJoin(){
            $temp = $this->getConfig()->getAll();
            return $temp["force-hub"];
        }
        public function SetAlias($name, $target){
            $cfg = $this->getConfig()->getAll();
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $spawns = $spawns->getAll();
            $aliases = new Config($this->getDataFolder() . "aliases.yml", Config::YAML, array());
            $temp = $aliases->getAll();
            $name = strtolower($name);
            //Check if spawn exists
            if(isset($spawns[$target])){
                $temp[$name] = $target;
                $aliases->setAll($temp);
                $aliases->save();
                if($cfg["enable-aliases"] == true){
                    $this->reloadAliases();
                }
                return true;
            }else{
                return false;
            }
        }
        public function getSpawn(Level $level){
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $spawns = $spawns->getAll();
            if($this->SpawnExists($level)){
                return $spawns[$level->getName()];
            }else{
                return false;
            }
        }
        public function setSpawn(Player $player){
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $temp = $spawns->getAll();
            $temp[$player->getLevel()->getName()]["X"] = $player->x;
            $temp[$player->getLevel()->getName()]["Y"] = $player->y;
            $temp[$player->getLevel()->getName()]["Z"] = $player->z;
            $temp[$player->getLevel()->getName()]["Yaw"] = $player->yaw;
            $temp[$player->getLevel()->getName()]["Pitch"] = $player->pitch;
            $player->sendMessage($this->translateColors("&", Main::PREFIX . "&aSpawn set"));
            $spawns->setAll($temp);
            $spawns->save();
        }
        public function SpawnExists(Level $level){
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $spawns = $spawns->getAll();
            return isset($spawns[$level->getName()]);
        }
        public function getHub(){
            $temp = $this->getConfig()->getAll();
            if($this->HubExists()){
                return $temp["hub"];
            }else{
                return false;
            }
        }
        public function setHub(Player $player){
            $temp = $this->getConfig()->getAll();
            $temp["hub"]["world"] = $player->getLevel()->getName();
            $temp["hub"]["X"] = $player->x;
            $temp["hub"]["Y"] = $player->y;
            $temp["hub"]["Z"] = $player->z;
            $temp["hub"]["Yaw"] = $player->yaw;
            $temp["hub"]["Pitch"] = $player->pitch;
            $player->sendMessage($this->translateColors("&", Main::PREFIX . "&aHub set"));
            $this->getConfig()->setAll($temp);
            $this->getConfig()->save();
        }
        public function HubExists(){
            $temp = $this->getConfig()->getAll();
            return isset($temp["hub"]);
        }
        public function teleportToSpawn(Player $player){
            $temp = $this->getConfig()->getAll();
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $spawns = $spawns->getAll();
            if(isset($spawns[$player->getLevel()->getName()])){
                $player->teleport(new Position($spawns[$player->getLevel()->getName()]["X"], $spawns[$player->getLevel()->getName()]["Y"], $spawns[$player->getLevel()->getName()]["Z"]), $spawns[$player->getLevel()->getName()]["Yaw"], $spawns[$player->getLevel()->getName()]["Pitch"]);
                if($temp["enable-spawn-message"] == true){
                    $player->sendMessage($this->translateColors("&", $this->getSpawnMessage($player)));
                }
            }else{
                $player->sendMessage($this->translateColors("&", $this->getNoSpawnMessage()));
            }
            return true;
        }
        public function teleportToSpawn_2(Player $player, Level $level){
            $temp = $this->getConfig()->getAll();
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $spawns = $spawns->getAll();
            if(isset($spawns[$level->getName()])){
                $player->teleport(new Position($spawns[$level->getName()]["X"], $spawns[$level->getName()]["Y"], $spawns[$level->getName()]["Z"]), $spawns[$level->getName()]["Yaw"], $spawns[$level->getName()]["Pitch"]);
                if($temp["enable-spawn-message"] == true){
                    $player->sendMessage($this->translateColors("&", $this->getSpawnMessage_2($player, $level)));
                }
            }else{
                $player->sendMessage($this->translateColors("&", $this->getNoSpawnMessage()));
            }
            return true;
        }
        public function teleportToSpawn_OnJoin(Player $player){
            $temp = $this->getConfig()->getAll();
            $spawns = new Config($this->getDataFolder() . "spawns.yml", Config::YAML, array());
            $spawns = $spawns->getAll();
            if(isset($spawns[$player->getLevel()->getName()])){
                $player->teleport(new Position($spawns[$player->getLevel()->getName()]["X"], $spawns[$player->getLevel()->getName()]["Y"], $spawns[$player->getLevel()->getName()]["Z"]), $spawns[$player->getLevel()->getName()]["Yaw"], $spawns[$player->getLevel()->getName()]["Pitch"]);
                if($temp["enable-spawn-message"] == true && $temp["show-messages-onjoin"] == true){
                    $player->sendMessage($this->translateColors("&", $this->getSpawnMessage($player)));
                }
            }
            else{
                $player->sendMessage($this->translateColors("&", $this->getNoSpawnMessage()));
            }
        }
        public function teleportToHub(Player $player){
            $temp = $this->getConfig()->getAll();
            if(isset($temp["hub"])){
                if($player->getLevel()->getName()!=$temp["hub"]["world"]){
                    if(Server::getInstance()->loadLevel($temp["hub"]["world"]) != false){
                        $player->teleport(new Position($temp["hub"]["X"], $temp["hub"]["Y"], $temp["hub"]["Z"], $this->getServer()->getLevelByName($temp["hub"]["world"])), $temp["hub"]["Yaw"], $temp["hub"]["Pitch"]);
                        if($temp["enable-hub-message"] == true){
                            $player->sendMessage($this->translateColors("&", $this->getHubMessage($player)));
                        }
                    }else{
                        $player->sendMessage($this->translateColors("&", $this->getNoWorldMessage()));
                    }
                }else{
                    $player->teleport(new Position($temp["hub"]["X"], $temp["hub"]["Y"], $temp["hub"]["Z"]), $temp["hub"]["Yaw"], $temp["hub"]["Pitch"]);
                    if($temp["enable-hub-message"] == true){
                        $player->sendMessage($this->translateColors("&", $this->getHubMessage($player)));
                    }
                }
            }else{
                $player->sendMessage($this->translateColors("&", $this->getNoHubMessage()));
            }
        }
        public function teleportToHub_OnJoin(Player $player){
            $temp = $this->getConfig()->getAll();
            if(isset($temp["hub"])){
                if($player->getLevel()->getName()!=$temp["hub"]["world"]){
                    if(Server::getInstance()->loadLevel($temp["hub"]["world"]) != false){
                        $player->teleport(new Vector3($temp["hub"]["X"], $temp["hub"]["Y"], $temp["hub"]["Z"], $this->getServer()->getLevelByName($temp["hub"]["world"])), $temp["hub"]["Yaw"], $temp["hub"]["Pitch"]);
                        if($temp["enable-hub-message"] == true && $temp["show-messages-onjoin"] == true){
                            $player->sendMessage($this->translateColors("&", $this->getHubMessage($player)));
                        }
                    }else{
                        $player->sendMessage($this->translateColors("&", $this->getNoWorldMessage()));
                    }
                }else{
                    $player->teleport(new Vector3($temp["hub"]["X"], $temp["hub"]["Y"], $temp["hub"]["Z"]), $temp["hub"]["Yaw"], $temp["hub"]["Pitch"]);
                    if($temp["enable-hub-message"] == true && $temp["show-messages-onjoin"] == true){
                        $player->sendMessage($this->translateColors("&", $this->getHubMessage($player)));
                    }
                }
            }else{
                $player->sendMessage($this->translateColors("&", $this->getNoHubMessage()));
            }
        }
         
    }
    ?>
    
    Plugin.yml
    Code:
    name: Lobby
    main: Lobby\Main
    version: 1.0
    api: [1.13.0]
    load: STARTUP
    author: Survingo
    description: Lobby teleport plugin
    website: www.thehydra.de.tl
    
    commands:
    slobby:
      aliases: [setlobby]
      description: Sets the Lobby teleport.
      permission: lobby.set
    lobby:
      aliases: [hub]
      description: Teleports to lobby.
      permission: lobby.lobby
    
    permissions:
    lobby.set:
        default: op
        description: Sets the hub.
    lobby.lobby:
        default: true
        description: Teleports to lobby.
    
    src\Lobby\EventListener.php
    Code:
    <?php
    
    
    
    namespace Lobby;
    
    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\event\Listener;
    use pocketmine\event\entity\EntityLevelChangeEvent;
    use pocketmine\event\player\PlayerEvent;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\event\player\PlayerRespawnEvent;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\permission\Permission;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    class EventListener extends PluginBase implements Listener{
       
        public function __construct(Main $plugin){
            $this->plugin = $plugin;
        }
       
        /* Possible implementation comes later
         * public function onWorldChange(EntityLevelChangeEvent $event){
            $entity = $event->getEntity();
            //Check if Entity is a Player
            if($entity instanceof Player){
                //Check Force Spawn
                if($this->plugin->getForceSpawn()){
                    $this->plugin->teleportToSpawn_2($entity, $event->getTarget());
                }
            }
        }*/
       
        public function onPlayerRespawn(PlayerRespawnEvent $event){
            $this->cfg = $this->plugin->getConfig()->getAll();
            $player = $event->getPlayer();
            //Check if the victim is a Player
            if($player instanceof Player){
                //TP Death: 1 = TP spawn 2 = Teleport to Lobby
                if($this->cfg["teleport-on-death"] == 1){
                    //Check lobby
                    if($this->plugin->SpawnExists($player->getLevel())){
                        $pos = $this->plugin->getSpawn($player->getLevel());
                        $event->setRespawnPosition(new Position($pos["X"], $pos["Y"], $pos["Z"]), $pos["Yaw"], $pos["Pitch"]);
                    }
                }elseif($this->cfg["teleport-on-death"] == 2){
                    //Check lobby
                    if($this->plugin->HubExists()){
                        $this->plugin->teleportToHub($player);
                    }
                }
            }
        }
       
        public function onPlayerJoin(PlayerJoinEvent $event){
            $player = $event->getPlayer();
            if($this->plugin->getForceHub_OnJoin() == true){
                $this->plugin->teleportToHub_OnJoin($player);
            }else{
                if($this->plugin->getForceSpawn_OnJoin() == true){
                    $this->plugin->teleportToSpawn_OnJoin($player);
                }
            }
        }
       
    }
        ?>
    
    src\Lobby\Commands\Commands.php
    Code:
    <?php
    
    
    namespace Lobby\Commands;
    
    use pocketmi
  7. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Code:
    ne\Player;
    use pocketmine\command\Command;
    use pocketmine\command\CommandExecutor;
    use pocketmine\command\CommandSender;
    use pocketmine\permission\Permission;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    use Lobby\Main;
    
    class Commands extends PluginBase implements CommandExecutor{
      
        public function __construct(Main $plugin){
            $this->plugin = $plugin;
        }
                         return true;
                                   }
                               }elseif($args[0]=="sethub"){
                                   if($sender instanceof Player){
                                       if($sender->hasPermission("lobby.set")){
                                           $this->plugin->setHub($sender);
                                           return true;
                                       }
                                       else{
                                           $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
                                           return true;
                                       }
                                   }else{
                                       $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cYou can only perform this command as a player"));
                                       return true;
                                   }
                               }elseif($args[0]=="lobby"){
                                   if($sender instanceof Player){
                                       if($sender->hasPermission("lobby.lobby")){
                                           $this->plugin->teleportToHub($sender);
                                           return true;
                                       }
                                       else{
                                           $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
                                           return true;
                                       }
                                   }else{
                                       $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cYou can only perform this command as a player"));
                                       return true;
                                   } 
                            
                                       break;
                                   }
                                   return true;
                           }
                }
            return true;
        }
      
    }
        ?>
    
    src\Lobby\Commands\lobby.php
    Code:
    <?php
    
    
    
    namespace Lobby\Commands;
    
    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\command\Command;
    use pocketmine\command\CommandExecutor;
    use pocketmine\command\CommandSender;
    use pocketmine\level\Level;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\permission\Permission;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    use Lobby\Main;
    
    class Hub extends PluginBase implements CommandExecutor{
      
        public function __construct(Main $plugin){
            $this->plugin = $plugin;
        }
      
        public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) {
            $fcmd = strtolower($cmd->getName());
            switch($fcmd){
                    case "lobby":
                        if($sender instanceof Player){
                            if($sender->hasPermission("lobby.lobby")){
                                $this->plugin->teleportToHub($sender);
                                return true;
                            }
                            else{
                                $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
                                return true;
                            }
                        }else{
                            $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cYou can only perform this command as a player"));
                            return true;
                        }
                        break;
                }
            return true;
        }
      
    }
        ?>
    
    src\Lobby\Commands\slobby.php
    Code:
    <?php
    
    
    
    namespace Lobby\Commands;
    
    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\command\Command;
    use pocketmine\command\CommandExecutor;
    use pocketmine\command\CommandSender;
    use pocketmine\level\Level;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\permission\Permission;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    use Lobby\Main;
    
    class slobby extends PluginBase implements CommandExecutor{
      
        public function __construct(Main $plugin){
            $this->plugin = $plugin;
        }
      
        public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) {
            $fcmd = strtolower($cmd->getName());
            switch($fcmd){
                    case "slobby":
                        if($sender instanceof Player){
                            if($sender->hasPermission("lobby.set")){
                                $this->plugin->setHub($sender);
                                return true;
                            }else{
                                $sender->sendMessage($this->plugin->translateColors("&", "§cYou do not have the permission to set the Lobby!"));
                                return true;
                            }
                        }else{
                            $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "§cSomething went wrong!"));
                            return true;
                        }
                    break;
                }
            return true;
        }
      
    }
        ?>
    
    Sorry was to big ;)
    Some Main php was destroyed Idk so I copied some parts of EvolSofts mspawns Main but that will be removed shortly (going to bed))
    Last edited: Dec 7, 2015
    Kiosek likes this.
  8. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Do you have a config.yml file?
  9. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Yeah but empty
  10. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Just for testing, insert this:
    Code:
    ---
    test: ~
    ...
    
    
    Edit: i am sure i again switched the "..." And "---"
    Switch it if the error. Still appears
    Survingo likes this.
  11. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Awesome! But now I get another error (about class)
    Code:
    INFO]: Enabling Lobby v1
    [Server] [23:08:31] [Server thread/CRITICAL]: ClassNotFoundException: "Class Lobby\Commands\lobby not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 131
    lol I am going to check that tomorrow
    Last edited: Dec 7, 2015
    thebigsmileXD likes this.
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Plugin.yml or folder problem.
  13. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    class Hub extends PluginBase implements CommandExecutor{
    its suppose to be:
    class lobby extends PluginBase implements CommandExecutor{
    if the file name is "lobby" :p
    thebigsmileXD likes this.
  14. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Ah that was it thanks xD
  15. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen

Share This Page

Advertisement