From 092130674bce43424ca5bfe8bf6696fe40a26ed7 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Thu, 16 Oct 2014 20:50:14 -0700 Subject: [PATCH] More accurate offline player search by name. Will now prefer a perfect (case sensitive) match and only return a case-insensitive match when there's no perfect match. --- src/me/ryanhamshire/GriefPrevention/GriefPrevention.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 9d96854..77d55a1 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -2133,6 +2133,7 @@ public class GriefPrevention extends JavaPlugin targetPlayer = this.getServer().getPlayer(name); if(targetPlayer != null) return targetPlayer; + OfflinePlayer bestMatch = null; if(searchOffline) { //then search offline players @@ -2141,13 +2142,13 @@ public class GriefPrevention extends JavaPlugin { if(players[i].getName().equalsIgnoreCase(name)) { - return players[i]; + bestMatch = players[i]; + if(bestMatch.getName().equals(name)) return bestMatch; } } } - //if none found, return null - return null; + return bestMatch; } //helper method to resolve a player name from the player's UUID