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

Base Loader

Discussion in 'Development' started by RinkuPlugins, Nov 4, 2017.

  1. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    I have one made one and now I think because of changes of Api ant etc it won't work I've reaserched alot

    PHP:
    <?php
    namespace Mega\Sys;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;

    class 
    Ver extends PluginCommand {
        
    /** @var Main $plugin */
           
    private $plugins;
        public function 
    __construct(Main $plugins){
            
    parent::__construct("SysVer""Display Ver"null, ["Sys"]);
            
    $this->plugins $plugins;
            
    $this->setPermission("mega.sys.ver");
        }
        public function 
    execute(CommandSender $sender$currentAlias, array $args){ // will be done by running the command
          
    foreach($this->plugin->getServer()->getOnlinePlayers() as $player){
          
    $player->sendMessage("1.2.3 pmmp api.. \n MegaSys Ver 1.5 alpha");
        }
      }
     
        public function 
    getPlugins(): BaseCommand{
    return 
    $this->plugins;
    }
    }
     
  2. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    • You can't even wait for 15 minutes?
    Bump!
     
  3. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    My issue is with PluginIdentifiableCommand
     
    Daniel23 likes this.
  4. Daniel23

    Daniel23 Witch

    Messages:
    65
    GitHub:
    daniel23
    Send the issue from the console
     
  5. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    PHP:
    public function getPlugins(): BaseCommand{
        return 
    $this->plugins;
    }
    What even is that. Your PHPDoc says it's an instance of Main, yet you're returning BaseCommand.

    But did you register the command to the command map?
     
    Last edited: Nov 4, 2017
    Sandertv likes this.
  6. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    I' sending
     
  7. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    ParseError: "syntax error, unexpected 'class' (T_CLASS), expecting ',' or ';'" (EXCEPTION) in "PluginName/src/Mega/Sys/Ver" at line 9
     
  8. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    And yes it' registerd
     
  9. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    I changed my code
     
  10. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    PHP:
    <?php
    namespace Mega\Sys;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\command\PluginIdentifiableCommand;

    class 
    Ver extends Command implements \pocketmine\command\PluginIdentifiableCommand {
        
    /** @var Main $plugin */
           
    private $plugin;
        public function 
    __construct(Main $plugin){
            
    parent::__construct("sysver""Display Ver"null, ["sys"]);
            
    $this->plugin $plugin;
            
    $this->setPermission("mega.sys.ver");
        }
        public function 
    execute(CommandSender $sender$currentAlias, array $args){ // will be done by running the command
          
    foreach($this->plugin->getServer()->getOnlinePlayers() as $player){
          
    $player->sendMessage("1.2.3 pmmp api.. \n MegaSys Ver 1.5 alpha");
        }
      }
     
        public function 
    getPlugin(): BaseCommand{
    return 
    $this->plugin;
    }
    }
     
  11. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    PluginIdentifiableCommand::getPlugin() should return an instance of Plugin. Why are you returning it as BaseCommand when you aren't using it. I smell copy and pasted code without knowledge of how it works, so here let me give you a little insight.

    Make sure you are providing an instance of Main when constructing Ver.

    This is what your command class should look like:
    PHP:
    <?php

    namespace Mega\Sys;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\command\PluginIdentifiableCommand;

    class 
    Ver extends Command implements PluginIdentifiableCommand {

        
    /** @var Main $plugin */
        
    private $plugin;

        public function 
    __construct(Main $plugin) {
            
    parent::__construct("sysver""Display Ver"null, ["sys"]);
            
    $this->plugin $plugin;
            
    $this->setPermission("mega.sys.ver");
        }


        public function 
    execute(CommandSender $sender$currentAlias, array $args){ // will be done by running the command
            
    foreach($this->getPlugin()->getServer()->getOnlinePlayers() as $player){
                
    $player->sendMessage("1.2.3 pmmp api.. \n MegaSys Ver 1.5 alpha");
            }
        }

        public function 
    getPlugin(): Plugin {
            return 
    $this->plugin;
        }
    }

    Here's what your registration should look like if you are registering from your class that extends PluginBase(I'm 99.9% sure that it's your Main class):
    PHP:
    $this->getServer()->getCommandMap()->register("exampleFallbackPrefix", new Ver($this));
     
  12. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    Still won' work there' a error with the extends and implements
     
  13. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    What's the error? Can I see your updated code?
     
  14. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
  15. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
  16. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
  17. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Just reread the error, and I think you're missing a semi-colon after your namespace.
     
  18. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    I don't I just checked it has a semicolon
     
  19. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Send your code.
     
  20. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    Must be this one
     

    Attached Files:

  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.