config->get from Other class

Discussion in 'Plugin Help' started by NZSigourney, Aug 29, 2021.

  1. NZSigourney

    NZSigourney Silverfish

    Messages:
    16
    GitHub:
    BlackPMFury
    How to Get config from Main to other Class?
    Config wrote at function onEnable in Main
    $this->plugin->onEnable->config->get or This?

    PHP:
    Public function __construct(Main $plugin){
         
    $this->plugin $plugin;
    }

    Public function 
    onJoin(PlayerJoinEvent $ev){
        
    $name $ev->getName();
        
    $config $this->plugin->config->get($name);
    }
     
    minijaham likes this.
  2. Primus

    Primus Zombie Pigman

    Messages:
    703
    PHP:
    $otherObject = new OtherClass($config); // Pass it via constructor

    $otherObject->config = new $config// Assign it to object property
    This isn't even pocketmine related. Just look up PHP OOP, watch 5 min tutorial and you know all. Thank me later.
     
    Pinesolz and minijaham like this.
  3. NZSigourney

    NZSigourney Silverfish

    Messages:
    16
    GitHub:
    BlackPMFury
    Thanks! Love youh
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.