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

DevTools: makeplugin Fails to Create a .phar

Comments in 'Plugin Development' started by Lafoog, Aug 13, 2014.

  1. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    Hello!

    I am new to coding in general and PHP specifically, and I need some help.

    I have downloaded DevTools, but I can not compile anything to a .phar file.

    All I have done is literally copy and paste ShoghiCP's example program into a php editor, save it as exampleplugin.php, and try to run the command "makeplugin exampleplugin" from the server console. I get the following error message, no matter what I do: "Invalid plugin name, check the name case."

    I have tried renaming, restarting, and everything that other threads have suggested. And yes, I have checked the case.


    EDIT: If you are a noob like me, please read the below.

    You can't just convert a .php file to a .phar. You have to have a folder set up with different elements of the plugin inside it. Visit http://pocketmine-mp.readthedocs.org/en/latest/plugins.html to see how to do this.

    only afterwards can you run makeplugin <pluginname>
    Last edited: Aug 13, 2014
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Is your plugin loaded?
  3. D_ART
    Offline

    D_ART New Member

    Joined:
    Aug 12, 2014
    Posts:
    1
    Minecraft User:
    D_ART
    I have same problem with DevTools. It doesn't want to pack anything extracted plugin.
    For example, I write into server console:
    Code:
    /extractplugin SimpleAuth
    After write this without changes:
    Code:
    /makeplugin Simple Auth
    And getting it:
    Code:
    [INFO] Plugin SimpleAuth is not in folder structure
  4. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    I can't load it if I can't compile it, or am I wrong?

    Can you tell me, step by step, how you make it work for you? I have a feeling i'm making a noob mistake.

    Edit: If the plugin isn't in phar format, how am I supposed to load it into Pocketmine?
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Well, you have to understand the structure of DevTools.

    DevTools has a feature called FolderPluginLoader. The default phar loader loads phar files in the plugins folder. FolderPluginLoader loads folders in the plugins folder, not from the DevTools folder.
    DevTools extracts plugin to the DevTools folder, so it is not in the plugins folder (not directly). The /makeplugin command compiles plugins that are LOADED by FolderPluginLoader into phar files. So, since in your case your edited version isn't loaded at all (but the phar file is loaded; you have to move it away), it won't compile. You need to load it to compile it, and you need to put folder plugins in the plugins folder.
  6. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Ok, let's clear somethings...
    1. To load the source code of a plugin, you must put the source inside a folder, and that folder inside the plugins/ folder, so you can get something like:
      Code:
      plugins/SimpleAuth/plugin.yml
    2. When you extract the source code of a plugin, it will be saved on plugins/DevTools/
    3. You must be sure that the server load your plugin and when using /makeplugin you should provide the exact name of the plugin you want to compress (if not compressed into a PHAR)
    PEMapModder likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    FolderPluginLoader loads folder plugins, so you have to remove or move away the phar file to avoid duplication. Then you have to move the folder to the plugins folder.
    iksaku likes this.
  8. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    Yes, I have the test plugin in the plugins folder as a raw .PHP file.
    But what if the plugin isn't in .YML format? Mine is in .PHP. I apologize for being stupid :/
  9. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    for the NEW API you should have a file named plugin.yml in order to load your plugin...
  10. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    What? so all I have to do is change the extension to YML?

    so it's like this : pocketmine/plugins/test/test.yml

    and then run makeplugin test ????


    Because it still doesn't work. I get the same error message that it is an "invalid plugin name"
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No.

    As @iksaku said, it only compiles loaded plugins, and they are loaded by the folder plugin loader.
  12. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    Dude, I figured it out!

    Thanks for helping out a new guy. Now to learn PHP!
    64FF00 and PEMapModder like this.
  13. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    Argh! Sorry man, I need more help. I thought I had it working, but it just crashes the server.

    When I attempt to start the server to load my plugin, Pocketmine crashes with the error:
    20:40:11 [ERROR] An E_ERROR error happened: "Autoloader couldn't find a file to include for Plugin" in "/src/spl/SplClassLoader" at line 156

    20:40:11 [EMERGENCY] An unrecoverable error has occurred and the server has crashed. Creating a crash dump


    Here is my plugin.yml
    name: testplugin
    main: testplugin\main
    version: 1.0.0
    api: [1.0.0]

    Attached is my main.php
    It is ShoghiCP's example plugin, slightly modified


    Here is how I have the folders arranged

    /plugins
    / /testplugin
    / / /src
    / / /plugin.yml
    / / / /testplugin
    / / / / /main.php


    The only error I can think of is either a .yml mess-up or a glitch : ( Any help would be appreciated

    Oh, yeah. My pocketmine version is Alpha 1.4 Dev, API 1.2.0

    Attached Files:

    • main.php
      File size:
      598 bytes
      Views:
      23
    Last edited: Aug 13, 2014
  14. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    You should provide the Main file name exactly on plugin.yml if the class is named "Main" you should put it on plugin.yml as Main not main
  15. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    Good thing i got safari download manager i saw your main.php and its "OutDated" as in you need to learn the "New API" format. Here is an example on how it should look.

    PHP:
    <?php

    namespace Yourname\pluginname;

    use 
    blah\blah;

    Class 
    example extends PluginBase

    public function OnEnable() {

    //some more code here is an example

    $this->getLogger("Here is your message");

    //dont forget to end the code with the curly bracket

    public function OnDisable() {

    // code :D

    }

    // your main code

    //end in two curly brackets

    }

    }

    //indent with tab I made this with my iphone


    Some one feel free to copy and paste and make fix any thing i did wrong. ;)

    Here is also the pocketmine docs lol it may help you :p : docs.pocketmine.net
    64FF00 likes this.
  16. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    Oh dang dude! Thanks a ton! If you couldn't tell, I am completely new to PHP and haven't gotten past the copy and paste stage yet : P
    64FF00 likes this.
  17. Lafoog
    Offline

    Lafoog New Member

    Joined:
    Aug 13, 2014
    Posts:
    9
    Minecraft User:
    Lafoog
    That fixed it. Man, they should make the documentation more newbie-friendly!
  18. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    Dont worry you can use the code above to help you out ;).
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That doesn't affect.
    64FF00 likes this.
  20. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    There's a plugin example for newbie developers, and if you understand the basics of PHP, you can understand the PocketMine API with the current (partial) documentation ;)
    PluginMastered likes this.

Share This Page

Advertisement