Working on a plugin in Java. everything works. I come to this one if statement and it just fails. I've tried changing the values from int to string and vice versa, it simply won't budge. I logged the coordinates. I try to compare them as strings.
Code:
String locationx = plugin.getConfig().getString("locationx");
String eventlocationx = Integer.toString(event.getClickedBlock().getX());
String locationy = plugin.getConfig().getString("locationy");
String eventlocationy = Integer.toString(event.getClickedBlock().getY());
String locationz = plugin.getConfig().getString("locationz");
String eventlocationz = Integer.toString(event.getClickedBlock().getZ());
if (locationx == eventlocationx && locationy == eventlocationy && locationz == eventlocationz)
{
System.out.println("SUCCESS: Passed coordinate check on the right click.");
return true;
}
else
{
System.out.println(locationx);
System.out.println(eventlocationx);
System.out.println(locationy);
System.out.println(eventlocationy);
System.out.println(locationz);
System.out.println(eventlocationz);
System.out.println("ERROR: Failed on the right click coordinate check.");
return false;
}
config:
locationx: '-226'
locationy: '64'
locationz: '266'
console log:
-226
[11:31:47 INFO]: -226
[11:31:47 INFO]: 64
[11:31:47 INFO]: 64
[11:31:47 INFO]: 266
[11:31:47 INFO]: 266
[11:31:47 INFO]: ERROR: Failed on the right click coordinate check.
I hope anyone can help me out.