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

loader class Sos

Comments in 'Plugin Development' started by rinkuno, Jul 19, 2016.

  1. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    how can I make a loader class for my plugin
  2. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    PocketMine-MP already has one. You should update your plugin from the old API to the new one.
    You may show us the console?
  3. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Like multiple command classes how can I do that
  4. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    ps my plugin is new api
  5. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Here's an example :p

    \PocketMine\plugins\PluginName\plugin.yml
    PHP:
    namePluginName
    version
    1.0.0
    api
    : [2.0.0]
    mainAuthorName\PluginName\Main
    author
    Survingo

    permissions
    :
    pluginname.command.info:
      
    description"Allows using command"
      
    default: true
    \PocketMine\plugins\PluginName\src\AuthorName\PluginName\Main.php
    PHP:
    <?php
    namespace AuthorName\PluginName;

    use 
    pocketmine\plugin\PluginBase;

    class 
    Main extends PluginBase {

        public function 
    onEnable(){
        
    $this->getServer()->getLogger()->info("Plugin enabled!");
    $this->getServer()->getCommandMap()->register("command-name", new CommandNameClass($this));
        }
    }
    \PocketMine\plugins\PluginName\src\AuthorName\PluginName\CommandNameClass.php
    PHP:
    <?php
    namespace AuthorName\PluginName;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    class 
    CommandNameClass extends Command implements \pocketmine\command\PluginIdentifiableCommand {
        
    /** @var Main $plugin */
           
    private $plugin;
        public function 
    __construct(Main $plugin){
            
    parent::__construct("command-name""description"null, ["aliases"]);
            
    $this->plugin $plugin;
            
    $this->setPermission("pluginname.command.info");
        }
        public function 
    execute(CommandSender $sender$currentAlias, array $args){ // will be done by running the command
    foreach($this->plugin->getServer()->getOnlinePlayers() as $player){
    $player->sendMessage("hi");
    }
    }
    }
    applqpak and Primus like this.
  6. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Where do I add the command As line
  7. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    [09:04:38] [Server thread/CRITICAL]: Could not load plugin 'PluginCustom'
  8. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Ah, I think I got it. I forgot getPlugin() function in CommandNameClass because of the PluginIdentifiableCommand :p
    Here's source code if you want it to run and edit it, just extract it in your plugins folder

    Attached Files:

  9. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Won't work same error
  10. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Please show us the complete console from start to error
  11. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    There

    Attached Files:

  12. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Why are you not using PocketMine-MP? We are a community of PocketMine and not copycats
    applqpak likes this.
  13. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Cus it's buggy
  14. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Ok I'll switch
  15. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    You should make a space at plugin.yml before plugin.opme:
    And class MainBase extends PluginBase{ remember in plugin.yml the main: name
    and also remember in your OP.php Command the aliases. If someone would run the command aliases he would run opme
  16. Yeelze
    Offline

    Yeelze New Member

    Joined:
    Apr 2, 2016
    Posts:
    31
    Minecraft User:
    Yeelze
    So you are asking for PocketMine API code and then you try to do it with another software because its buggy.
    ok
    applqpak and Survingo like this.
  17. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Line 7 in MainBase.php, Main should be MainBase. Line 10 in OP, Main should be MainBase too.
    Survingo likes this.
  18. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    I get the Unknown command error
  19. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Means you are registeing an other command and you're running an other one.
  20. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    You don't use multiple classes for commands for no reason. The onCommand() function in the main class is good enough unless you have like hundreds of lines of code to manage, or if you need some hierarchical relationship between different commands.
    Blabla, applqpak and Survingo like this.

Share This Page

Advertisement