2020-06-18 22:24:02 +00:00
|
|
|
package me.totalfreedom.tfguilds.util;
|
|
|
|
|
2020-07-13 00:40:11 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2020-06-18 22:24:02 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
2020-06-22 17:51:32 +00:00
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
2020-07-12 03:34:30 +00:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2020-06-18 22:24:02 +00:00
|
|
|
|
|
|
|
public class GUtil
|
|
|
|
{
|
2020-07-14 04:27:55 +00:00
|
|
|
private static final SimpleDateFormat STANDARD = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
|
2020-06-18 22:24:02 +00:00
|
|
|
|
2020-07-13 00:40:11 +00:00
|
|
|
public static String flatten(String s)
|
2020-06-18 22:24:02 +00:00
|
|
|
{
|
2020-07-13 00:40:11 +00:00
|
|
|
String[] split = s.split(" ");
|
|
|
|
for (int i = 0; i < split.length; i++)
|
2020-06-20 21:23:53 +00:00
|
|
|
{
|
2020-07-13 00:40:11 +00:00
|
|
|
split[i] = ChatColor.stripColor(colorize(split[i].toLowerCase()));
|
2020-06-20 21:23:53 +00:00
|
|
|
}
|
2020-07-13 00:40:11 +00:00
|
|
|
return StringUtils.join(split, "_");
|
2020-06-20 21:23:53 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 00:40:11 +00:00
|
|
|
public static String colorize(String string)
|
2020-06-18 22:24:02 +00:00
|
|
|
{
|
2020-07-13 00:40:11 +00:00
|
|
|
Matcher matcher = Pattern.compile("&#[a-f0-9A-F]{6}").matcher(string);
|
|
|
|
while (matcher.find())
|
2020-06-18 22:24:02 +00:00
|
|
|
{
|
2020-07-13 00:40:11 +00:00
|
|
|
String code = matcher.group().replace("&", "");
|
|
|
|
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
2020-06-18 22:24:02 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 00:40:11 +00:00
|
|
|
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
|
|
return string;
|
2020-06-18 22:24:02 +00:00
|
|
|
}
|
2020-07-12 03:34:30 +00:00
|
|
|
|
2020-07-13 00:40:11 +00:00
|
|
|
public static String format(long time)
|
2020-07-12 03:34:30 +00:00
|
|
|
{
|
2020-07-13 00:40:11 +00:00
|
|
|
Date date = new Date(time);
|
|
|
|
return STANDARD.format(date);
|
2020-07-12 03:34:30 +00:00
|
|
|
}
|
2020-06-15 21:39:52 +00:00
|
|
|
}
|