[SOLVED] Comparing two signs

Discussion in 'Plugin Development' started by Benedikt Wüller, Sep 24, 2012.

Thread Status:
Not open for further replies.
  1. Hey there,
    I have a problem by checking if a sign equals another.
    My code is something like that:
    Code:java
    1. if (signA == signB) {
    2. // do something
    3. } else {
    4. System.out.println("Sign A: " + signA);
    5. System.out.println("Sign B: " + signB);
    6. }


    The System prints out this on testing it:
    Code:
    18:36:17 [INFORMATION] Sign A: org.bukkit.craftbukkit.block.CraftSign@d499c9ec
    18:36:17 [INFORMATION] Sign B: org.bukkit.craftbukkit.block.CraftSign@d499c9ec
    But they are the same.
    Any ideas what I'm doing wrong?
     
  2. Offline

    LukeSFT

    You first have to get the lines of the sign by sign.getLines().
    This gives you a String[4].
    This is what you can send as Message.
     
  3. Offline

    brord

  4. Offline

    LukeSFT

    That's what I said.
     
  5. Offline

    brord

    yea, we posted the same time ^^
     
    LukeSFT likes this.
  6. Offline

    LukeSFT

  7. Thanks. Now it says they are not the same, but the lines are exactly the same.
     
  8. Offline

    LukeSFT

    use:
    Code:
    if(signA.getLines().equals(signB.getLines()) ){}
     
    kroltan likes this.
  9. returns false, too.
     
  10. Offline

    LukeSFT

    are you sure the two signs are identical?

    Maybe you should try with the same sign twice.
     
  11. Offline

    Comphenix

    Try Arrays.equals instead:
    Code:
    if(Arrays.equals(signA.getLines(), signB.getLines())) { }
    
     
  12. Now it's working. Thank you!
     
  13. Offline

    LukeSFT

    Then please add an [SOLVED] to your title. ;)

    thanks :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
    kroltan likes this.
Thread Status:
Not open for further replies.

Share This Page