Solved Return issues.

Discussion in 'Plugin Development' started by ColaCraft, Jun 2, 2013.

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

    ColaCraft

    I could have swore I had my returns right, I guess not though.

    When I execute the "flag" command, it just returns the "usage" in the plugin.yml

    Code:java
    1.  
    2. package me.PorterK.RAF;
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.configuration.file.FileConfiguration;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.PluginDescriptionFile;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. import java.util.logging.Logger;
    13.  
    14. public class RAF extends JavaPlugin {
    15.  
    16. private final Logger log = Logger.getLogger("Minecraft");
    17. private final String logTag = "[RAF] " + ChatColor.RESET;
    18.  
    19. private FileConfiguration config;
    20. private PluginDescriptionFile pdfFile;
    21.  
    22. @Override
    23. public void onEnable(){
    24. this.pdfFile = this.getDescription();
    25. this.config = this.getConfig();
    26. log.info( logTag + pdfFile.getName() + " v" + pdfFile.getVersion() + " enabled!");
    27. }
    28.  
    29. @Override
    30. public void onDisable(){
    31. log.info( logTag + pdfFile.getName() + " v" + pdfFile.getVersion() + " disabled!");
    32. }
    33. public boolean onCommand(Player sender, Command cmd, String label, String[] args ) {
    34. if(label.equalsIgnoreCase("flag")) {
    35. Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "msg porterk derp");
    36. sender.sendMessage(logTag + "Derp!");
    37. return true;
    38. }
    39. return false;
    40. }
    41. }
    42.  


    Thanks guy, I appreciate any help.
     
  2. Offline

    Addicted_24_7

    From what i can tell, it may help to turn the last return to true.
     
  3. Can you post your plugin.yml?
    It could be that your plugin.yml has a different definition of the command "flag".
    That's the only reason it'd return a usage message.
     
  4. Offline

    ColaCraft

    To all else who have this issue, this is how you solve it:

    Code:java
    1.  
    2. public boolean onCommand(Player sender, Command cmd, String label, String[] args){
    3.  


    needs to be

    Code:java
    1.  
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    3.  


    Props to bobacadodl for solving this :)
     
Thread Status:
Not open for further replies.

Share This Page