Use ComponentLogger + update dependencies

This commit is contained in:
Telesphoreo 2022-06-29 18:11:03 -05:00
parent 6763e12d81
commit 4a14f94158
3 changed files with 20 additions and 22 deletions

View File

@ -18,12 +18,12 @@ dependencies {
library "org.apache.maven.resolver:maven-resolver-connector-basic:1.8.0" library "org.apache.maven.resolver:maven-resolver-connector-basic:1.8.0"
library "org.apache.maven.resolver:maven-resolver-transport-http:1.8.0" library "org.apache.maven.resolver:maven-resolver-transport-http:1.8.0"
library "org.apache.maven:maven-resolver-provider:3.8.5" library "org.apache.maven:maven-resolver-provider:3.8.5"
library "org.eclipse.jetty:jetty-server:11.0.9" library "org.eclipse.jetty:jetty-server:11.0.11"
library "org.eclipse.jetty:jetty-servlet:11.0.9" library "org.eclipse.jetty:jetty-servlet:11.0.11"
library "org.eclipse.jetty:jetty-proxy:11.0.9" library "org.eclipse.jetty:jetty-proxy:11.0.11"
library "com.google.code.gson:gson:2.9.0" library "com.google.code.gson:gson:2.9.0"
compileOnly "io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT" compileOnly "io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT"
compileOnly("com.github.MilkBowl:VaultAPI:1.7") { compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
exclude group: "org.bukkit", module: "bukkit" exclude group: "org.bukkit", module: "bukkit"
} }
implementation "org.bstats:bstats-base:3.0.0" implementation "org.bstats:bstats-base:3.0.0"

View File

@ -3,11 +3,12 @@ package dev.plex.util;
import dev.plex.Plex; import dev.plex.Plex;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit; import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import org.bukkit.ChatColor;
public class PlexLog public class PlexLog
{ {
private static final ComponentLogger logger = ComponentLogger.logger("");
public static void log(String message, Object... strings) public static void log(String message, Object... strings)
{ {
for (int i = 0; i < strings.length; i++) for (int i = 0; i < strings.length; i++)
@ -17,12 +18,12 @@ public class PlexLog
message = message.replace("{" + i + "}", strings[i].toString()); message = message.replace("{" + i + "}", strings[i].toString());
} }
} }
Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.YELLOW + "[Plex] " + ChatColor.GRAY + "%s", message)); logger.info(PlexUtils.mmDeserialize("<yellow>[Plex] <gray>" + message));
} }
public static void log(Component component) public static void log(Component component)
{ {
Bukkit.getConsoleSender().sendMessage(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY)); logger.info(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
} }
public static void error(String message, Object... strings) public static void error(String message, Object... strings)
@ -34,8 +35,7 @@ public class PlexLog
message = message.replace("{" + i + "}", strings[i].toString()); message = message.replace("{" + i + "}", strings[i].toString());
} }
} }
Bukkit.getConsoleSender().sendMessage(PlexUtils.mmDeserialize("<red>[Plex Error] <gold>" + message)); logger.error(PlexUtils.mmDeserialize("<red>[Plex Error] <gold>" + message));
// Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.RED + "[Plex Error] " + ChatColor.GOLD + "%s", message));
} }
public static void warn(String message, Object... strings) public static void warn(String message, Object... strings)
@ -47,23 +47,21 @@ public class PlexLog
message = message.replace("{" + i + "}", strings[i].toString()); message = message.replace("{" + i + "}", strings[i].toString());
} }
} }
// Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.YELLOW + "[Plex Warning] " + ChatColor.GOLD + "%s", message)); logger.warn(PlexUtils.mmDeserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
Bukkit.getConsoleSender().sendMessage(PlexUtils.mmDeserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
} }
public static void debug(String message, Object... strings) public static void debug(String message, Object... strings)
{ {
for (int i = 0; i < strings.length; i++)
{
if (message.contains("{" + i + "}"))
{
message = message.replace("{" + i + "}", strings[i].toString());
}
}
if (Plex.get().config.getBoolean("debug")) if (Plex.get().config.getBoolean("debug"))
{ {
Bukkit.getConsoleSender().sendMessage(PlexUtils.mmDeserialize("<dark_purple>[Plex Debug] <gold>" + message)); for (int i = 0; i < strings.length; i++)
// Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.DARK_PURPLE + "[Plex Debug] " + ChatColor.GOLD + "%s", message)); {
if (message.contains("{" + i + "}"))
{
message = message.replace("{" + i + "}", strings[i].toString());
}
}
logger.info(PlexUtils.mmDeserialize("<dark_purple>[Plex Debug] <gold>" + message));
} }
} }
} }

View File

@ -124,7 +124,7 @@ public class PlexUtils implements PlexBase
{ {
aprilFools = plugin.config.getBoolean("april_fools"); aprilFools = plugin.config.getBoolean("april_fools");
} }
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)); ZonedDateTime date = ZonedDateTime.now(ZoneId.systemDefault());
if (aprilFools && date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1) if (aprilFools && date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1)
{ {
Component component = MINI_MESSAGE.deserialize(input); // removes existing tags Component component = MINI_MESSAGE.deserialize(input); // removes existing tags