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: www.mediafire.com/?ge8xom8gprx38d9#
    Code:
    Code (Text):
    1.  
    2.  
    3. package BukkitPlugin;
    4.  
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class bukkitPlugin_Main extends JavaPlugin implements Listener {
    11.         @Override
    12.         public void onEnable() {
    13.                 getServer().getPluginManager().registerEvents(this, this);
    14.                 getLogger().info("Bukkit: I AM ALIVE!");
    15.         }
    16.        
    17.         @Override
    18.         public void onDisable() {
    19.                 getLogger().info("Bukkit: I AM DEAD!");
    20.                
    21.         }            
    22.         public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    23.                
    24.                 if(cmd.getName().equalsIgnoreCase("alive")) {
    25.                         getLogger().info("Bukkit: Hello!");
    26.                         return true;    
    27.                 }
    28.  
    29.                 return true;
    30.         }
    31. }
    32.  
    33.  
    Please help :)
     
  2. the command wont work because you haven't registered the command in onEnable()
     

  3. Umm... How do I do that?
     
  4. 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. Plugin.yml please.
     
  7. Burnett1
    Here you go:
    Code (Text):
    1.  
    2.  
    3. name: Bukkit_Plugin
    4. main: BukkitPlugin.bukkitPlugin_Main
    5. version: 1.0
    6.  
    7. commands:
    8. Alive:
    9. description: Testing Command
    10. usage: /<command> [player]
    11. permission: Bukkit_Plugin.Alive
    12. permission-message: You don't have Bukkit_Plugin.Alive
    13.  
    14.  
     
  8. 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. 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.
     

  11. Should I rename it?
     
  12. 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.
     

  13. I have done that. Still not working....
     
  14. Techno Ummm....post code again?
     

  15. Code (Text):
    1.  
    2.  
    3. package Bill4788Package;
    4.  
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class Bill4788_MainBukkitClass extends JavaPlugin implements Listener {
    11.         @Override
    12.         public void onEnable() {
    13.                 getServer().getPluginManager().registerEvents(this, this);
    14.                 getLogger().info("Bukkit: I AM ALIVE!");                
    15.         }
    16.        
    17.         @Override
    18.         public void onDisable() {
    19.                 getLogger().info("Bukkit: I AM DEAD!");
    20.                
    21.         }            
    22.         public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    23.                
    24.                 if(cmd.getName().equalsIgnoreCase("alive")) {
    25.                         getLogger().info("Bukkit: Hello!");
    26.                         return true;    
    27.                 }
    28.  
    29.                 return true;
    30.         }
    31. }
    32.  
    33.  
     
  16. Techno Uhh I got nothing.... This guy is pretty awesome though: CluelessDev maybe he can help
     
  17. You use 2 times: "return true;"
     
  18. Didnt notice that, you need to return false at the end to show that it has not worked and it will send the usage.
     

  19. I have set the
    Code (Text):
    1. return true
    with
    Code (Text):
    1. return false
    at the end of the code.

    (Look up this topic for the code.)
     
  20. And what happened?
     

  21. Nothing... It said nothing about it in the console either.
     
  22. try adding this after implements Listener:
    Code (Text):
    1. implements CommandExecutor
    this tells the plugin there is a command function in the code
     
  23. 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. }
     
  24. you can't use "implements" two times in the same class, this is only if the command is in another class (the CommandExecutor)
     

  25. No. It does not. There are error's for the Logger's.
     
  26. @Technothe loggers should be this:
    Code (Text):
    1. getLogger().info("Message here");
     
  27. 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)
     
  28. 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?
     
Thread Status:
Not open for further replies.

Share This Page