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

Plugin API Suggestions

Comments in 'Plugin Development' started by jython234, Mar 10, 2015.

  1. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Hey everyone,

    As you may or not know, I'm working on BlockServer and PocketBukkit, alternate MCPE server software written in Java. PocketBukkit is an API wrapper for BlockServer, while BlockServer is the core of the server. @PEMapModder and I would like to see ideas for our API to implement, maybe some things that are too late to change in PocketMine. I know this is getting a little astray from the idea of PHP, but It is Plugin/API related, and I would like to keep this on topic as much as possible. Don't be afraid to share your ideas, some may be implemented!

    Visit our github.

    Thanks guys!
    - jython234
  2. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    BTW, I just finished simple JavaScript plugin support. It looks like this:
    Code:
    /***
    name: ExamplePlugin
    version: 1.0-SNAPSHOT
    mainClass: ExamplePlugin
    */
    var plugin = null;
    
    function init(wrapper){
        plugin = wrapper;
    }
    
    function onEnable(){
        plugin.getLogger().info("I've been enabled!");
    }
    
    function onDisable(){
        plugin.getLogger().info("I've been enabled!");
    }
    If you have any suggestions, please comment below.
  3. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    Would this take people away from PocketMine?
  4. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    372
    Plugins:
    3
    Minecraft User:
    Dutok
    It won't - PocketMine will probably always be the top Pocket Edition server implementation because it's stable and pretty much the only one.

    Anyways, competition is always good because then we get better products from both sides. :)
  5. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    372
    Plugins:
    3
    Minecraft User:
    Dutok
    That seems very cool. Can you give us some more details, please?
    iksaku likes this.
  6. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    Java is my main coding language! Can't wait for this :D
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Actually, we are looking for ideas on improvements in the plugin API. As some developers may feel, PocketMine is actually not perfect at its plugin API. There may be some limitations. Nevertheless, it is too late to change on PocketMine. I am going to start working on PocketBukkit global API (we will support different types of plugins in PocketBukkit, from Bukkit plugins to JavaScript plugins (but not PHP :p) by different APIs, and we combine these APIs using a global API) soon, and I would like to listen to the community about different things before we actually start. We particularly want to know about different opinions on designing the structure of the event API, as it is something that cannot be changed once it is started (unless we rewrite). Please stay on-topic. We thank you all for your valuable opinions.
    RekkuzaRage and jython234 like this.
  8. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Well, as @PEMapModder said, we should stay on topic. But, I will give some information on how this works. First of all, you create a new javascript file in the "plugins" folder. The first line MUST be "/***". The next required items are the plugin's name, version, and main class (not needed right now, just put something random). For example:
    Code:
    /***
    name: HelloPlugin
    version: 1.0
    mainClass: PutSomethingRandomHere
    */
    Make sure to end that section with "*/". After that you will need 3 javascript functions: init, onEnable, and onDisable. Init takes one argument, a JavaScriptPlugin object. Because of how oracle's script engine works, you can access java classes from the javascript file. Pretty cool huh? Anyway, you should store that object in a variable that you would use (that variable is the key to the entire API). A finished plugin would look something like this:
    Code:
    /***
    name: ExamplePlugin
    version: 1.0-SNAPSHOT
    mainClass: ExamplePlugin
    */
    var plugin = null;
    
    function init(wrapper){
        plugin = wrapper;
    }
    
    function onEnable(){
        plugin.getLogger().info("I've been enabled!");
    }
    
    function onDisable(){
        plugin.getLogger().info("I've been enabled!");
    }
    You can look at the pocketbukkit docs here.
    PEMapModder likes this.
  9. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    372
    Plugins:
    3
    Minecraft User:
    Dutok
    That's really cool. Great job. :)
    PEMapModder likes this.
  10. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    If anyone wants to try it out, head over to http://builds.blockserver.org and use the guest account. Select the PocketBukkit project, find the latest build and click on artifacts. Download the jar, and try it out for yourself :).
    Falk likes this.
  11. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    252
    Minecraft User:
    RekkuzaRage
    This global API is very interesting. I think it is a great idea. Especially for people who know Java or JavaScript.
    PEMapModder and jython234 like this.

Share This Page

Advertisement