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

Config File Help!!!!

Comments in 'Plugin Development' started by Mason Gareis, Jan 11, 2014.

  1. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    53
    Minecraft User:
    MasonLovesMCPE
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=ConfigTest
    description=Sends a message to a user
    version=1.0
    author=<your username>
    class=Send
    apiversion=10
    */

    class Send implements Plugin{
      private 
    $api;

      public function 
    __construct(ServerAPI $api$server false){
        
    $this->api $api;

      }

      public function 
    init(){
        
    $this->readConfig();
            
    $this->api->plugin->configPath($this);
      }
     
      public function 
    readConfig(){
     

    if (
    file_exists($this->api->plugin->configPath($this))) {
            
    $homepage file_get_contents($this->api->plugin->configPath($this));
            
    console ($homepage);
      }
      else {
      
    $arr = array('a' => 1'b' => 2'c' => 3'd' => 4'e' => 5);
        
    $this->path $this->api->plugin->createConfig($this, array((json_encode($arr))));
        
    $homepage file_get_contents($this->api->plugin->configPath($this));
            
    console ($homepage);
      };

    }
    public function 
    __destruct(){
      }
    }
    ?>


    1-11-2014 12-06-24 PM.png






    I don't know what i'm doing wrong!!!



    .
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I use this in the init to make the file:
    PHP:
    $this->config = new Config($this->api->plugin->configPath($this)."config.yml"CONFIG_YAML, array("contents","here");
    Then read the file like:
    PHP:
    $this->api->plugin->readYAML($this->api->plugin->configPath($this). "config.yml");
    And write:
    PHP:
    $this->api->plugin->writeYAML($this->api->plugin->configPath($this)."config.yml"$array_to_write);
  3. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    53
    Minecraft User:
    MasonLovesMCPE
    THANK YOU!!!!:):cool::p:D:rolleyes:
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    the configpath function is for finding the plugin's distributed folderr. It should be used for collecting the folder path unless you only want it to vreate a folder.
    Mason Gareis likes this.

Share This Page

Advertisement