Command inside command problem

Discussion in 'Spigot Plugin Development' started by SnappyCo, May 4, 2017.

  1. Im using this code structure to allow somebody to accept a gamble request from another user. All of the code up to the "hfaccept" command works but when the receiving user enters "/hfaccept" they get an error in chat saying "An internal error occurred while attempting to perform this command". Am i going about the right way of creating a response command?

    CODE STRUCTURE:

    if (cmd.getName().equalsIgnoreCase("hf")) {

    (User sends request)

    if (cmd.getName().equalsIgnoreCase("hfaccept")) {

    (User accepts request)


    }


    }
     
  2. You should do this instead:

    Code (Text):
    if (cmd.getName().equalsIgnoreCase("hf")) {
         (User sends request)
    }else if (cmd.getName().equalsIgnoreCase("hfaccept")) {
           (User accepts request)
    }
    You can't check if the command is "hfaccept" within the other command, because if it equals "hf", it can't also equal "hfaccept" which is what you're checking within that if.
     
  3. Why not just create a HashMap with both players?