Plugin Template

Discussion in 'Plugin Development' started by enkilleridos, Sep 16, 2012.

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

    enkilleridos

    As a person that learns best by doing something than reading about doing something or watching someone do something. I want you to assume several things about me. 1.) I have a working knowledge of programming fundamentals. 2.)I have a intermediate knowledge of creating a java program. 3.)I am not asking for tutorial or really a lot of hand holding. 4.) I have a structured idea for a plugin.

    Does anyone have a template plugin? Something that would technically run but do absolutely nothing more than just simply exist.
     
    FourOhFour likes this.
  2. Offline

    jacklin213

    have u checked bukkit wiki? a plugin template like that is just
    Code:java
    1. package: <packagename>
    2.  
    3. public class <Classname> extends JavaPlugin{
    4.  
    5. public <Classname> plugin;
    6. //PluginDescriptionFile <variable>;
    7. PluginDescriptionFile pdfFile;
    8.  
    9. public void onDisable() {
    10. this.pdfFile = getDescription();
    11. this.getLogger().info(this.pdfFile.getName() + " by jacklin213 is now disabled!");
    12. }
    13. public void onEnable() {
    14. PluginManager pm = getServer().getPluginManager();
    15. this.pdfFile = getDescription();
    16. this.getLogger().info(this.pdfFile.getName() + " Version: "+ his.pdfFile.getVersion()+"
    17. by <authorname> is enabled!");
    18. }
    19.  
    20. }
     
  3. Offline

    CorrieKay

    Even thats a bit too much. theres no need for a lot of that code in there, and

    main class:
    Code:
    //TODO Package declaration
     
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin{
        
        public void onEnable(){
            
            //TODO initialize plugin
            
        }
        
        public void onDisable(){
            
            //TODO disable
            
        }
     
    }
    
    and the plugin.yml:
    Code:
    main: ##package+Main
    author: ##your name
    version: ##version
    name: ##plugin name
    
     
    Sasha Lo and FourOhFour like this.
  4. Offline

    jacklin213

    oh on line 17 change his. into this. after the "Version:"

    tbh u dont even need onEnable nor onDisable plugin does that anyway

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

    CorrieKay

    Well even then, theres no need for a plugin to print out that its being enabled... as bukkit already does that for you. No need whatsoever for any code.

    Also, ive seen that developers use a PluginDescriptionFile a lot... What gives? if you need the version just use getDescription().getVersion() No need to save it at all, seeing as the superclass of the main plugin already does that for you. Just call getDescription() and bam, you've got your pdf right there, with no need to hold it in memory again.

    edit: technically no, as its not implicitely required.

    Realistically speaking, it would be dificult to get your plugin to do much without it. You'd have to create an object that registers a task with the scheduler in its constructor or something xD
     
  6. Offline

    enkilleridos

    oh thank you that lead me directly to where I needed to be.
     
  7. Offline

    FourOhFour

    I realise this was a while ago but thanks for this useful template.
     
    Sasha Lo likes this.
Thread Status:
Not open for further replies.

Share This Page