[Tutorial] How to make a Simple Basic Bukkit Plugin

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

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

    emericask8ur

    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
     
    Jogy34 and thehutch like this.
  2. This should be in Resources
     
  3. Offline

    Sparten368

    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

    emericask8ur likes this.
  5. Offline

    emericask8ur

    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

    Thanks bro =)

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

    XsNiPeRxXz

    Nice! I've tweeked this a little but it seems to work fine! Thanks.
     
  7. Offline

    chrost2000

  8. Offline

    orano

    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
     
  9. Offline

    emericask8ur

    Please use the BB Code [ Code ] & [ /Code ] (Put them together)
     
  10. Offline

    orano

    yeah sorry, but do you know the answer?
     
  11. Offline

    emericask8ur

    return true; and You should remove the "permission" in your YML under Command.
     
  12. Offline

    orano

    yeah i've changed the code now
     
  13. Offline

    emericask8ur

  14. Offline

    orano

    where do I put return true;?
     
  15. Offline

    emericask8ur

    Where it says false :p
     
  16. Offline

    orano

    oh BTW the permission and usage and stuff is indented, it's just the code editor

    which file?

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

    emericask8ur

    I sent you a Link on how to Register Permissions and Commands in a YML
     
  18. Offline

    orano

    but still, which file do i put return true; in and which line?
     
  19. Offline

    emericask8ur

    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;
     
  20. Offline

    orano

    are you sure it should be true? and will this solve my problem of the folder not appearing?
     
  21. Offline

    emericask8ur

    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
    
     
  22. Offline

    orano

    thanks a lot, i'll try running it in minecraft

    still doesn't make a folder or run...

    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
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  23. Offline

    emericask8ur

    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
     
  24. Offline

    orano

    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!

    oh yeah and the command doesn't work, so if I try /orano10000 or orano10000 in console, it just returns"unknown command"

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

    emericask8ur

    I think your doing it wrong -.- You have TeamViewer?
     
  26. Offline

    orano

    yup

    u want the network id and password?

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

    emericask8ur

    Private Message me your info
     
  28. Offline

    orano

    I'm sorry for my extreme noobiness but how do I pm you on this site?
     
  29. Offline

    emericask8ur

    Click my name here and Click Start Conversation
     
  30. Offline

    orano

    thanks for being so helpful emericask before, so can you help me again by saying what would you do if you wanted to say something to the whole server. A bit like [BROADCAST] and [SERVER] except custom text like [ORANOBROADCAST]? So you could have a custom tag that goes to everyone on the server, and then some text afterwards like, [ORANOBROADCAST] Everyone Get in side your homes!


    and of course this could be activated via a command?

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

Share This Page