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

Solved I have a problem with plugin implementation...

Discussion in 'Development' started by 7awariGamer, Apr 18, 2020.

  1. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Fatal error: Class com\MCBE\MCommand contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (pocketmine\command\PluginIdentifiableCommand::getPlugin) in /storage/emulated/0/PocketMine-MP/plugins/PVPHUD-7Wdev/src/com/MCBE/MCommand.php on line 20
    PHP:
    <?php
    namespace com\MCBE;

    //pmmp libs!
    use pocketmine\command\PluginIdentifiableCommand;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\utils\CommandException;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;
    use 
    pocketmine\event\server\ServerCommandEvent;
    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\utils\TextFormat as C;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\player\PlayerQuitEvent as Disconnect;

    //mine libs!
    use com\MCBE\Main;
    use 
    com\MCBE\MTask;

    class 
    MCommand extends Command implements PluginIdentifiableCommand {

        private 
    $command;

        public function 
    __construct(Main $plugin)
          {
             
    $cmd Main::$cfg->get('cmd');
             
    parent::__construct($cmd"displays pvp hud!""/" $cmd, []);
             
    $this->setPermission("pvphud.command");
             
    $this->command $plugin;
          }

        public function 
    execute(CommandSender $senderstring $commandLabel, array $args)
          {
             if(
    $sender instanceof Player)
              {
                 
    $task = new MTask($this$sender);
                 
    $this->command->getServer()->getScheduler()->scheduleRepeatingTask(task40);
              } else
                  {
                     
    //nothing ...
                  
    }
          }
        
        public function 
    onDisconnect(Disconnect $e)
          {
             
    $e->getPlayer()->cancelMTask();
          }
    }
    ?>
     
  2. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    You have to add this function:
    PHP:
    public function getPlugin() : Plugin{
        return 
    $this->plugin;
    }
    As seen by the error above:
    Hope this helped :D
     
  3. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    I did this before and got an error, this func isn't returning Plugin
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    In your case, the property that references your plugin is command (which is a hella confusing name, I recommend going with plugin instead)
     
  5. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Also this didn't work, anyway I fixed the code it had many mistakes thank you
     
    HimbeersaftLP likes 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.