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

MultiLanguage plugin help me to finish it

Comments in 'Plugin Development' started by Driesboy1, May 16, 2016.

  1. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    hello

    i am working on a multi language plugin but there is 1 error and i cannot find the problem

    error:
    PHP:
    NoticeUndefined propertyMcrafters\MultiLanguage\Main::$data in /Users/Ronny/Desktop/v20/plugins/MultiLanguage-master/src/Mcrafters/MultiLanguage/Main.php on line 44
    [07:02:39] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'Test v1': Call to a member function get() on null on MCrafterss\test
    [07:02:39] [Server thread/CRITICAL]: Error: "
    Call to a member function get() on null" (EXCEPTION) in "/MultiLanguage-master/src/Mcrafters/MultiLanguage/Main" at line 44

    github page: https://github.com/BoxOfDevs/MultiLanguage
  2. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    Did you delete the event on line 44 ?
    Also are you missed the Case sensitive ?
    PHP:
    $this->data = new Config($this->getDataFolder()."Data.yml"Config::YAML, array());
    $this->saveResource("data.yml"); // Right here
    Also, where's your Data.yml file in your Resource folder ?
  3. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
  4. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    Why set/get something in Config with null ?
    The $player is Player, not Player's Name

    PHP:
    public function onJoin(PlayerJoinEvent $event){
            
    $event->getPlayer()->sendMessage(ML::getInstance()->Translate($event->getPlayer()->getName(), "testmessage"));
        }
    Also you shouldn't use PlayerJoinEvent, use PlayerLoginEvent.
    And get the Player's name in the function, not in the sendMessage.
    PHP:
    public function Translate(Player $player$messagebool $force false$issuer "none") : int{
                    
    $player $player->getName();
            if (
    $this->getPlayerLang($player) === "nl"){
                
    $this->NL->get($message);
            }
            if (
    $this->getPlayerLang($player) === "en"){
                
    $this->EN->get($message);
            }
            if (
    $this->getPlayerLang($player) === "fr"){
                
    $this->FR->get($message);
            }
            if (
    $this->getPlayerLang($player)=== "de"){
                
    $this->DE->get($message);
            }
        }
    Last edited: May 17, 2016
  5. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    Notice: Undefined property: pocketmine\event\player\PlayerJoinEvent::$getPlayer in /Users/Ronny/Desktop/v20/plugins/testplugin/src/Mcrafterss/test.php on line 18
    [07:00:24] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'Test v1': Call to a member function sendMessage() on null on MCrafterss\test
    [07:00:24] [Server thread/CRITICAL]: Error: "Call to a member function sendMessage() on null" (EXCEPTION) in "/testplugin/src/Mcrafterss/test" at line 18
  6. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    Oh yea sorry, check the code in edited post

Share This Page

Advertisement