mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-23 02:55:40 +01:00
+ Add Utility class PlayerFinder
This commit is contained in:
parent
9d6da70404
commit
6ab4b52eb9
@ -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;
|
||||
|
34
src/main/java/me/blackvein/quests/util/PlayerFinder.java
Normal file
34
src/main/java/me/blackvein/quests/util/PlayerFinder.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user