1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help with a crashdump

Discussion in 'Plugin Help' started by MCAMD, Sep 14, 2018.

  1. MCAMD

    MCAMD Creeper

    Messages:
    3
    GitHub:
    elwakilz
    PHP:
    namespace AdminFun\commands;
     
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\CommandExecutor;
    use 
    AdminFun\AdminFun;

    abstract class 
    BaseCommand extends PluginBase implements CommandExecutor{

        public 
    $plugin;

        public function 
    __construct(AdminFun $plugin){
            
    $this->plugin $plugin;
        }

        public final function 
    getPlugin(){
            return 
    $this->plugin;
        }
    Help me with this code
    That caused server crash
     
  2. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Replace PluginBase with PluginCommand but make sure to call the parent constructor, too.

    (On a side note, this also makes
    PHP:
    $this->plugin $plugin;
    redundant, since you could just use
    PHP:
    $this->getPlugin()
    to access your plugin object)
     
  3. MCAMD

    MCAMD Creeper

    Messages:
    3
    GitHub:
    elwakilz
    How to call a parent constructor please xplain i am still beginner
     
  4. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Your class should look more or less like this:
    PHP:
    namespace AdminFun\commands;
     
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\command\PluginCommand;

    abstract class 
    BaseCommand extends PluginCommand implements CommandExecutor{

    }
    That might seem too empty, but that's totally fine. Look at this example command extending your base command:

    PHP:
    namespace AdminFun\commands;

    use 
    AdminFun\AdminFun;

    class 
    ExampleCommand extends BaseCommand {

        public function 
    __construct(AdminFun $plugin){
            
    parent::__construct("example"$plugin);
        }

        
    // Inside this class, you can now use $this->getPlugin()
    }
    Here's the origin of ExampleCommand->getPlugin()
     
    Awzaw and Muqsit like this.
  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.