57 lines
1.3 KiB
Java
57 lines
1.3 KiB
Java
package xyz.etztech.minealert;
|
|
|
|
import net.md_5.bungee.api.ChatColor;
|
|
import net.md_5.bungee.api.chat.TextComponent;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.command.ConsoleCommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public enum Color {
|
|
DEFAULT("#AAAAAA"),
|
|
ERROR("#F14668"),
|
|
INFO("#3298DC"),
|
|
PRIMARY("#3273DC");
|
|
|
|
private final String hex;
|
|
private final ChatColor chatColor;
|
|
|
|
Color(String hex) {
|
|
this.hex = hex;
|
|
this.chatColor = ChatColor.of(hex);
|
|
}
|
|
|
|
public String getHex() {
|
|
return hex;
|
|
}
|
|
|
|
public int getInt() {
|
|
return hexToInt(hex);
|
|
}
|
|
|
|
public ChatColor getChatColor() {
|
|
return chatColor;
|
|
}
|
|
|
|
public void sms(CommandSender commandSender, String message) {
|
|
if (commandSender instanceof ConsoleCommandSender) {
|
|
MineAlert.getInstance().log(message);
|
|
return;
|
|
}
|
|
TextComponent text = new TextComponent(message);
|
|
text.setColor(this.chatColor);
|
|
commandSender.spigot().sendMessage(text);
|
|
}
|
|
|
|
public static int hexToInt(String hex) {
|
|
if (hex.startsWith("#")) {
|
|
hex = hex.substring(1);
|
|
}
|
|
|
|
if (hex.length() != 6) {
|
|
return 0;
|
|
}
|
|
|
|
return Integer.parseInt(hex, 16);
|
|
}
|
|
}
|