48 lines
1.6 KiB
Java
48 lines
1.6 KiB
Java
package xyz.etztech.deluxegroups;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.io.PrintWriter;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
|
|
public class DeluxeUtil {
|
|
|
|
public static void sms(Player player, String message) {
|
|
player.sendMessage(message);
|
|
}
|
|
|
|
public static UUID asUUID(String uuid) {
|
|
try {
|
|
if (uuid.contains("-") && uuid.length() == 36) {
|
|
return UUID.fromString(uuid);
|
|
} else if (uuid.length() == 32) {
|
|
return UUID.fromString(uuid.substring(0, 8) + "-" + uuid.substring(8, 12) + "-" + uuid.substring(12, 16)
|
|
+ "-" + uuid.substring(16, 20) + "-" + uuid.substring(20, 32));
|
|
} else {
|
|
return null;
|
|
}
|
|
} catch (Exception ex) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void log(PrintWriter logger, String message, boolean sendToConsole) {
|
|
if (sendToConsole) {
|
|
Bukkit.getServer().getConsoleSender().sendMessage(message);
|
|
}
|
|
Date date = new Date();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("M/d/yy h:m a");
|
|
String text = "[" + sdf.format(date) + "] " + message;
|
|
logger.append(text + "\n");
|
|
logger.flush();
|
|
}
|
|
|
|
public static Boolean resolveBoolean(String text) {
|
|
List<String> yes = new ArrayList<>(Arrays.asList("yes", "true", "1"));
|
|
List<String> no = new ArrayList<>(Arrays.asList("no", "false", "0"));
|
|
return yes.contains(text) ? true : no.contains(text) ? false : null;
|
|
}
|
|
}
|