Args[0] in if-Statement does not work

Discussion in 'Plugin Development' started by doppelkool, Aug 25, 2020.

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

    doppelkool

    Hey guys,

    I am still a beginner and do not understand why something like this does not work. I wanted to build a small lobby system for "practice" and a "ClearSlot" command should be integrated.
    If it would work, you can use the command /clearslot [number]/Helmet/... to clear the slot in your/the players inventory.
    But without a reason the if statement does not work here. It should decide which slot shoudl be cleared.

    //EDIT: First Thing i haven't seen was in line 28 the "else" missing to change the statement into an "else if()" statement. - Still not fixed

    In line 24. for example
    https://pastebin.com/y1FTT6ZN

    Can somebody help me please :D
     
    Last edited by a moderator: Aug 25, 2020
  2. Offline

    KarimAKL

  3. Offline

    timtower Administrator Administrator Moderator

    Moved to plugin development.
     
  4. Offline

    Strahan

    I assume his problem is due to using == as if he tries any of the armor text entries, it will always send the help message in the NFE catch block.

    OP, you should not be embedding the color character. Use ChatColor, that's why it exists. Also you don't need to create an air itemstack; just set to null. Lastly, and this is just personal preference, I'd recommend negative check and return and a switch statement for readability.

    Depends how their plugin.yml is setup. If it has usage defined properly, then some people prefer to return false and let MC send the usage message when applicable. Personally, I always return true and just handle that myself but it's not necessarily wrong to return false.
     
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page