[Tutorial] How to make a Simple Basic Bukkit Plugin

Discussion in 'Resources' started by emericask8ur, Oct 15, 2011.

  1. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Watch HD, Full Screen and Enjoy:

    Subscribe!
    More Info:
    This is just a Small Plugin Tutorial on how to create the basics of the basics of a Plugin. Just a Broadcaster but I hope this helps some of you Noobs :)
    And if i helped Feel Free To Donate! :D

    This post has been edited 4 times. It was last edited by emericask8ur Jul 13, 2012.
    Jogy34 and thehutch like this.
  2. Offline

    Ribesg

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    This should be in Resources
  3. Offline

    Sparten368

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    im a complete noob and attempting to learn this stuff. i am very grateful of this video but it would be even nicer if it had voice instructions too.
    ROBERTLEEOBRIEN likes this.
  4. Offline

    Butkicker12 Community Staff Moderator BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    emericask8ur likes this.
  5. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I will add a Voice Tut soon; Since I didnt have a Mic for the computer I was using, I could only do this. But now I have a Mic so I can get to it =D
  6. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  7. Offline

    XsNiPeRxXz

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Nice! I've tweeked this a little but it seems to work fine! Thanks.
  8. Offline

    chrost2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  9. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hey, I am new to plugin making, and I have a problem with my very simple program in which you type /orano10000 and it returns a string. The only thing is, when I export my file, it exports fine (yes i have config.yml selected) and when I run my server, the file is there, but shows no signs of being executed. Also there is no folder with config.yml in it that is generated. Help would be appreciated. Here is my project.
    Main Class:
    Code:
    import java.util.logging.Logger;
     
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
     
    public class TestPlugin extends JavaPlugin {
    private final TestPluginPlayerListener playerListener = new TestPluginPlayerListener(this);
    Logger log =Logger.getLogger("Minecraft");
    public void onEnable(){
    log.info("[TESTPLUGIN] TestPlugin is enabled");
    PluginManager pm = this.getServer().getPluginManager();
    }
    public void onDisable(){
    log.info("TestPlugin is now disabled");
    }
    }
    Listener Class:
    Code:
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerMoveEvent;
    public class TestPluginPlayerListener extends PlayerListener {
    public TestPlugin plugin;
    Logger log =Logger.getLogger("Minecraft");
    public TestPluginPlayerListener(TestPlugin instance) {
    plugin = instance;
    }
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    if(cmd.getName().equalsIgnoreCase("orano10000")){ // If the player typed /basic then do the following...
    sender.sendMessage(ChatColor.GREEN + "Did someone say my name!");
    return true;
    } //If this has happened the function will break and return true. if this hasn't happened the a value of false will be returned.
    return false;
    }
    }
    config.yml:
    Code:
    name: TestPlugin
    main: Bukkit_plugin.TestPlugin
    version: 1.0
    commands:
       orano10000:
          description: This is a jokey command.
          usage: /orano1000

    This post has been edited 2 times. It was last edited by orano Jan 20, 2012.
  10. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Please use the BB Code [ Code ] & [ /Code ] (Put them together)
  11. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    yeah sorry, but do you know the answer?
  12. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    return true; and You should remove the "permission" in your YML under Command.
  13. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    yeah i've changed the code now
  14. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  15. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    where do I put return true;?
  16. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Where it says false :p
  17. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    oh BTW the permission and usage and stuff is indented, it's just the code editor
  18. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    which file?
  19. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I sent you a Link on how to Register Permissions and Commands in a YML
  20. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    but still, which file do i put return true; in and which line?
  21. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Here:
    } //If this has happened the function will break and return true. if this hasn't happened the a value of false will be returned.
    return false; <-- Change to true;
  22. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    are you sure it should be true? and will this solve my problem of the folder not appearing?
  23. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Here ill show you a new way to code it. You dont have to use Two Classes.
    1. Create your Main Class
    Code:
    public class PMain extends JavaPlugin{
     @Override
     public void onDisable() {
      // TODO Auto-generated method stub
      
     }
     @Override
     public void onEnable() {
      // TODO Auto-generated method stub
      
     }
     @Override
     public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
      if(cmdLabel.equalsIgnoreCase("emericask8ur")){
       sender.sendMessage(ChatColor.RED + "Yeah im emericask8ur!");
       return true;
      }
      return true;
      
     }
    }
    
    1. Create YML
    Code:
    name: Simple
    version: 0.1
    main: com.emericask8ur.Simple.PMain
    commands:
      emericask8ur:
       description: Uses 
       usage: /emericask8ur
    
  24. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    thanks a lot, i'll try running it in minecraft
  25. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    still doesn't make a folder or run...
  26. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    i'll post my new code:
    main class:
    Code:
    import java.util.logging.Logger;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
     
    public class TestPlugin extends JavaPlugin{
        @Override
        public void onDisable() {
          // TODO Auto-generated method stub
         
        }
        @Override
        public void onEnable() {
          // TODO Auto-generated method stub
         
        }
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
          if(cmdLabel.equalsIgnoreCase("orano10000")){
          sender.sendMessage(ChatColor.RED + "Did someone say my name!");
          return true;
          }
          return true;
         
        }
        }
    and config.yml:
    Code:
    name: TestPlugin
    main: Bukkit_plugin.TestPlugin
    version: 1.0
    commands:
      orano10000:
          description: This is a jokey command.
          usage: /orano10000
  27. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    It wont make a Folder unless you make it do that. Creating a Folder happens when you create a config. And it does run. Make sure your doing these things:
    1. DO NOT Renaming the .jar File to something else than your Project name
    2. It must contain your package name
  28. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    so the .jar file is called TestPlugin.jar, is that right? And I did create a config didn't I? Config.yml
    sorry for being so nooby but i'm confused!
  29. Offline

    orano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    oh yeah and the command doesn't work, so if I try /orano10000 or orano10000 in console, it just returns"unknown command"
  30. Offline

    emericask8ur

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I think your doing it wrong -.- You have TeamViewer?

Share This Page