Solved getCustomName() is not equal to itself

Discussion in 'Plugin Development' started by TheKingElessar, Jul 27, 2018.

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

    TheKingElessar

    I am trying to detect if a wither that shoots something is name a certain thing. So, I set something like this up:
    Code:
    String witherName = shooter.getCustomName();
    
    if(witherName == "This is a Wither") {
        // Do stuff               
    } else {
        // Wrong name!
    }
    However, even when I directly copy-pasted the name in the code into a nametag and named the Wither, the "Do stuff" code never executed. So, I tried doing this:
    Code:
    String witherName = shooter.getCustomName();
    
    
    if(witherName == shooter.getCustomName()) {
        // Do stuff
    } else {
        // What?!
    }
    But, the "Do stuff" code is never executed! It only executes the "What?!" part. What's wrong with it?

    The only thing I can think of that's causing this is that nametag names aren't actually returned through getCustomName(); is that the case? If so, how can I get the nametag name?

    Thanks for your help!
     
  2. Offline

    TheKingElessar

  3. Offline

    KarimAKL

  4. Offline

    TheKingElessar

Thread Status:
Not open for further replies.

Share This Page