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

How to load other plugin

Comments in 'Plugin Development' started by AndrewBit, Oct 9, 2015.

  1. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I have a plugin called 'PlayerLanguage' that detect player language, now I need know how to load info from this plugin, because I want say to other plugins what the language of the player x)

    I want load a variable called $playerlang from the function onLogin


    *Sorry If I make too many questions today! I only do it because I'm working hardly in some things.
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    In your plugin base:
    PHP:
    ...
    /**
     * @param Player $player
     * @return string $language
     */
    public function getLanguage(Player $player){
       return 
    $this->languages[$player->getId()];
    }
    In other plugin:
    PHP:
    use AndrewBit\PlayerLanguage\Main;
    ...
    public function 
    PlayerJoinEvent(PlayerJoinEvent $event){
       
    $language $this->getServer()->getPluginManager()->getPlugin('PlayerLanguage')->getLanguage($event->getPlayer());
    }
    Not too sure if this would work though. You would have to see for yourself.
    AndrewBit likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Note that you cannot get a variable outside its function, other plugins or not. You can, however, get a class property, like $this->languages as @Lambo showed.
    Taha_The_Hacker, AndrewBit and Lambo like this.
  4. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Doesn't Language::getInstance() work too?
  5. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    No. You would have to implement that yourself.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Is there even a class called Language?
    Taha_The_Hacker likes this.

Share This Page

Advertisement