Plugin Template [935] [OUTDATED]

Discussion in 'Resources' started by Tagette, May 25, 2011.

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

    Tagette

    Template Version <font color="rgb(0, 204, 255)">1.1.5 <font color="rgb(0, 0, 0)">[935](NOW SUPPORTS MYSQL)</font></font>

    <font color="rgb(255, 0, 0)">Looking for someone to make a video on how to use my template to make their plugin. If you would like to do this for me please let me know. I have decided not to put the effort into making my own video.</font>

    Summary:
    I have been creating a bukkit plugin template for the last couple weeks and I have decided I am going to release it to you guys. Let me know if this template is adequate enough. This is actually my first plugin for bukkit so it may need some fixing. I have been searching through source code and the forums to make it as practical as possible for everyone. Hope you enjoy.

    Features:
    - Examples on how to use in the code,
    - Multiple plugin support, (Permissions, GroupManager, Help, iConomy 4&5, BOSEconomy, OddItem, Lockette, LWC... and more)
    - Auto Updater Support,
    - Auto generating Settings and Language files, (With auto-generating comments)
    - SQLite or MySQL data management,
    - And More...
    Show Spoiler
    1) Extract the zip to where you like.
    2) Create a new project with your favorite Java IDE and use the src folder from the Template.zip as the project source.
    3) Rename the packages from "me.tagette.template" to "me.<Your Name>.<Your Plugin>".
    4) Replace any instances of Tagette in any of the classes under "src/me".
    5) Rename your classes to whatever you like. (Try to keep it standard! For example if your plugin's name was "Basic" then you would rename "TSettings.java" to "BSettings.java".)
    6) Add all the .jar files from the lib folder into the libraries of the project. (Netbeans Eclipse)
    7) Edit the plugin.yml and enter your information. (Note: In order for a command to work it must be in the plugin.yml)
    8) Build and test? YAY!



    Show Spoiler
    Features:
    - Download latest support plugins.
    - Download latest template.
    - Download latest working CraftBukkit.
    - Extracts and renames files for you from template.
    - Simple use:
    I) Enter Name
    II) Enter Plugin Name
    III) Enter Plugin Initials
    IV) Click Create Button

    Info: If you would like this to be made, please request it. Otherwise I won't waste my time on it.


    Future Features:
    - Java Application that extracts and renames for you. (3/4 done) <font color="rgb(255, 0, 0)">*On Hold*</font>
    - Suggestions?
    Show Spoiler
    * July 4 - Enhanced debug system and more. (1.1.5)
    * June 29 - Tidied up code, enhanced the debug system and the command system. (1.1.4)
    * June 29 - Added Auto-Updater and Plugin Constants. (1.1.3)
    * June 18 - Updated Libraries and added LowDetailMode. (1.1.2)
    * June 2 - More minor code changes. (1.1.1)
    * June 2 - Updated example commands. (1.1.1) [Added support for console commands]
    * June 2 - Removed Simplified Database (1.1.1) [Didn't actually simplify]
    * May 28 - Added plugin debug mode command. (Currently only debugs SQL) (1.1.0)
    * May 28 - More minor code changes. (1.1.0)
    * May 28 - Fixed SQLite (1.1.0)
    * May 28 - Added MySQL Support (Alta189's SQL Lib) (1.1.0)
    * May 28 - Removed useless code & Tidied up code (1.0.9)
    * May 27 - Changed how to setup. (1.0.8)
    * May 27 - New Command System (1.0.7)
    * May 27 - Permissions Fix (1.0.6)
    * May 25 - Download changed. (1.0.5)
    * May 25 - Changed how to setup. (1.0.4)
    * May 25 - LWC error fixed. (1.0.3)
    * May 25 - GitHub enabled. (1.0.2)
    * May 25 - Released. (1.0.1)



    Show Spoiler
    Add your command to the command manager in Template.java:
    Code:
    /*
         * Sets up the core commands of the plugin.
         */
        private void setupCommands() {
            // Add command labels here.
            // For example in "/template version" and "/template reload"
            //    the label for both is "template".
            // Make your commands in the me.tagette.template.commands package.
            //    Each command is a seperate class.
            addCommand("template", new TemplateCmd(this));
        }
    Create your class in the me.<Your Name>.<Plugin Name>.commands package.
    Name it something meaningful, for instance in this example, "TemplateCmd.java" since the command is template.

    There are a few methods you should know before starting your commands:
    is(String entered, String label) - This compares the entered value from the user to a subcommand's label.
    isPlayer() - This returns true if the thing that sent the command is a player. If it is not a player then it was the console that sent it.
    getPlayer() - This will get the player if it is actually a player. Otherwise is returns null.
    getName() - This gets the name of the player if it is actually a player. Otherwise it returns "Console".
    sendMessage(String message) - Sends a message to the player only if it is actually a player.
    sendLog(String message) - Sends a log to the console only if the caller of the command is not a player.


    Now in the class you just created it must be similar to the example given. It must implement CommandExcecutor and have a overidden method called onCommand. (Easiest way is to just copy TemplateCmd and rename it)
    Code:
    /**
     * @description Handles a command.
     * @author Tagette
     */
    public class TemplateCmd implements CommandExecutor {
    
        private final Template plugin;
        private CommandSender cSender;
    
        public TemplateCmd(Template instance) {
            plugin = instance;
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Now in the onCommand method go to where it says "// Put your commands here". That is where you start coding your commands. There are some examples in the TemplateCmd class you can go by.
    Code:
    else if (!defaultCommand(command, label, args)) {
    
                // Put your commands in here
    
                // This is the sub command name
                if (is(args[0], "getawesome")) {
                    // This means that the command has been handled
                    //    so bukkit won't send an error message.
                    handled = true;
                    // This is how you find a permission and check if actually a player
                    if ((isPlayer() && TPermissions.has(getPlayer(), "template.awesomeness", getPlayer().isOp()))){ 


    Download:
    Template.zip (GitHub)
    <Edit by Moderator: Redacted mediafire url>

    Source Code / GitHub:
    GitHub
    Show Spoiler
    - None that I know of. If you have found one let me know.


    Conclusion:
    Please leave a comment about any suggestions or fixes you may have and let me know what you think. I am still deciding if it would be worth making the java application so let me know if you would like it.
    Show Spoiler
    - To Bukkit for making CraftBukkit possible.
    - To nijikokun for the register source.
    - To alta189 for the SQL lib source.
    - To TaylorKelly for the properties file source.
    - To Adamki11s for the AutoUpdater source.
    - To the awesome developers who developed:
    -> BOSEconomy
    -> Essentials
    -> GroupManager
    -> Help
    -> iConomy 4 & 5
    -> Lockette
    -> LWC
    -> OddItem
    -> Permissions
    - To anyone else that was missed.


    Please give credit for using this template.

    Thanks,

    Tagette
     
    Last edited by a moderator: Nov 27, 2016
  2. Offline

    wasd591

    Thanks Tagette! :D You should post this on the github because the old example is... well old.

    Also, welcome to Bukkit! :D
     
    Tagette likes this.
  3. Offline

    Tagette

    I'll look into github

    and thank you :)

    GitHub is up!
    Also fixed some errors.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  4. Offline

    Tagette

    New Command System and fixed a Permissions error.

    Updated downloads and GitHub.

    Updated Setup

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  5. Offline

    iPhysX

    Thankyou! It's great :p
     
    Tagette likes this.
  6. Offline

    bevso

    Well seeing as this is a template, if people want to fill it in but dont have ideas come check out my ideas that i put in plugin requests trust me there are loads of my ideas haha :p

    ---------------------------------------------------------------------------------------------------------------------------------------------

    Youtube: http://www.youtube.com/user/MinecraftNewbhelp?feature=mhee
     
  7. Offline

    Tagette

    Your welcome! :)
    Let me know if you think there should be any changes.
     
  8. Offline

    iPhysX

    Alta189's sqllib has been updated and there is now a MySQL lib :D
     
  9. Offline

    Tagette

    It is? I don't see anything updated on his thread yet. He told me he would be releasing it soon though.

    Made some minor changes to code.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  10. Offline

    Tagette

    Working on adding MySQL into database connections. Pretty sure its working although not sure about SQLite.. tests don't look promising.
     
  11. Offline

    alta189

    Why does it not work?
     
  12. Offline

    Tagette

    Umm I use my own class that allows for simpified database setup. So I had to add it to that.

    EDIT: Turns out I had the wrong sql syntax all along anyways.. So the SQLite was fine.
     
  13. Offline

    Kier

    Eh, I'm confused? I'm very new to this, so what Java IDE do you use? cos idk what to use, and do i open: src > me > tagette > template?
     
  14. Offline

    Tagette

    I use Netbeans.

    First Extract the template.zip somewhere.

    Then make a new java project in Netbeans by:
    1) File>New Project.
    2) Under Categories select 'Java' and under Projects select 'Java Project with Existing Source'. Click next.
    3) Set your name for the project. Click next.
    4) Click the 'Add folder...' for 'Source Package Folders'. Find the src folder that was extracted from the Template.zip and add it.
    5) Click Finish.

    Then rename each package by right clicking.
    Currently the name of the package is "me.tagette.template".
    Rename this to "me.<Your Name>.<Plugin Name>".
    Do this for all 3 of the packages that start with "me.".
    Leave the packages that start with "com.". (They're not my source)

    Then rename each of the classes inside of the package "me.tagette.template" and "me.tagette.template.commands".
    Again leave the files in "me.tagette.template.extras" alone.
    For example if your plugin name was "Basic" then you would rename "TSettings.java." to "BSettings.java".
    Also rename the "Template.java" to "Basic.java".

    EDIT: Forgot an important step!

    Then add the libraries to the project by:
    1) Right clicking on libraries in the left project panel and selecting "Add Jar/Folder".
    2) Go to where you extracted the template into the "libs" folder and select all the files in that folder and add them.

    I will be making a tutorial video as soon as I can.
    I am working to make this template as simple as possible for everyone.

    Another more common IDE is Eclipse. I just prefer Netbeans.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  15. Offline

    WhosDaMan

    Uhh i am confused on how to access the template :p I am a noob, i know.

    EDIT: Nevermind, i think i figured it out :p
     
  16. Offline

    Tagette

    Ok :)
     
  17. Offline

    nexusrightsi

    hmm i got some errors in the BOSE.java

    BOSEconomy > cannot find symbol
    import cosine package does not exist
     
  18. Offline

    Tagette

    Can I see the console output?

    Or is it a IDE error?

    Updated
    * June 2 - More minor code changes.
    * June 2 - Updated example commands. (1.1.1) [Added support for console commands]
    * June 2 - Removed Simplified Database (1.1.1) [Didn't actually simplify]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  19. Offline

    alta189

    You removed the SQL Lib?
     
  20. Offline

    Tagette

    No I removed my simplified database class. =P
    It was a class that used your lib. It basically had methods instead of sql querys.
    Ex:
    Code:
    int amount = DBM.getIntByName("munchies", "Tagette");
    instead of:
    Code:
    int munchies = 0;
    
    ResultSet results = DBM.query("SELECT munchies FROM players WHERE name = 'Tagette'");
    if(results.next()){
        munchies = results.getInt("munchies");
    }
    I may add it back in later when I simplify it a little more.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  21. Offline

    alta189

    Oh
     
    Tagette likes this.
  22. Offline

    jeffadkins51

    Tagette you bump your thread way to much... Just because you updated a link or something dont mean you have to post a second time, just add it to the thread. And im not trying to be a douscher or anything, Just stating my opinion.
     
  23. Offline

    Tagette

    If people are watching this thread will they get an alert just from me editing the original post? I do it because it lets people who are using the 'watch thread' tool get alerted.
     
  24. Offline

    Tagette

    Updated Libraries and added LowDetailMode
     
  25. Offline

    Tagette

    Deciding whether or not to add an updater to the template.
     
  26. well did you? :confused:
     
  27. Offline

    Tagette

    Havn't done it yet but I probably will.
     
  28. Offline

    Tagette

    Added Auto-Updater and Plugin Constants.

    Some minor bug fixes as well :p
     
  29. Offline

    Kaikz

    Would it be possible to make this into a generator like this (outdated)?
     
  30. Offline

    Tagette

    Well in my original post I said I had plans for a template generator, but since no-one showed any interest until now I didn't put to much effort into completing it. I would have to look into making the actual projects for each IDE. I don't exactly know how to do that yet. I'm sure it wouldn't be too hard.

    I have worked on it a little at a time however so it is now 3/4 done.


    Tidied up code, enhanced the debug system, the command system and the help.

    I'm very new to java apps so it's taking me a while.

    I've also got life and a couple more projects on the way.

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

Share This Page