40 lines
998 B
Java
40 lines
998 B
Java
package fr.xephi.authme.util;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
/**
|
|
* Player utilities.
|
|
*/
|
|
public final class PlayerUtils {
|
|
|
|
// Utility class
|
|
private PlayerUtils() {
|
|
}
|
|
|
|
private static final boolean IS_LEAVES_SERVER = Utils.isClassLoaded("top.leavesmc.leaves.LeavesConfig");
|
|
|
|
/**
|
|
* Returns the IP of the given player.
|
|
*
|
|
* @param player The player to return the IP address for
|
|
* @return The player's IP address
|
|
*/
|
|
public static String getPlayerIp(Player player) {
|
|
return player.getAddress().getAddress().getHostAddress();
|
|
}
|
|
|
|
/**
|
|
* Returns if the player is an NPC or not.
|
|
*
|
|
* @param player The player to check
|
|
* @return True if the player is an NPC, false otherwise
|
|
*/
|
|
public static boolean isNpc(Player player) {
|
|
if (IS_LEAVES_SERVER) {
|
|
return player.hasMetadata("NPC") || player.getAddress() == null;
|
|
} else {
|
|
return player.hasMetadata("NPC");
|
|
}
|
|
}
|
|
}
|