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

Crash in relation with the config.yml file

Comments in 'Plugin Development' started by LoveToBeDev, Aug 19, 2015.

  1. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Hello Guys, my console Crashes when i execute a command in the game, the command interacts with the config.yml, and it is to set a position, and the error code is here:
    and the code is here:
    PHP:
     $spawn $sender->getPosition();
                        
    $sender->getConfig()->set("spawn"$spawn);
                        
    $this->getConfig()->save();
    it says that the problem is here:
    PHP:
    $sender->getConfig()->set("spawn"$spawn);
    and the config.yml is like this:
    PHP:
    ---
    spawn0
    positioncero
    0
    thanks for helping guys.
    Last edited: Aug 19, 2015
  2. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    $sender->getConfig() should be replaced with $this->getServer()->getConfig()
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You shouldn't save objects with YAML.
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    I think you should learn the PocketMine API better.
    In your code $sender is a Player instance and the PocketMine Player class doesn't have a method called getConfig(). This is the reason why your plugin crashes.
    PEMapModder and jojoe77777 like this.
  5. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    What does the server have to do with a config file? o_O
    PEMapModder likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    How do you know getServer() return an object without a getConfig function? :p

Share This Page

Advertisement