2021-01-03 07:21:15 +00:00
|
|
|
package dev.plex.util;
|
2020-10-27 18:14:34 +00:00
|
|
|
|
2022-03-18 01:18:35 +00:00
|
|
|
import dev.plex.Plex;
|
2022-04-01 07:54:22 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
2022-06-29 23:11:03 +00:00
|
|
|
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
2020-10-27 18:14:34 +00:00
|
|
|
|
2022-03-18 01:18:35 +00:00
|
|
|
public class PlexLog
|
2020-10-27 18:14:34 +00:00
|
|
|
{
|
2022-06-29 23:11:03 +00:00
|
|
|
private static final ComponentLogger logger = ComponentLogger.logger("");
|
|
|
|
|
2022-02-28 06:28:00 +00:00
|
|
|
public static void log(String message, Object... strings)
|
2020-10-27 18:14:34 +00:00
|
|
|
{
|
2022-02-28 06:28:00 +00:00
|
|
|
for (int i = 0; i < strings.length; i++)
|
|
|
|
{
|
|
|
|
if (message.contains("{" + i + "}"))
|
|
|
|
{
|
|
|
|
message = message.replace("{" + i + "}", strings[i].toString());
|
|
|
|
}
|
|
|
|
}
|
2022-06-29 23:11:03 +00:00
|
|
|
logger.info(PlexUtils.mmDeserialize("<yellow>[Plex] <gray>" + message));
|
2020-10-27 18:14:34 +00:00
|
|
|
}
|
|
|
|
|
2022-04-01 07:54:22 +00:00
|
|
|
public static void log(Component component)
|
|
|
|
{
|
2022-06-29 23:11:03 +00:00
|
|
|
logger.info(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
2022-04-01 07:54:22 +00:00
|
|
|
}
|
|
|
|
|
2022-02-28 06:28:00 +00:00
|
|
|
public static void error(String message, Object... strings)
|
2020-10-27 18:14:34 +00:00
|
|
|
{
|
2022-02-28 06:28:00 +00:00
|
|
|
for (int i = 0; i < strings.length; i++)
|
|
|
|
{
|
|
|
|
if (message.contains("{" + i + "}"))
|
|
|
|
{
|
|
|
|
message = message.replace("{" + i + "}", strings[i].toString());
|
|
|
|
}
|
|
|
|
}
|
2022-06-29 23:11:03 +00:00
|
|
|
logger.error(PlexUtils.mmDeserialize("<red>[Plex Error] <gold>" + message));
|
2022-04-19 20:33:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void warn(String message, Object... strings)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < strings.length; i++)
|
|
|
|
{
|
|
|
|
if (message.contains("{" + i + "}"))
|
|
|
|
{
|
|
|
|
message = message.replace("{" + i + "}", strings[i].toString());
|
|
|
|
}
|
|
|
|
}
|
2022-06-29 23:11:03 +00:00
|
|
|
logger.warn(PlexUtils.mmDeserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
2022-01-27 07:00:03 +00:00
|
|
|
}
|
|
|
|
|
2022-02-28 06:28:00 +00:00
|
|
|
public static void debug(String message, Object... strings)
|
2022-01-27 07:00:03 +00:00
|
|
|
{
|
2022-06-29 23:11:03 +00:00
|
|
|
if (Plex.get().config.getBoolean("debug"))
|
2022-02-28 06:28:00 +00:00
|
|
|
{
|
2022-06-29 23:11:03 +00:00
|
|
|
for (int i = 0; i < strings.length; i++)
|
2022-02-28 06:28:00 +00:00
|
|
|
{
|
2022-06-29 23:11:03 +00:00
|
|
|
if (message.contains("{" + i + "}"))
|
|
|
|
{
|
|
|
|
message = message.replace("{" + i + "}", strings[i].toString());
|
|
|
|
}
|
2022-02-28 06:28:00 +00:00
|
|
|
}
|
2022-06-29 23:11:03 +00:00
|
|
|
logger.info(PlexUtils.mmDeserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
2022-01-27 07:00:03 +00:00
|
|
|
}
|
2020-10-27 18:14:34 +00:00
|
|
|
}
|
|
|
|
}
|