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

[Solved(i think)] Problem

Comments in 'Plugin Development' started by jython234, Nov 17, 2013.

  1. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    I am trying to make a multi-world plugin
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=JythonWorlds
    description=A multiple worlds plugin
    version=0.1
    author=jython234
    class=JythonWorlds
    apiversion=10
    */

    class JythonWorlds implements Plugin{
      private 
    $api;
      private 
    $worldFile;
      private 
    $worlds=array();


      public function 
    __construct(ServerAPI $api$server false){
      
    #TODO: Class init
      
    $this->api $api;
      }

      public function 
    loadWorldList(){
            
    $this->worldFile=fopen("worlds.lst"'r');
            while ((
    $line fgets($this->worldFile)) !== false) {
                
    $this->worlds[] = $line;
            }
            
    console("[JythonWorlds]: World list loaded.");
      }

      public function 
    init(){
      
    #TODO: Insert code to run when plugin is enabled here.
      #-----------------------------------------------------
      #console("Enabling ")
      
    $cwd=getCwd();
      
    console("[JythonWorlds]: CWD is"+$cwd);
      if(
    file_exists("JythonWorlds"){
         
      }
      else{
            
    console("[Jython Worlds]: Creating config directory...");
            
    mkdir("JythonWorlds");
        }
        
    chdir("plugins/JythonWorlds");
        if(
    file_exists("worlds.lst")){
            
    $this->loadWorldList();
        }
        else{
            
    $tmpFile=fopen("worlds.lst"'w');
            
    fclose($tmpFile);
            
    $this->loadWorldList();
        }
        
    $worldCount=count($this->$worlds)-1
        
    while(($currentWorld=0) < $worldCount){
            
    $this->api->levelApi->loadLevel($this->worlds[$currentWorld]);
            
    $currentWorld++;
        }
        
    console("[JythonWorlds]: All worlds loaded successfully.");
     
        }

      public function 
    __destruct(){
      
    #TODO: Insert code to run when plugin is disabled here.
      #------------------------------------------------------
      #console("Disabling ")
      
    }
    }
    ?>
    It won't let me change directories and it somehow fails at loading the file into the array.

    Please help!

    EDIT: I fixed the directory problem but it still won't work the array.

    EDIT: Problem fixed.

    - Jython234

Share This Page

Advertisement