No commands working?

Discussion in 'Plugin Development' started by Caprei, Oct 6, 2013.

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

    Caprei

    Hi guys, I'm learning to make plugins at the moment. This is what i'm working on right now. It's a simple healing plugin. When I put it on the server and try a command absolutely nothing happens. It doesn't even say internal error or unknown command, just nothing happens. Help please? :)
    Here is the pastebin link:

    http://pastebin.com/HaBvwEsS

    And here it is in a Bukkit thing:
    Code:java
    1. package me.Antonio.Test;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.command.Command;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.PluginDescriptionFile;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class Test extends JavaPlugin{
    11. public static Test plugin;
    12. public Logger logger = Logger.getLogger("Minecraft");
    13.  
    14. @Override
    15. public void onDisable(){
    16. PluginDescriptionFile pdfFile = this.getDescription();
    17. this.logger.info(pdfFile.getName() + " has been disabled");
    18.  
    19. }
    20.  
    21. @Override
    22. public void onEnable(){
    23. PluginDescriptionFile pdfFile = this.getDescription();
    24. this.logger.info(pdfFile.getName() + " has been enabled!");
    25. }
    26.  
    27. public boolean onCommand(Command sender, Command cmd, String commandLabel, String [] args){
    28. Player player = (Player) sender;
    29. if(commandLabel.equalsIgnoreCase("heal") || commandLabel.equalsIgnoreCase("h")){
    30. if (args.length == 0){
    31. player.setHealth(20.0);
    32. player.sendMessage("You healed yourself!");
    33. }else if (args.length == 1){
    34. if(player.getServer().getPlayer(args [0]) != null){
    35. Player targetPlayer = player.getServer().getPlayer(args [0]);
    36. targetPlayer.setHealth(20.0);
    37. targetPlayer.sendMessage("You were healed!");
    38. }else{
    39. player.sendMessage("Player is offline.");
    40. }
    41. }
    42. }
    43. return false;
    44. }
    45.  
    46.  
    47. }


    Thanks so much.
    Antonio
     
  2. Offline

    Seadragon91

    Here is the error:
    Code:
    public boolean onCommand(Command sender, Command cmd, String commandLabel, String [] args){
    
    And here the fixed line:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String [] args){
    
    Next time add @Override to the command method, it's not necessary, but the IDE will show a error, if the class JavaPlugin has no method with that parameters to override. And don't forget to add the command in the plugin.yml, if you haven't.
     
  3. Offline

    MrSparkzz

    Caprei & Seadragon91
    He could implement CommandExecutor after extending JavaPlugin. Then his IDE would make him enter it correctly.
     
  4. Offline

    Caprei

    Thank you so much both of you! Eternal gratitude haha.
     
Thread Status:
Not open for further replies.

Share This Page