package xyz.etztech.deluxegroups; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.dynmap.DynmapAPI; 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 yes = new ArrayList<>(Arrays.asList("yes", "true", "1")); List no = new ArrayList<>(Arrays.asList("no", "false", "0")); return yes.contains(text) ? true : no.contains(text) ? false : null; } public static void setupDynmap(Object dynmap) { Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "IMPORTANT: Disabling Dynmap Game->Web Chat. All web chat will be handled by DeluxeGroups."); ((DynmapAPI) dynmap).setDisableChatToWebProcessing(true); } public static List trimmed(List list) { for (int i = 0; i < list.size(); i++) { list.set(i, list.get(i).trim()); } return list; } }