working on my first plugin. Would like to kill any bad habbits early. Would someone check my code?

Discussion in 'Plugin Development' started by pmx, Aug 23, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    pmx

    I'm working on my first plugin (and first java project), Lick. Lick is a plugin manage that will allow server admins to download and install bukkit plugins via easy commands in the game. It also enabled them to enable/disable currently installed plugins and will have more features like removing plugins etc.

    My code is on github: https://github.com/DeanWard/Lick I'd love it if you guys could look over my code and tell me if I'm making a horrible mess anywhere. I'm sure there are some stupid things in my code somewhere!

    Thanks for any feedback you can give me :D

    Oh! jar available here: https://github.com/downloads/DeanWard/Lick/Lick.jar

    commands are:

    /lick install pluginname
    (doesnt do much until i fix the repo up)
    /lick enable pluginname
    enable plugin, acts instantly on exact match, asks for confirm on partial match
    /lick disable pluginname
    disable plugin, acts instantly on exact match, asks for confirm on partial match
    /lick installed
    lists installed plugins, enabled ones in green, disabled ones in red

    EDIT: I also would like to ask how to find out if CommandSender is a player or a console user?
     
  2. Offline

    DrBowe

    @pmx

    CommandSender can be either of them. You check to see what it is using the instanceof operator.
     
  3. Offline

    iKrazy

    Nom nom tasty plugins.
     
  4. Offline

    pmx

    @DrBoweNur Thanks! I'll do that today so it stops freaking out if i try to use it from the console!

    @iKrazy wut?

    Would still like some feedback on the code in my plugin :D
     
  5. Offline

    sddddgjd

    It's a reference to the plugin's name...seriously,"lick"?
     
  6. Offline

    pmx

    Oh yeah I feel stupid now lmao
     
  7. Offline

    desht

    A few suggestions:
    • Your Utils class would be a better place to put getLevenshteinDistance()
    • This is somewhat subjective, but I would personally put onCommand() in its own class, and use getCommand("lick").setExecutor(...). Tidier that way, IMHO.
    • I would also strongly recommend splitting out onCommand() into separate sub-methods, for readability's sake. It's hugely long (and wide) right now.
    • No problem with supporting Permissions for now, but I would at least add a fallback to player.hasPermission() if you can't load Permissions. I would suggest adding a boolean method called (say) isAllowedTo() in your plugin, which checks if permissionHandler != null, and uses player.hasPermission() if it is null. There's no excuse for not supporting superperms.
     
  8. Offline

    Pencil

    The name is cool! Don't change it!! :D

    I really like the idea of the plugin, tho I'm afraid people will then install plugins without reading the actual instructions :/
     
  9. Offline

    sddddgjd

    Your avatar matches the name perfectly...:confused:

    Ontopic,if you need any help PM me! :D
    Sounds like a really awesome idea!
     
    Pencil likes this.
  10. Offline

    pmx

    Thank you for the input I'll Definately take that on board! I was thinking about the permsissions stuff before actually so I'm glad you've made some suggestions on that :D

    Haha I like the name too :D the concern about the instructions is a valid one and may cause problems. I'll have to see if there is something I can do to help with that. Maybe I could have it email the user the instructions and tell them they need to follow those steps for the plugin to work. Should be easy enough to have the server admins register an email address with the plugin on first use.

    @sddddgjd Thank you I may just end up doing that! I've managed to struggle through most problems I've faced by reading threads on asking google but I'm sure I'll get stuck as my code gets more complex :D

    Right I've made a bunch of fixes to the code to fix console support and also to fall-back if permissions 3 isn’t available. Code is in my repo. I'd be grateful if one of you fine gentlemen could take a look at the permissions code I wrote to see if it’s up to scratch?


    https://gist.github.com/1169387

    thanks :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
Thread Status:
Not open for further replies.

Share This Page