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

error with my plugin !!

Comments in 'Plugin Development' started by Ritch, Mar 5, 2016.

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Help please ?
    PHP:
    <?php

    namespace game;

    use 
    pocketmine\utils\TextFormat as MT;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\scheduler\PluginTask;

    class 
    Min extends PluginTask {
       
            public function 
    __construct(Main $plugin)  {
            
    $this->plugin $plugin;
            
    parent::__construct($plugin);
        }
       
            public function 
    onRun($tick)  {
            
    $this->plugin->min -= 1;
            if(
    $this->plugin->min 19)  {
                foreach(
    Server::getInstance()->getOnlinePlayers() as $player) {
                    
    $level $player->getLevel()->getName();
                        if(
    $level === "test" $this->plugin->start 1){
                           
    $player->sendMessage("§l§6[GAME] Finished in §9[".$this->plugin->min.":00] minutes");
                           }else{
                             
    $world $this->plugin->getServer()->getLevelByName("test");
                         if(
    $world instanceof Level){
                        
    $playersArena count($world->getPlayers());
                        if (
    count($playersArena) === $this->plugin->min 20) {
                                       }                     
                                  }
                         unset(
    $this->plugin->min);
                              unset(
    $this->plugin->timer);
                              unset(
    $this->plugin->zeit);
                              unset(
    $this->plugin->min);
                             }
                        }
                    }elseif(
    $this->plugin->min === 19) {
                     foreach(
    Server::getInstance()->getOnlinePlayers() as $player) {
                       
    $level $player->getLevel()->getName();
                           if(
    $level === "test"){
                            
    $player->sendMessage("§l§6[GAME] §3The Death-Match starting in §9[5:00] §3minutes !");
                    }
                  }
                }elseif(
    $this->plugin->min === 10) {
                    foreach(
    Server::getInstance()->getOnlinePlayers() as $player) {
                       
    $level $player->getLevel()->getName();
                          if(
    $level === "test"){
                            
    $player->sendMessage("§b[GAME §eThe Death-Match starting in  §9[5:00] §eminutes !!");
                    }
                }
            }elseif(
    $this->plugin->min === 5) {
                foreach(
    Server::getInstance()->getOnlinePlayers() as $player) {
                   
    $level $player->getLevel()->getName();
                      if(
    $level === "test"){
                         
    $player->sendMessage("§a[GAME] The Death-Match started !! good luck !!");
                         
    $player->teleport(new Vector3(-596103150));
            }
        }
        }elseif(
    $this->plugin->min === 0) {
        foreach(
    Server::getInstance()->getOnlinePlayers() as $player) {
                   
    $level $player->getLevel()->getName();
                      if(
    $level === "test"){
                        
    $player->sendMessage("§l§c[GAME] The GAME is finished !");               
                        
    $player->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn(), 00);
                        
    $name $this->plugin->cfg->get("reset_map");
                         if (!
    $this->plugin->getServer()->getLevelByName($name) instanceof Level) {
                               
    $this->plugin->getServer()->unloadLevel($name);
                                    
    $this->deleteDirectory($this->plugin->getServer()->getDataPath() . "/worlds/" $name);
                                    
    $this->copymap($this->plugin->getDataFolder() . "/maps/" $name$this->plugin->getServer()->getDataPath() . "/worlds/" $name);
                                    
    $this->plugin->getServer()->loadLevel($name);
                                     
    $tiles $this->plugin->getServer()->getLevelByName("hub2")->getTile(new Vector3(614114));
                                      if(
    $tiles instanceof Sign){
                                      if ((
    $world $this->plugin->getServer()->getLevelByName("test"))){
                                       
    $count count($world->getPlayers());
                                        if(
    $this->zeit 60 $this->gameStarted === true){
                                        
    $tiles->setText("§l§6[GAME]""§l§JOIN !""[$count/8]""test");
                                        
    $world->loadChunk();
                                        
    $this->refreshSign();
                                    }
                                 }
                              }

                              unset(
    $this->plugin->min);
                              unset(
    $this->plugin->timer);
                              unset(
    $this->plugin->zeit);
                              unset(
    $this->plugin->min);

                           }
                        }
                    }
                 }
             }
      

           public function 
    copymap($src$dst) {
            
    $dir opendir($src);
            @
    mkdir($dst);
            while (
    false !== ( $file readdir($dir))) {
                if (( 
    $file != '.' ) && ( $file != '..' )) {
                    if (
    is_dir($src '/' $file)) {
                        
    $this->copymap($src '/' $file$dst '/' $file);
                    } else {
                        
    copy($src '/' $file$dst '/' $file);
                    }
                }
            }
            
    closedir($dir);
        }

        public function 
    deleteDirectory($dirPath) {
            if (
    is_dir($dirPath)) {
                
    $objects scandir($dirPath);
                foreach (
    $objects as $object) {
                    if (
    $object != "." && $object != "..") {
                        if (
    filetype($dirPath DIRECTORY_SEPARATOR $object) == "dir") {
                            
    $this->deleteDirectory($dirPath DIRECTORY_SEPARATOR $object);
                        } else {
                            
    unlink($dirPath DIRECTORY_SEPARATOR $object);
                        }
                    }
                }
                
    reset($objects);
                
    rmdir($dirPath);
            }
        }
    }
           

    Attached Files:

  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    $this->plugin->min is undefined. Also, Server::getInstance().. Anyone that taught you that - He cannot code(well). That's a very bad practice.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The worst practice here is the namespace. Namespace game is too generic and is very likely to be duplicated.
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    The namespace should always include the nameoftheplugin the path to the phpfile and theclassname
    Mine are always like that:
    ServerCore/ServerCore/DataHandlers/MyClassName

Share This Page

Advertisement