Solved Not working...

Discussion in 'Plugin Development' started by Meatiex, Oct 7, 2013.

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

    Meatiex

    Heres my code:
    Code:java
    1. String commandString2 = theSign.getLine(1);
    2. if (theSign.getLine(0).equals("[Color]") || theSign.getLine(0).equals(ChatColor.DARK_BLUE +"[Color]") && commandString2.toUpperCase() != "Random"
    3. && commandString2.toUpperCase() != "StrikeThrough" && commandString2.toUpperCase() != "Italicize" && commandString2.toUpperCase() != "Bold") {

    Its sposto not let players use a sign that says Bold, Italicize, Random, StrikeThrough and those on the second line, Its probably just a small error... Thanks :D
     
  2. Offline

    Trevor1134

    String should be done with if(!commandString2.equals(STRING){

    rather than !=.
     
  3. Offline

    Hoolean

    Meatiex

    Just to explain Trevor1134 's answer in a bit more detail, == compares whether two objects are the same instance, rather than whether their content is the same. :)
     
    Trevor1134 and CubieX like this.
  4. Offline

    Meatiex

    It didn't work...
    Code:java
    1. if (theSign.getLine(0).equals("[Color]") || theSign.getLine(0).equals(ChatColor.DARK_BLUE +"[Color]") && !commandString2.toUpperCase().equals("StrikeThrough")
    2. && !commandString2.toUpperCase().equals("Bold") && !commandString2.toUpperCase().equals("Italicize") && !commandString2.toUpperCase().equals("Random")) {
     
  5. Offline

    remremrem

    change "Italicize" to "ITALICIZE", "Random" to "RANDOM" etc.
    you are comparing string.toUpperCase, so you need to use all uppercase letters.
     
  6. Offline

    Meatiex

    Sorry to bother, but BOLD works(cant click) and bold dosn't work...(can click)
    Code:java
    1. if (theSign.getLine(0).equals("[Color]") || theSign.getLine(0).equals(ChatColor.DARK_BLUE +"[Color]") && !commandString2.toUpperCase().equals("STRIKETHROUGH")
    2. && !commandString2.toUpperCase().equals("BOLD") && !commandString2.toUpperCase().equals("ITALICIZE") && !commandString2.toUpperCase().equals("RANDOM")) {
     
  7. Offline

    Ultimate_n00b

    Why not remove toUpperCase altogether, and just .equalsIgnoreCase() ?
     
  8. Offline

    Meatiex

    I guess that would work... but i fixed it now :D
    Code:java
    1. if (theSign.getLine(0).equals("[Color]") || theSign.getLine(0).equals(ChatColor.DARK_BLUE +"[Color]")) {
    2. if (!commandString2.toUpperCase().equals("STRIKETHROUGH")&& !commandString2.toUpperCase().equals("BOLD") && !commandString2.toUpperCase().equals("ITALICIZE")
    3. && !commandString2.toUpperCase().equals("RANDOM")) {
     
Thread Status:
Not open for further replies.

Share This Page