*
* @return <code>true</code> if the user is close enough to have the window
* open, <code>false</code> otherwise.
*/
public boolean isCloseEnough() {
final User user = User.get();
if ((user != null) && (parent != null)) {
// null checks are fixes for Bug 1825678:
// NullPointerException happened
// after double clicking one
// monster and a fast double
// click on another monster
// Check if the parent is user
RPObject root = parent.getRPObject().getBaseContainer();
// We don't want to close our own stuff
// The root entity may have been removed, but still if it was
// the user we do not want to close it.
// User may have been changed by the main thread, so we can not rely
// on user.getRPObject() being equal to root. (bug #3159058)
final String type = root.getRPClass().getName();
if (type.equals("player") && root.has("name")) {
if (StendhalClient.get().getCharacter().equalsIgnoreCase(
root.get("name"))) {
return true;
}
}
return isCloseEnough(user.getX(), user.getY());
}
return true;
}