#OfflinePlayer instances not matching for same player

1 messages · Page 1 of 1 (latest)

silent hill
#

So basically my plugin is a town one. It stores player's as Residents and keeps an OfflinePlayer instance as an attribute. However, when I compare Bukkit.getOfflinePlayer() to it when the player's offline, it doesn't match

#

Here's some relevent code

#
        if (target == player) {
            // same player response
            return;
        }

        Resident targetR = town.getResident(target);
        if (targetR == null) {
            // not a resident response
            return;
        }```
#

Even though I'm typing the player's name EXACTLY during testing, the Bukkit.getOfflinePlayer() instance is still different to the stored instance

#

I'm guessing that this is just how Bukkit handles it, so is there any way around this?

twilit cove
#

Have you tried .equals

silent hill
#

Oh ffs hang on

silent hill
#

#Object.equals() compares the value as opposed to comparing references right?

twilit cove
#

It uses the equals method