HELP My plugin is broken!

Discussion in 'Plugin Development' started by RangerNuk, Sep 12, 2012.

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

    RangerNuk

    I have my plugin coded right and my .yml works fine, only one command works properly, all the other commands just print this, "/<command name> [player]", this is how its defined in the yml. I've tried giving each command it's own class, I've tried everything, PLEASE HELP!!!
     
  2. Offline

    Dpasi314

    Check your return statements and / or public boolean onCommand code. Make sure you have your returns properly, or else that will happen. If you can't find it please post the onCommand :}
     
  3. Offline

    xXSniperzzXx_SD

    Do you have the opening and closing brackets ( { } ) in the right spot?
    and as for the
    My guess is at the end of the code you have return false;
     
  4. Offline

    RangerNuk

    Here are the on command methods



    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    if(cmd.getName().equalsIgnoreCase("roast")){
    Player s = (Player)sender;
    Player target = s.getServer().getPlayer(args[0]);
    target.setFireTicks(10000);
    return true;
    }
    return false;

    }




    here is the other one
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    if(cmd.getName().equalsIgnoreCase("scorch")){
    Player s = (Player)sender;
    Player target = s.getServer().getPlayer(args[0]);
    target.setFireTicks(10000);
    return true;
    }
    return false;

    }
     
  5. Offline

    xEpicTaco

    RangerNuk

    The code works, but it wouldn't it be much more efficient to just do:

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    {
            if(cmd.getName().equalsIgnoreCase("scorch")
            {
                    sender.getServer().getPlayer(args[0]).setFireTicks(10000);
                    return true;
            }
     
            return false;
    }
    
     
  6. Offline

    RangerNuk

    I guess but I like doing it the way I do. Why is this happening?
     
  7. Offline

    xEpicTaco

    Personally, I'd do:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    {
            if(cmd.getName().equalsIgnoreCase("scorch")
            {
                    sender.getServer().getPlayer(args[0]).setFireTicks(10000);
                    return true;
            }
     
            return true;
    }
    
    Also, make sure your plugin.yml is like so:

    Code:
    commands:
        scorch:
            permission: (put permission here)
            usage: (Usage here)
    permissions:
        scorch.example:
            default: op
    
     
  8. Offline

    StevasaurousREX

    Do you have both those onCommands in one class? I would just put them together like so
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. if(cmd.getName().equalsIgnoreCase("roast")){
    3. Player s = (Player)sender;
    4. Player target = s.getServer().getPlayer(args[0]);
    5. target.setFireTicks(10000);
    6. return true;
    7. }
    8. if(cmd.getName().equalsIgnoreCase("scorch")){
    9. Player s = (Player)sender;
    10. Player target = s.getServer().getPlayer(args[0]);
    11. target.setFireTicks(10000);
    12. return true;
    13. }
    14. return false;
    15. }

    But I might not be doing the most efficient way, its just the way I've done my commands (besides the end I always 'return true;'
    Had a mess of bbcode in there trying to remove you chat formatting xD
     
  9. Offline

    RangerNuk



    I'll do this, thanks!
     
Thread Status:
Not open for further replies.

Share This Page