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

Solved Need help with config

Comments in 'Plugin Development' started by cake23, Feb 11, 2016.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    I will write a feedback plugin..
    PHP:
    public function onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            @
    mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->reloadConfig();
        }
       
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args) {
            if(
    $command->getName() === "feedback" && isset($args[0])) {
                
    $name $sender->getName();
                
    $this->getConfig()->set("Name: ".$name);
                
    $this->getConfig()->set("Feedback: ".$args[0]);
                
    $this->getConfig()->save();
            }
        }
    But I get this error:
    Code:
    [15:56:52] warning> RuntimeException: "yaml_parse(): end of stream reached without finding document 0" (E_WARNING) in "/src/pocketmine/utils/Config" at line 148
    Does anyone know why? ._.
    Thanks!
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You have an empty config.yml
    cake23 likes this.
  3. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Yes..? Is it wrong to have an empty config? What should be in the config? :eek:
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    At least put these:
    Code:
    ---
    ...
    Otherwise, YAML will throw an exception because it found an entirely empty document that it cannot even find anything that suggests that it might be a YAML file.
    PocketKiller and cake23 like this.
  5. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Thanks! But now I get this error :/
    Code:
    [18:10:38] system> Enabling FeedbackPlugin v1.0.0
    [18:10:38] notice> InvalidArgumentException: "Argument 1 passed to pocketmine\utils\Config::setDefaults() must be of the type array, null given, called in phar://C:/Users/allesklar/Desktop/Minecraft PE/PocketMine_Plugins/Test-Server/PocketMine-MP.phar/src/pocketmine/plugin/PluginBase.php on line 266 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/utils/Config" at line 419
    [18:10:38] system> Disabling FeedbackPlugin v1.0.0
    
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You expect an empty array in your YAML?
    Maybe you should put this:
    Code:
    --- []
    ...
    This is what yaml_emit([]) would generate.
    cake23 likes this.
  7. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Thank you! <3 :D

Share This Page

Advertisement