How to start???

Discussion in 'Resources' started by TechNickL, Jul 10, 2011.

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

    TechNickL

    I was just wondering...... how in the world do I even make a plugin? I know java, but I have no idea where to begin on this! Help?
     
  2. Offline

    Zaven

    Hello. I myself started learning just a few days ago, but unlike you i don't know Java well yet.
    All I wanted to do is giving you this link : Huge Plugin Tutorial wich is, I guess, all you need to start developing plugins for Bukkit.

    It will give you the link to the Bukkit API and some exemples files. That's all I can do to help, but honestly, I think you'll be able to make many things after reading this.

    Edit : By the way, don't forget to look after source codes from other Plugins. Although i'm not good at it, someone who already knows Java should be able to learn lots of stuff just by reading those source codes.

    2: Basic Bukkit Plugin Tutorial. This looks very good too. You can watch a video there, maybe you prefere it that way. You'll find example files (Templates) there too.
     
  3. Offline

    captainawesome7

  4. Offline

    TechNickL

    Thank you all!
     
  5. Do you guys think I need to add anything to my Huge Plugin tutorial? i haven't added much to it in a while and I know a lot of people use it.
     
  6. Offline

    Tordur

    Yeah, a more noobfriendly way to show how to make/use commands.. I'm lost.
     
  7. Offline

    (infected)

    I'm making it easier for beginners to get started whether they know Java or not.
    Check my thread
     
  8. Offline

    TechNickL

    I must agree.... I'm not even sure where to put the onCommand. it says its an illegal modifier, only final is permitted. i bet i did something stupid and of course i'll probably figure out whats wrong in like 10 minutes but.....
     
  9. onCommand should go in your main class unless you register it elsewhere which I don't recommend untill you have more experience.

    What are you registering as final?
     
  10. Offline

    TechNickL

    nothing... maybe thats the problem?

    heres the code:

    Code:
    package me.technickl.wrath;
    
    import java.util.logging.Logger;
    
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import com.nijiko.permissions.PermissionHandler;
    import com.nijikokun.bukkit.Permissions.Permissions;
    import org.bukkit.plugin.Plugin;
    
    public class WRATHOFTHEADMIN extends JavaPlugin{
        //Permission setup:
        public static PermissionHandler permissionHandler;
        private void setupPermissions() {
            if (permissionHandler != null) {
                return;
            }
    
            Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
    
            if (permissionsPlugin == null){
                log.severe("WARNING!!! PERMISSIONS NOT FOUND. ALL OPS WILL HAVE WRATH.");
                return;
            }
    
            permissionHandler = ((Permissions) permissionsPlugin).getHandler();
            log.info("Permissions found!");
        }
        //start
        PluginManager pm = this.getServer().getPluginManager();
        Logger log = Logger.getLogger("Minecraft");
        public void onEnable(){
            setupPermissions();
            log.info("Wrath Enabled");
            public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    
            }
        }
        public void onDisable(){
            log.info("Wrath Disabled");
        }
    }
    
     
  11. I have rewritten your code to work ;) And added comments where it went wrong.

    Code:java
    1.  
    2. package me.technickl.wrath;
    3.  
    4. import java.util.logging.Logger;
    5.  
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.event.player.PlayerListener;
    8. import org.bukkit.plugin.PluginManager;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10. import com.nijiko.permissions.PermissionHandler;
    11. import com.nijikokun.bukkit.Permissions.Permissions;
    12. import org.bukkit.plugin.Plugin;
    13.  
    14. public class WRATHOFTHEADMIN extends JavaPlugin{
    15. //Permission setup:
    16. public static PermissionHandler permissionHandler;
    17. private void setupPermissions() {
    18. if (permissionHandler != null) {
    19. return;
    20. }
    21.  
    22. Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
    23.  
    24. if (permissionsPlugin == null){
    25. log.severe("WARNING!!! PERMISSIONS NOT FOUND. ALL OPS WILL HAVE WRATH.");
    26. return;
    27. }
    28.  
    29. permissionHandler = ((Permissions) permissionsPlugin).getHandler();
    30. log.info("Permissions found!");
    31. }
    32.  
    33. //start
    34. PluginManager pm;
    35. Logger log = Logger.getLogger("Minecraft");
    36. public void onEnable(){
    37. setupPermissions();
    38. pm = this.getServer().getPluginManager();//You need to call this.GetServer() from within the onEnable() method.
    39. log.info("Wrath Enabled");
    40. }
    41.  
    42. public void onDisable(){
    43. log.info("Wrath Disabled");
    44. }
    45.  
    46. //This should be on it's own, not in onEnable()
    47. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    48.  
    49. }
    50. }
     
  12. Offline

    TechNickL

    ahhhhhhhhhhh THANK U
     
  13. Your welcome ;)
     
  14. Offline

    TechNickL

    YES! just got my first demo plugin working on my server.
     
  15. Offline

    moose517

    Glad i came across this thread as i see the OP is using permissions system as well. I'm writing a simple test plugin more or less to see if i even want to attempt plugins or leave it to the experts LOL. Anyways in my onCommand function i have this

    Code:
    	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    		if (commandLabel.equalsIgnoreCase("/basic") || commandLabel.equalsIgnoreCase("/b")) {
    			// see if the user has the permissions to do it
    			if (!(this).permissionHandler.has((Player) sender, "basic.basic")) {
    				toggleVision((Player) sender);
    			}
    		}
    		return true;
    	}
    
    eclipse underlines permissionHandler if i keep it as (this) but if i put Basic - the name of the plugin it errors saying that i need to create a constant. First of all am i even on the right path with that? i mean nijiko's API reference just leaves you guessing at that point i think LOL. Would be nice if he had a total plugin example with just a simple command that says hi or something for a noob like me haha.

    Sorry to the OP, if you don't want this here i can delete and start another thread. who knows maybe the answer will be your next question anyways LOL.
     
  16. Offline

    (infected)

    @TechNickL
    Did the link I gave help you?
     
  17. Fixed your code up.

    Code:java
    1.  
    2. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    3. if (commandLabel.equalsIgnoreCase("/basic") || commandLabel.equalsIgnoreCase("/b")) {
    4. // see if the user has the permissions to do it
    5. if (permissionHandler.has((Player) sender, "basic.basic")) {
    6. toggleVision((Player) sender);
    7. return true;
    8. }
    9. }
    10. return true;
    11. }
    12.  
     
  18. Offline

    TechNickL

    it would hav helped more if i hadnt known java already

    ^^^^^^^^^^
    CODE MAGICIAN:p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  19. Haha, not exactly ;)
     
Thread Status:
Not open for further replies.

Share This Page