Hi all! First of all i want to say that i'm new to java, and maybe my question is more likely to be a java issue than bukkit. So i use Player.getName() to get the player name, and every time i try to compare it to a String in a LinkedList it just doesnt work. Here is an exemple of what isn't working: Code: if(curr.name == playerName) { player.sendMessage(ChatColor.BLUE+" Your places:"); for(String[] place : curr.places) { player.sendMessage(ChatColor.AQUA+place[0]+" - X: "+place[1]+", Y: "+place[2]+", Z: "+place[3]); } } And this works: Code: if(curr.name.replace(playerName, "").length() == 0) { player.sendMessage(ChatColor.BLUE+" Your places:"); for(String[] place : curr.places) { player.sendMessage(ChatColor.AQUA+place[0]+" - X: "+place[1]+", Y: "+place[2]+", Z: "+place[3]); } } Do anybody have a suggesion for me?
If curr.name and playerName are both strings, you might want to try the equals or equalsIgnoreCase methods.
Thanks, this works. This means that if(string1 == string2) is not a proper way to compare to strings in java? Anyway now i have problems with teleportTo method. I'm experimenting with a teleport plugin, where you can save multiple places. These are stored in String arrays where [0] is the name of the place, and the rest are the coordinates. here is my code for the teleport: The coordinates are right i checked it trough the server console. Than what is the problem? Code: public void goPlace(Player player, String placeName) { for (jWorldUser curr : users ) { if(curr.name.equals(player.getName())) { for(String[] place : curr.places) { System.out.println(place[0]); System.out.println(Double.valueOf(place[1]).doubleValue()); System.out.println(Double.valueOf(place[2]).doubleValue()); System.out.println(Double.valueOf(place[3]).doubleValue()); if(place[0].equals(placeName)) player.teleportTo(new Location(player.getWorld(), Double.valueOf(place[1]).doubleValue(), Double.valueOf(place[2]).doubleValue(), Double.valueOf(place[3]).doubleValue())); player.sendMessage(ChatColor.BLUE+" Now you are at: "+placeName); break; } break; } } } I found the problem. Some Bracket was missing near the if
Ah, the pain of tablecopy.... Take a look at this site: http://leepoint.net/notes-java/data/expressions/22compareobjects.html