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

how to use config to enable or disable public function

Comments in 'Plugin Development' started by amiremad, Jan 8, 2016.

Thread Status:
Not open for further replies.
  1. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    title says it all
  2. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Enable or disable public function? What do you mean? Really, I don't understand...
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    A public function is a class method, part of a class in object-oriented programming. It cannot be "enabled"/"disabled", because that doesn't make sense at all.
    I'm assuming that you are referring to a public Event function in a Listener class passed into PluginManager::registerEvents(). It is called an event handler in a listener class.
    Simply add
    PHP:
    if($this->isThisHandlerDisabled) return;
    in the first line of your event handler function.
  4. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    how to make config file step by step
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Method 1:
    PHP:
    $cfg $this->getConfig();
    $cfg->get("Whatever"); //Get something in config
    $cfg->set("Whatever"$value); //Set something in config
    Method 2:
    PHP:
    use pocketmine\utils\Config;

    public 
    $cfg//Make the property

    $this->cfg = new Config($this->getDataFolder() . "config.yml"Config::YAML, array());
    Last edited: Jan 8, 2016
    amiremad likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Instead of asking and looking for code, you should instead learn PHP and at least understand what a function is.
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You should add
    PHP:
    $cfg->save();
    as it otherwise wouldn't save the config.
Thread Status:
Not open for further replies.

Share This Page

Advertisement