Solved Code stopping at certain statements

Discussion in 'Spigot Plugin Development' started by TheGamerPlayz, May 20, 2016.

Thread Status:
Not open for further replies.
  1. During the code it gets the world from the config and the world the player is in, but when i compare them it returns false. Here is what i am using.
    Code (Java):

            if(p.getWorld().getName() == pl.getConfig().getString("World")){
    I used the sendMessage to be sure that they are the same, and they are, but it is not going into the if statement.
    • Funny Funny x 1
  2. Use equals
    • Like Like x 1
  3. yeah you can't compare Objects (in Java Strings are objects) with the equal sign the same way as with primitive data Types as said above, use the .equals() method.
    If you use the equal signs, the programm will actualy check if the Objects are the same Object, however the Strings are not the same since one is created in the World and the other one is created when reading from the YAML file
    • Informative Informative x 1
Thread Status:
Not open for further replies.