From 10d84b5cc842a990c79ff67ae54168b2de9c9c0e Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Sat, 2 Jul 2022 02:21:48 +0200 Subject: [PATCH] Further improve downsampled colors --- .../paper/managers/Configuration.java | 60 +++++++++++++++++++ .../notquests/paper/managers/DataManager.java | 37 +++++++++--- .../notquests/paper/managers/LogManager.java | 39 ++++++------ 3 files changed, 112 insertions(+), 24 deletions(-) diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/managers/Configuration.java b/paper/src/main/java/rocks/gravili/notquests/paper/managers/Configuration.java index 2cd532168..7d5562d95 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/managers/Configuration.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/managers/Configuration.java @@ -131,11 +131,21 @@ public class Configuration { private String colorsConsolePrefixPrefix = "<#393e46>["; private String colorsConsolePrefixSuffix = "<#393e46>]<#636c73>: "; private String colorsConsoleInfoDefault = "
"; + private String colorsConsoleInfoDefaultDownsampled = ""; private String colorsConsoleInfoData = ""; + private String colorsConsoleInfoDataDownsampled = ""; + private String colorsConsoleInfoLanguage = ""; + private String colorsConsoleInfoLanguageDownsampled = ""; + private String colorsConsoleWarnDefault = ""; + private String colorsConsoleWarnDefaultDownsampled = ""; + private String colorsConsoleSevereDefault = ""; + private String colorsConsoleSevereDefaultDownsampled = ""; + private String colorsConsoleDebugDefault = ""; + private String colorsConsoleDebugDownsampled = ""; private List colorsMain; private List colorsHighlight; @@ -1041,4 +1051,54 @@ public boolean isConsoleColorsDownsampleColors() { public void setConsoleColorsDownsampleColors(boolean consoleColorsDownsampleColors) { this.consoleColorsDownsampleColors = consoleColorsDownsampleColors; } + + public String getColorsConsoleInfoDefaultDownsampled() { + return colorsConsoleInfoDefaultDownsampled; + } + + public void setColorsConsoleInfoDefaultDownsampled(String colorsConsoleInfoDefaultDownsampled) { + this.colorsConsoleInfoDefaultDownsampled = colorsConsoleInfoDefaultDownsampled; + } + + public String getColorsConsoleInfoDataDownsampled() { + return colorsConsoleInfoDataDownsampled; + } + + public void setColorsConsoleInfoDataDownsampled(String colorsConsoleInfoDataDownsampled) { + this.colorsConsoleInfoDataDownsampled = colorsConsoleInfoDataDownsampled; + } + + public String getColorsConsoleInfoLanguageDownsampled() { + return colorsConsoleInfoLanguageDownsampled; + } + + public void setColorsConsoleInfoLanguageDownsampled( + String colorsConsoleInfoLanguageDownsampled) { + this.colorsConsoleInfoLanguageDownsampled = colorsConsoleInfoLanguageDownsampled; + } + + public String getColorsConsoleWarnDefaultDownsampled() { + return colorsConsoleWarnDefaultDownsampled; + } + + public void setColorsConsoleWarnDefaultDownsampled(String colorsConsoleWarnDefaultDownsampled) { + this.colorsConsoleWarnDefaultDownsampled = colorsConsoleWarnDefaultDownsampled; + } + + public String getColorsConsoleSevereDefaultDownsampled() { + return colorsConsoleSevereDefaultDownsampled; + } + + public void setColorsConsoleSevereDefaultDownsampled( + String colorsConsoleSevereDefaultDownsampled) { + this.colorsConsoleSevereDefaultDownsampled = colorsConsoleSevereDefaultDownsampled; + } + + public String getColorsConsoleDebugDownsampled() { + return colorsConsoleDebugDownsampled; + } + + public void setColorsConsoleDebugDownsampled(String colorsConsoleDebugDownsampled) { + this.colorsConsoleDebugDownsampled = colorsConsoleDebugDownsampled; + } } diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java b/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java index 211faab26..c54522579 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java @@ -729,30 +729,53 @@ public void updateAndReadGeneralConfig() { "<#393e46>]<#636c73>: " )); configuration.setColorsConsoleInfoDefault(getGeneralConfigString( - "visual.colors.console.info.default", + "visual.colors.console.info.default.normal", "
" )); + configuration.setColorsConsoleInfoDefaultDownsampled(getGeneralConfigString( + "visual.colors.console.info.default.downsampled", + "" + )); configuration.setColorsConsoleInfoData(getGeneralConfigString( - "visual.colors.console.info.data", + "visual.colors.console.info.data.normal", "" )); + configuration.setColorsConsoleInfoDataDownsampled(getGeneralConfigString( + "visual.colors.console.info.data.downsampled", + "" + )); configuration.setColorsConsoleInfoLanguage(getGeneralConfigString( - "visual.colors.console.info.language", + "visual.colors.console.info.language.normal", "" )); + configuration.setColorsConsoleInfoLanguageDownsampled(getGeneralConfigString( + "visual.colors.console.info.language.downsampled", + "" + )); configuration.setColorsConsoleWarnDefault(getGeneralConfigString( - "visual.colors.console.warn.default", + "visual.colors.console.warn.default.normal", "" )); + configuration.setColorsConsoleWarnDefaultDownsampled(getGeneralConfigString( + "visual.colors.console.warn.default.downsampled", + "" + )); configuration.setColorsConsoleSevereDefault(getGeneralConfigString( - "visual.colors.console.severe.default", + "visual.colors.console.severe.default.normal", "" )); + configuration.setColorsConsoleSevereDefaultDownsampled(getGeneralConfigString( + "visual.colors.console.severe.default.downsampled", + "" + )); configuration.setColorsConsoleDebugDefault(getGeneralConfigString( - "visual.colors.console.debug.default", + "visual.colors.console.debug.default.normal", "" )); - + configuration.setColorsConsoleDebugDownsampled(getGeneralConfigString( + "visual.colors.console.debug.default.downsampled", + "" + )); //CustomTags configuration.setColorsMain(getGeneralConfigStringList( "visual.colors.tags.main", diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/managers/LogManager.java b/paper/src/main/java/rocks/gravili/notquests/paper/managers/LogManager.java index 774617cf5..266c51b01 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/managers/LogManager.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/managers/LogManager.java @@ -29,10 +29,10 @@ public class LogManager { private final NotQuests main; - private final Component prefix; + private Component prefix; + private final Component prefixDownsampled, prefixNoColor; private final ArrayList severeLogs, warnLogs; - private ConsoleCommandSender consoleSender; - private String prefixText; + private final ConsoleCommandSender consoleSender; public LogManager(final NotQuests main) { this.main = main; @@ -41,15 +41,18 @@ public LogManager(final NotQuests main) { consoleSender = Bukkit.getConsoleSender(); - prefixText = "<#393e46>[NotQuests<#393e46>]<#636c73>: "; - prefix = main.parse(prefixText); + prefix = main.parse("<#393e46>[NotQuests<#393e46>]<#636c73>: "); + prefixDownsampled = main.parse("[NotQuests]: "); + prefixNoColor = Component.text("[NotQuests]: "); } public void lateInit() { - prefixText = + prefix = + main.parse( main.getConfiguration().getColorsConsolePrefixPrefix() + "NotQuests" - + main.getConfiguration().getColorsConsolePrefixSuffix(); + + main.getConfiguration().getColorsConsolePrefixSuffix() + ); } public final ArrayList getErrorLogs() { @@ -68,33 +71,35 @@ private void log( final Level level, final LogCategory logCategory, final String color, final String message) { if (main.getConfiguration().isConsoleColorsEnabled()) { if (!main.getConfiguration().isConsoleColorsDownsampleColors()) { - consoleSender.sendMessage(main.parse(prefixText + color + message)); + consoleSender.sendMessage( prefix.append(main.parse(color + message))); } else { - final Component component = main.parse(prefixText + color + message); + final Component component = main.parse(message); consoleSender.sendMessage( + prefixDownsampled.append(main.parse(color)).append( GsonComponentSerializer.gson() .deserializeFromTree( // Convert back to component GsonComponentSerializer.builder() .downsampleColors() .build() .serializeToTree( // Convert to text - component))); + component)))); } } else { consoleSender.sendMessage( + prefixNoColor.append( main.parse( main.getMiniMessage() - .stripTags(prefixText + message, main.getMessageManager().getTagResolver()))); + .stripTags(message, main.getMessageManager().getTagResolver())))); } } public void info(final LogCategory logCategory, final String message) { if (logCategory == LogCategory.DEFAULT) { - log(Level.INFO, logCategory, main.getConfiguration().getColorsConsoleInfoDefault(), message); + log(Level.INFO, logCategory, main.getConfiguration().isConsoleColorsDownsampleColors() ? main.getConfiguration().getColorsConsoleInfoDefaultDownsampled() : main.getConfiguration().getColorsConsoleInfoDefault(), message); } else if (logCategory == LogCategory.DATA) { - log(Level.INFO, logCategory, main.getConfiguration().getColorsConsoleInfoData(), message); + log(Level.INFO, logCategory, main.getConfiguration().isConsoleColorsDownsampleColors() ? main.getConfiguration().getColorsConsoleInfoDataDownsampled() : main.getConfiguration().getColorsConsoleInfoData(), message); } else if (logCategory == LogCategory.LANGUAGE) { - log(Level.INFO, logCategory, main.getConfiguration().getColorsConsoleInfoLanguage(), message); + log(Level.INFO, logCategory, main.getConfiguration().isConsoleColorsDownsampleColors() ? main.getConfiguration().getColorsConsoleInfoLanguageDownsampled() : main.getConfiguration().getColorsConsoleInfoLanguage(), message); } } @@ -103,7 +108,7 @@ public void info(final String message) { } public void warn(final LogCategory logCategory, final String message) { - log(Level.WARNING, logCategory, main.getConfiguration().getColorsConsoleWarnDefault(), message); + log(Level.WARNING, logCategory, main.getConfiguration().isConsoleColorsDownsampleColors() ? main.getConfiguration().getColorsConsoleWarnDefaultDownsampled() : main.getConfiguration().getColorsConsoleWarnDefault(), message); warnLogs.add(message); } @@ -115,7 +120,7 @@ public void severe(final LogCategory logCategory, final String message) { log( Level.SEVERE, logCategory, - main.getConfiguration().getColorsConsoleSevereDefault(), + main.getConfiguration().isConsoleColorsDownsampleColors() ? main.getConfiguration().getColorsConsoleSevereDefaultDownsampled() : main.getConfiguration().getColorsConsoleSevereDefault(), message); severeLogs.add(message); } @@ -126,7 +131,7 @@ public void severe(final String message) { public void debug(final LogCategory logCategory, final String message) { if (main.getConfiguration().debug) { - log(Level.FINE, logCategory, main.getConfiguration().getColorsConsoleDebugDefault(), message); + log(Level.FINE, logCategory, main.getConfiguration().isConsoleColorsDownsampleColors() ? main.getConfiguration().getColorsConsoleDebugDownsampled() : main.getConfiguration().getColorsConsoleDebugDefault(), message); } }