+ Add Utility class PlayerFinder

This commit is contained in:
PikachuEXE 2015-04-08 18:10:53 +08:00
parent 9d6da70404
commit 6ab4b52eb9
2 changed files with 35 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import me.blackvein.quests.util.ColorUtil;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import me.blackvein.quests.util.PlayerFinder;
import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
import net.citizensnpcs.api.CitizensAPI;

View File

@ -0,0 +1,34 @@
package me.blackvein.quests.util;
import org.bukkit.entity.Player;
import org.bukkit.Bukkit;
public class PlayerFinder {
public static Player findOnlinePlayerByPartialCaseInsensitiveNameMatch(String queryString) {
Player target_online_player = null;
for (Player online_player : Bukkit.getOnlinePlayers()) {
if (online_player.getName().toLowerCase().contains(queryString.toLowerCase())) {
target_online_player = online_player;
break;
}
}
return target_online_player;
}
public static Player findOnlinePlayerByExactCaseInsensitiveNameMatch(String queryString) {
Player target_online_player = null;
for (Player online_player : Bukkit.getOnlinePlayers()) {
if (online_player.getName().equalsIgnoreCase(queryString)) {
target_online_player = online_player;
break;
}
}
return target_online_player;
}
}