diff --git a/common/src/main/java/net/william278/huskhomes/manager/RequestsManager.java b/common/src/main/java/net/william278/huskhomes/manager/RequestsManager.java index 4e0d5573..2426c90a 100644 --- a/common/src/main/java/net/william278/huskhomes/manager/RequestsManager.java +++ b/common/src/main/java/net/william278/huskhomes/manager/RequestsManager.java @@ -146,7 +146,10 @@ public void sendTeleportRequest(@NotNull OnlineUser requester, @NotNull String t final long expiry = Instant.now().getEpochSecond() + plugin.getSettings().getGeneral().getTeleportRequestExpiryTime(); final TeleportRequest request = new TeleportRequest(requester, type, expiry); - final Optional localTarget = plugin.getOnlineUser(targetUser); + + // Lookup the user locally first. If there's a username match globally, perform an exact local check + final Optional localTarget = plugin.isUserOnlineGlobally(targetUser) + ? plugin.getOnlineUserExact(targetUser) : plugin.getOnlineUser(targetUser); if (localTarget.isPresent()) { if (localTarget.get().equals(requester)) { throw new IllegalArgumentException("Cannot send a teleport request to yourself"); diff --git a/common/src/main/java/net/william278/huskhomes/user/UserProvider.java b/common/src/main/java/net/william278/huskhomes/user/UserProvider.java index 28c770bc..521c5850 100644 --- a/common/src/main/java/net/william278/huskhomes/user/UserProvider.java +++ b/common/src/main/java/net/william278/huskhomes/user/UserProvider.java @@ -68,8 +68,10 @@ default void setUserList(@NotNull String server, @NotNull List players) { getGlobalUserList().put(server, players); } - default boolean isUserOnline(@NotNull User user) { - return getOnlineUserMap().containsKey(user.getUuid()); + default boolean isUserOnlineGlobally(@NotNull String playerName) { + return getUserList().stream() + .map(u -> u.getName().toLowerCase(Locale.ENGLISH)) + .anyMatch(u -> u.equals(playerName.toLowerCase(Locale.ENGLISH))); } default Optional getOnlineUser(@NotNull String playerName) {