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

Config Troubles

Comments in 'Plugin Development' started by CrazedMiner, Jun 16, 2015.

  1. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    I'm trying to get data from a config and I keep getting this Warning and I have no idea what I'm doing wrong...

    Code:
    PHP:
    public function __construct(Main $main) {
            
    $this->plugin $main;
        }
      
        public function 
    onJoin(PlayerJoinEvent $event) {
            
    $config $this->plugin->getConfig()->getAll();
            
    $player $event->getPlayer();
            
    $message $config["Join"]["Popup"]["Public-Popup-Text"];
            
    $duration $config["Join"]["Popup"]["Public-Popup-Duration"];
            
    $this->plugin->schedulePopup($playerstr_replace("@player"$player->getName(), $message), $duration);
        }
    Error/Warning:
    Code:
     
    [18:56:04] [Server thread/WARNING]: RuntimeException: "yaml_parse(): end of stream reached without finding document 0" (E_WARNING) in "/src/pocketmine/utils/Config" at line 143
    [18:56:04] [Server thread/INFO]: CrazedMiner joined the game
    
    
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Did you save the default configuration file correctly?
    PHP:
    @mkdir($this->getDataFolder());
    $this->saveDefaultConfig();
    CraftYourBukkit likes this.
  3. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Yup

    Main.php
    PHP:
    public function onEnable() {
            @
    mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->getServer()->getPluginManager()->registerEvents(new Events\Join($this), $this);
        }
    Join.php
    PHP:
    public function __construct(Main $main) {
            
    $this->plugin $main;
        }
      
        public function 
    onJoin(PlayerJoinEvent $event) {
            
    $config $this->plugin->getConfig()->getAll();
            
    $player $event->getPlayer();
            
    $message $config["join"]["popup"]["public-popup-text"];
            
    $duration $config["join"]["popup"]["public-popup-duration"];
            
    $this->plugin->schedulePopup($playerstr_replace("@player"$player->getName(), $message), $duration);
        }
    Config.yml
    Code:
    ---
    join:
        popup:
            public-popup-enabled: true
            public-popup-text: "&l&[email protected]&r has &bjoined&r the TakeTwo Network!"
            public-popup-duration: 6
    ...
    
    Error
    Code:
    [19:50:27] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'TakeTwo-Core-v1 v': Undefined index: join on TakeTwo\Events\Join
    [19:50:27] [Server thread/NOTICE]: ArrayOutOfBoundsException: "Undefined index: join" (E_NOTICE) in "/TakeTwo-Core-v1/src/TakeTwo/Events/Join" at line 19
    
    
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Don't use $config. Use another like $cfg instead
    CrazedMiner likes this.
  5. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Sa
    same error .-.
    Code:
    [20:39:43] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'TakeTwo-Core-v1 v': Undefined index: join on TakeTwo\Events\Join
    [20:39:43] [Server thread/NOTICE]: ArrayOutOfBoundsException: "Undefined index: join" (E_NOTICE) in "/TakeTwo-Core-v1/src/TakeTwo/Events/Join" at line 19
    
    
  6. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Very strange.
    Try to var dump the config:
    PHP:
    var_dump($cfg);
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Your config is empty.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    There is no difference for these local variables...
  9. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    No it isn't....

Share This Page

Advertisement