Where to place php file for devtools

Discussion in 'Plugin Help' started by Sebastiaan, Feb 8, 2017.

  1. Sebastiaan

    Sebastiaan Creeper

    Messages:
    4
    GitHub:
    srvreeswijk
    I've downloaded and successfully added the devoots plugin to my minecraft-pe server.
    Now I want to convert and downloaded plugin in php format to an phar file.

    From what I understand I need to use the makeplugin command.
    Only it says: Invalid plugin name, check the name case.
    What am I doing wrong?
    I tried to place the plugin in:
    minecraft/plugins
    minecraft/plugins/devtools
    minecraft/src/plugins
     
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    913
    GitHub:
    edwardhamham
    A plugin for PocketMine requires more than just a single php file. It requires a plugin.yml file with the required information written in, along with a special folder structure. The plugin you downloaded is most likely an extremely outdated plugin for the old PocketMine API. May I ask what plugin it was, and where you downloaded it from?
     
  3. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    620
    GitHub:
    JackNoordhuis
    It could be a script plugin.
     
  4. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    913
    GitHub:
    edwardhamham
    Oh, didn't think about that.
     
  5. Sebastiaan

    Sebastiaan Creeper

    Messages:
    4
    GitHub:
    srvreeswijk
    I'm completely new in this and just started setting up an server for my kids.
    This is the file:
    PHP:
    <?php

    class DisableTNT implements Plugin{
        private 
    $api;
        public function 
    __construct(ServerAPI $api$server false){
            
    $this->api $api;
        }
        
        public function 
    init(){
            
    $this->api->addHandler("player.block.action", array($this"handle"), 15); //Priority higher that API
            
    $this->api->addHandler("player.equipment.change", array($this"handle"), 15);
        }
        
        public function 
    __destruct(){
        
        }
        
        public function 
    handle(&$data$event){
            switch(
    $event){
                case 
    "player.equipment.change":
                    if(
    $data["block"] === 46){
                        
    $this->api->player->getByEID($data["eid"])->eventHandler("[DisableTNT] By DemonKingz""server.chat");
                        
    $data["block"] = 0;
                        
    $data["meta"] = 0;
                    }
                    break;
                case 
    "player.block.action":
                    if(
    $data["block"] === 46){ //no u won't
                        
    $data["block"] = 0//wtf it's a secret LOL
                        
    $data["meta"] = 0;
                    }
                    break;
            }
        }

    }
    I'll RTFM first about creating plugins.
    Creating an plugin.yml seems pretty straight foreward. I'll give that an try.
    Thanks for the help. This sets me in the right direction.
     
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,159
    GitHub:
    Thunder33345
    There a huge problem!
    I am sorry to tell you you learned the wrong version of PM API!
     
  7. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    465
    GitHub:
    InspectorGadget
  8. Sebastiaan

    Sebastiaan Creeper

    Messages:
    4
    GitHub:
    srvreeswijk
    So far I did not learn anything. I just found this on the internet and tried it.

    Thanks to you guys I already saw this.
    I will be fun to learn php and convert the one I have to the new api.
    I already know several languages and scripts. So this won't be a big problem.
    And this seems like a fun small plugin to start with.
     
  9. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,378
    GitHub:
    robske110
    If you want a really quick start you might want to try and create a script plugin:
    It might help you to get past the current mess with getting a devtools phar.
    PHP:
    <?php

    /**
     * @name YourPluginName
     * @main authorName\PluginName\MainClassName
     * @version 0.0.1
     * @api 3.0.0-ALPHA3
     * @description Much description.
     * @author authorName
     */


    namespace authorName\PluginName{

        use 
    robske_110\SPC\ScriptPluginCommands;
        use 
    robske_110\Utils\Utils;
        use 
    pocketmine\event\Listener;
        use 
    pocketmine\plugin\PluginBase;
        use 
    pocketmine\command\Command;
        use 
    pocketmine\command\CommandSender;

        class 
    PacketLogger extends PluginBase implements Listener{
          
            public function 
    onLoad(){
                
    $id ScriptPluginCommands::initFor($this);
                
    ScriptPluginCommands::addCommand($id, [
                    
    'name' => 'exampleCmd0',
                    
    'description' => 'somedesc',
                    
    'permission' => 'op'//Op only
                    
    'usage' => 'usage'
                
    ]);
                
    ScriptPluginCommands::addCommand($id, [
                    
    'name' => 'exampleCmd1',
                    
    'description' => 'ouputs sth to console',
                    
    'permission' => 'op'//Op only
                    
    'usage' => 'usage'
                
    ]);
                
    $this->getServer()->getCommandMap()->registerAll($this->getDescription()->getName(), ScriptPluginCommands::getCommands($id));
            }
          
            public function 
    onEnable(){
                
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            }
          
            public function 
    onDisable(){
                
    //Disable code
            
    }
          
            public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
                switch(
    $command->getName()){
                    case 
    "exampleCmd0":
                        
    //blah
                        
    return true;
                    break;
                    case 
    "exampleCmd0":
                        
    $this->getLogger()->info("much test");
                        return 
    true;
                    break;
                }
            }
        }
    }
    /** LIBARIES */
    namespace robske_110\SPC{
        use 
    pocketmine\command\PluginCommand;
        use 
    pocketmine\Plugin\Plugin;
        use 
    robske_110\Utils\Utils;
      
        
    /**
         * @author robske_110
         * @version 0.1.2-php7
         */
        
    abstract class ScriptPluginCommands{
            private static 
    $plugins;
          
            public static function 
    initFor(Plugin $plugin) : int {
                
    self::$plugins[] = [$plugin];
                return 
    count(self::$plugins) - 1;
            }
          
            public static function 
    addCommand(int $id, array $data){
                if(!isset(
    self::$plugins[$id])){
                    
    Utils::critical("addCommand() has been called with an unkown ID!");
                }
                
    $cmd = new PluginCommand($data["name"], self::$plugins[$id][0]);
                if(isset(
    $data["description"])){
                    
    $cmd->setDescription($data["description"]);
                }
                if(isset(
    $data["usage"])){
                    
    $cmd->setUsage($data["usage"]);
                }
                if(isset(
    $data["permission"])){
                    
    $cmd->setPermission($data["permission"]);
                }
                if(isset(
    $data["aliases"]) && is_array($data["aliases"])){
                    
    $aliases = [];
                    foreach(
    $data["aliases"] as $alias){
                        
    $aliases[] = $alias;
                    }
                    
    $cmd->setAliases($aliases);
                }
                
    self::$plugins[$id][1][] = $cmd;
            }
          
            public static function 
    getCommands(int $id) : array {
                if(!isset(
    self::$plugins[$id])){
                    
    Utils::critical("getCommands() has been called with an unkown ID!");
                }
                return 
    self::$plugins[$id][1];
            }
        }
    }
     
  10. Sebastiaan

    Sebastiaan Creeper

    Messages:
    4
    GitHub:
    srvreeswijk
    Thanks guys.

    I've succesfully made my first plugin.
    I'll add the funcionallity I need and put it on my server.
    Thanks for all the help.
     

Share This Page

  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.