Plugin wont install

Discussion in 'Plugin Development' started by Techno, Jun 6, 2013.

Thread Status:
Not open for further replies.
  1. Hello,

    I have written a Plugin for my server (A simple one.) And it won't work when I put
    the .jar into the plugin's folder.

    Plugin Download: <Edit by Moderator: Redacted mediafire url>
    Code:
    Code:
     
    package BukkitPlugin;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class bukkitPlugin_Main extends JavaPlugin implements Listener {
            @Override
            public void onEnable() {
                    getServer().getPluginManager().registerEvents(this, this);
                    getLogger().info("Bukkit: I AM ALIVE!");
            }
           
            @Override
            public void onDisable() {
                    getLogger().info("Bukkit: I AM DEAD!");
                   
            }            
            public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
                   
                    if(cmd.getName().equalsIgnoreCase("alive")) {
                            getLogger().info("Bukkit: Hello!");
                            return true;    
                    }
     
                    return true;
            }
    }
     
    
    Please help :)
     
    Last edited by a moderator: Nov 6, 2016
  2. Offline

    NoLiver92

    the command wont work because you haven't registered the command in onEnable()
     

  3. Umm... How do I do that?
     
  4. Offline

    Technius

    NoLiver92
    You don't need to register it in onEnable().

    Techno
    Are you getting the messages in the console. Are there any error logs?
     
  5. Technius
    No. It does not say anything about it in the console.
     
  6. Offline

    Burnett1

    Plugin.yml please.
     
  7. Burnett1
    Here you go:
    Code:
     
    name: Bukkit_Plugin
    main: BukkitPlugin.bukkitPlugin_Main
    version: 1.0
     
    commands:
    Alive:
    description: Testing Command
    usage: /<command> [player]
    permission: Bukkit_Plugin.Alive
    permission-message: You don't have Bukkit_Plugin.Alive
     
    
     
  8. Offline

    Zach_1919

    Techno Well it doesn't look like your command identifiers in the plugin.yml are done correctly. All of the things like the description, usage, permission, and oermission-message needs to be three spaces in.
     

  9. Thank you. I have fixed the orientation but it is still not working
     
  10. Offline

    Zach_1919

  11. Offline

    Zach_1919

    Techno Hmmm it may have to do with the name of your package. The name BukkitPlugin may already be used by something in Bukkit. A kind of customary thing to do is to make your package me.YourName.PluginName so it doesn't coflict with anything else. Also, I'm not sure, but maybe you shouldn't use underscores in the class name. I am not sure, but try to avoid it.
     

  12. Should I rename it?
     
  13. Offline

    Zach_1919

    Techno Yes, copy your code, delete your package and the class, then create a new package and a new class as I told you, then paste the code back in.
     

  14. I have done that. Still not working....
     
  15. Offline

    Zach_1919

    Techno Ummm....post code again?
     

  16. Code:
     
    package Bill4788Package;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Bill4788_MainBukkitClass extends JavaPlugin implements Listener {
            @Override
            public void onEnable() {
                    getServer().getPluginManager().registerEvents(this, this);
                    getLogger().info("Bukkit: I AM ALIVE!");                
            }
           
            @Override
            public void onDisable() {
                    getLogger().info("Bukkit: I AM DEAD!");
                   
            }            
            public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
                   
                    if(cmd.getName().equalsIgnoreCase("alive")) {
                            getLogger().info("Bukkit: Hello!");
                            return true;    
                    }
     
                    return true;
            }
    }
     
    
     
  17. Offline

    Zach_1919

    Techno Uhh I got nothing.... This guy is pretty awesome though: CluelessDev maybe he can help
     
  18. Offline

    Bammerbom

    You use 2 times: "return true;"
     
  19. Offline

    Burnett1

    Didnt notice that, you need to return false at the end to show that it has not worked and it will send the usage.
     

  20. I have set the
    Code:
    return true
    with
    Code:
    return false
    at the end of the code.

    (Look up this topic for the code.)
     
  21. Offline

    Burnett1

    And what happened?
     

  22. Nothing... It said nothing about it in the console either.
     
  23. Offline

    NoLiver92

    try adding this after implements Listener:
    Code:
    implements CommandExecutor
    this tells the plugin there is a command function in the code
     
  24. Offline

    PatoTheBest

    This should work
    Code:java
    1. package Bill4788Package;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class Bill4788_MainBukkitClass extends JavaPlugin {
    8. public final Logger logger = Logger.getLogger("Minecraft");
    9.  
    10. @Override
    11. public void onEnable() {
    12. getServer().getPluginManager().registerEvents(this, this);
    13. this.logger.info("Bukkit: I AM ALIVE!");
    14. }
    15.  
    16. @Override
    17. public void onDisable() {
    18. this.logger.info("Bukkit: I AM DEAD!");
    19.  
    20. }
    21. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    22.  
    23. if(commandLabel.equalsIgnoreCase("alive")) {
    24. this.logger.info("Bukkit: Hello!");
    25. }
    26. return true;
    27. }
    28. }


    you can't use "implements" two times in the same class, this is only if the command is in another class (the CommandExecutor)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016

  25. No. It does not. There are error's for the Logger's.
     
  26. Offline

    NoLiver92

    @Technothe loggers should be this:
    Code:
    getLogger().info("Message here");
     
  27. Offline

    Rocoty

    A class can implement as many interfaces as you'd like it to. But of course you're right, the keyword "implements" cannot be used twice. You'd have to separate the interfaces with commas.

    NoLiver92 CommandExecutor is already implemented by some class some levels up in the hierarchy, so implementing CommandExecutor on that class wouldn't make any difference (I don't think it would even work)

    Where is the plugin.yml located anyway? It has to be in the default package or in no package

    EDIT: And I assume you replaced the main key in the plugin.yml with the updated path once you refactored the class?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016

  28. What do you mean?
     
  29. Offline

    Burnett1

    Upload the jar somewhere we can download please.
     
Thread Status:
Not open for further replies.

Share This Page