mirror of
https://github.com/Shiewk/SModeration.git
synced 2026-04-28 05:54:16 +02:00
Add mute command, command usages and smaller improvements
This commit is contained in:
@@ -2,15 +2,31 @@ package de.shiewk.smoderation.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class PlayerUtil {
|
||||
private PlayerUtil(){}
|
||||
|
||||
public static String offlinePlayerName(UUID uuid){
|
||||
public static final UUID UUID_CONSOLE = new UUID(0, 0);
|
||||
|
||||
public static @NotNull String offlinePlayerName(UUID uuid){
|
||||
if (uuid.equals(UUID_CONSOLE)){
|
||||
return "UUID_CONSOLE";
|
||||
}
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||
return player.getName() == null ? uuid.toString() : player.getName();
|
||||
}
|
||||
|
||||
public static @Nullable UUID offlinePlayerUUIDByName(String name){
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayerIfCached(name);// getOfflinePlayerIfCached(String) is safer (I have experience with getOfflinePlayer(String) returning wrong UUIDs)
|
||||
if (offlinePlayer != null) {
|
||||
return offlinePlayer.getUniqueId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user