I was trying to create a SkyBlock Plugin for my server. When a player types /is go the program checks if the sender has an island. All the islands are stored in a set called islSet. Here's some code Code: case "go": if(hasIsland(player) == true) { try{ player.teleport(getPlayerIsland(player).mainBlock); player.sendMessage(prefix + "Teleporting to your island"); } catch (NullPointerException ex) { player.sendMessage(prefix + "Error teleporting to the island (NullPointerException), talk to a staffer!"); System.out.println(prefix + "Error teleporting " + player.getName() + " to the island, [Error] NullPointerException"); } } else { player.sendMessage(prefix + "You have no island so you can't be teleported"); } Here i'll post the hasIsland method Code: public static boolean hasIsland (Player player) { String pName = player.getName(); for(Island is : islSet) { if(is.owner == pName) { return true; } } return false; } When the hasIsland method is called, it returns false even when the player owns an island. The code was originally in Italian but i changed the words to allow everyone to understand. In case I forgot somethings : proprietario = owner teletrasportando = teleporting isola = island Errore = Error
@Ago19 Don't compare strings with == use .equals instead. You should be using UUID's instead of player names anyway.