IF statement always triggering true when in fact isn't...

Discussion in 'Plugin Development' started by GeekyCompz, Mar 28, 2016.

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

    GeekyCompz

    When getting the status (string) from a custom yaml configuration, then checking if it is equal-ignore-case to another string it seems to give wrong results.
    I have multiple IF statements in one divided by '||' which if I am correct, means 'OR'.
    Now if the status is equal to 'available' OR 'denied' OR 'forfeited' OR 'cancelled' then do this.
    But the statement seems to give the wrong results.

    I HAVE checked what response it is getting via the logger and it is in fact getting 'available' but is still returning false but should return true.

    here is my github: (LINE 275) https://github.com/Axiom1999/WarDec...arDeclaration/src/me/axiom/bpl/wardeclaration/cmdexecutor.java
     
  2. Offline

    mine-care

    Nope, you check if it is NOT equal to available OR it is NOT equal to denied OR (...)

    Code:
            if (!(plugin.factionWars.getString(f.getName() + ".Status").equalsIgnoreCase("available")) || !(plugin.factionWars.getString(f.getName() + ".Status").equalsIgnoreCase("denied")) || !(plugin.factionWars.getString(f.getName() + ".Status").equalsIgnoreCase("forfeited")) || !(plugin.factionWars.getString(f.getName() + ".Status").equalsIgnoreCase("cancelled"))) {
    
    the ! is the NOT operator so it is alogic error ;)
     
Thread Status:
Not open for further replies.

Share This Page