Raxen/src/main/java/gq/unurled/raxen/utils/Utils.java

81 lines
2.2 KiB
Java
Raw Normal View History

2021-11-27 10:49:11 +00:00
package gq.unurled.raxen.utils;
2021-11-20 10:33:03 +00:00
2021-11-27 10:49:11 +00:00
import gq.unurled.raxen.Raxen;
2021-11-20 10:33:03 +00:00
import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
2021-11-20 10:33:03 +00:00
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
2021-11-20 10:33:03 +00:00
import org.bukkit.inventory.ItemStack;
import java.util.logging.Logger;
public class Utils {
private static final Logger logger = Raxen.getPluginLogger();
2021-11-20 10:33:03 +00:00
public static String color(String string) {
return ChatColor.translateAlternateColorCodes('&', string);
}
public static String decolor(String string) {
return ChatColor.stripColor(color(string));
}
public static void debug(Raxen main, String... strings) {
FileConfiguration config = main.getConfig();
if(config.getBoolean("debug")) {
for(String string : strings) {
logger.info(string);
}
}
}
2021-11-20 10:33:03 +00:00
public static void log(String... strings) {
for(String string : strings) {
logger.info(string);
}
}
public static void warn(String... strings) {
for(String string : strings) {
logger.warning(string);
}
}
public static void error(String... strings) {
for(String string : strings) {
logger.severe(string);
}
}
public static void msgPlayer(Player player, String... strings) {
for(String string : strings) {
player.sendMessage(Component.text(color(string)));
}
}
public static Inventory fillGreyPane(Inventory inv) {
Integer in = -1;
for (ItemStack it : inv) {
in++;
if (it == null || it.getType() == Material.AIR) {
inv.setItem(in, Items.greyPane());
}
}
return inv;
}
2021-11-20 10:33:03 +00:00
public static Component noPerms() {
return Component.text(color("&cYou don't have the permission to use this feature."));
}
public static Component error() {
return Component.text(color("&cAn Error has occurred. Please retry or contact an Admin."));
}
}