Add a message for a command.

Discussion in 'Plugin Development' started by Okky_, Dec 19, 2020.

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

    Okky_

    It's quick, I hope you can help me. Look at https://prnt.sc/w65pc5 what I want to do is add a message that comes to you when the item in the head is changed.
     
  2. Online

    timtower Administrator Administrator Moderator

    @Okky_ You do it in the if statement that changes the head?
     
  3. Offline

    Kars

    @Okky_ You mean when the player changes their headwear?
     
  4. Offline

    pietermantel

    First, I think you forgot to check if the label of the command is correct. This code will fire whenever a command is executed, so you probably want to add
    Code:
     if (label.equalsIgnoreCase("hat")) 
    around the whole thing (assuming the command is /hat)
    Second, you have two variables, p and player, both referring to the player. I'd strongly recommend having just one variable player, and removing the p variable.
    Third, I think you want to add the
    Code:
     p.sendMessage("Succesfully changed hat!") 
    after
    Code:
     player.getInventory().remove(hand); 
    Hope that helps!
     
  5. Offline

    Strahan

    You're typically better off using Command#getName() instead of the label so you don't have to worry about aliases.
     
    pietermantel likes this.
Thread Status:
Not open for further replies.

Share This Page