Skip to content

Commit

Permalink
Further improve downsampled colors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioGr committed Jul 2, 2022
1 parent 6bbf183 commit 10d84b5
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,21 @@ public class Configuration {
private String colorsConsolePrefixPrefix = "<#393e46>[<gradient:#E0EAFC:#CFDEF3>";
private String colorsConsolePrefixSuffix = "<#393e46>]<#636c73>: ";
private String colorsConsoleInfoDefault = "<main>";
private String colorsConsoleInfoDefaultDownsampled = "<gray>";
private String colorsConsoleInfoData = "<gradient:#1FA2FF:#12D8FA:#A6FFCB>";
private String colorsConsoleInfoDataDownsampled = "<blue>";

private String colorsConsoleInfoLanguage = "<gradient:#AA076B:#61045F>";
private String colorsConsoleInfoLanguageDownsampled = "<dark_purple>";

private String colorsConsoleWarnDefault = "<warn>";
private String colorsConsoleWarnDefaultDownsampled = "<yellow>";

private String colorsConsoleSevereDefault = "<error>";
private String colorsConsoleSevereDefaultDownsampled = "<red>";

private String colorsConsoleDebugDefault = "<unimportant>";
private String colorsConsoleDebugDownsampled = "<dark_gray>";

private List<String> colorsMain;
private List<String> colorsHighlight;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -729,30 +729,53 @@ public void updateAndReadGeneralConfig() {
"<#393e46>]<#636c73>: "
));
configuration.setColorsConsoleInfoDefault(getGeneralConfigString(
"visual.colors.console.info.default",
"visual.colors.console.info.default.normal",
"<main>"
));
configuration.setColorsConsoleInfoDefaultDownsampled(getGeneralConfigString(
"visual.colors.console.info.default.downsampled",
"<gray>"
));
configuration.setColorsConsoleInfoData(getGeneralConfigString(
"visual.colors.console.info.data",
"visual.colors.console.info.data.normal",
"<gradient:#1FA2FF:#12D8FA:#A6FFCB>"
));
configuration.setColorsConsoleInfoDataDownsampled(getGeneralConfigString(
"visual.colors.console.info.data.downsampled",
"<blue>"
));
configuration.setColorsConsoleInfoLanguage(getGeneralConfigString(
"visual.colors.console.info.language",
"visual.colors.console.info.language.normal",
"<gradient:#AA076B:#61045F>"
));
configuration.setColorsConsoleInfoLanguageDownsampled(getGeneralConfigString(
"visual.colors.console.info.language.downsampled",
"<dark_purple>"
));
configuration.setColorsConsoleWarnDefault(getGeneralConfigString(
"visual.colors.console.warn.default",
"visual.colors.console.warn.default.normal",
"<warn>"
));
configuration.setColorsConsoleWarnDefaultDownsampled(getGeneralConfigString(
"visual.colors.console.warn.default.downsampled",
"<yellow>"
));
configuration.setColorsConsoleSevereDefault(getGeneralConfigString(
"visual.colors.console.severe.default",
"visual.colors.console.severe.default.normal",
"<error>"
));
configuration.setColorsConsoleSevereDefaultDownsampled(getGeneralConfigString(
"visual.colors.console.severe.default.downsampled",
"<red>"
));
configuration.setColorsConsoleDebugDefault(getGeneralConfigString(
"visual.colors.console.debug.default",
"visual.colors.console.debug.default.normal",
"<unimportant>"
));

configuration.setColorsConsoleDebugDownsampled(getGeneralConfigString(
"visual.colors.console.debug.default.downsampled",
"<dark_gray>"
));
//CustomTags
configuration.setColorsMain(getGeneralConfigStringList(
"visual.colors.tags.main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> severeLogs, warnLogs;
private ConsoleCommandSender consoleSender;
private String prefixText;
private final ConsoleCommandSender consoleSender;

public LogManager(final NotQuests main) {
this.main = main;
Expand All @@ -41,15 +41,18 @@ public LogManager(final NotQuests main) {

consoleSender = Bukkit.getConsoleSender();

prefixText = "<#393e46>[<gradient:#E0EAFC:#CFDEF3>NotQuests<#393e46>]<#636c73>: ";
prefix = main.parse(prefixText);
prefix = main.parse("<#393e46>[<gradient:#E0EAFC:#CFDEF3>NotQuests<#393e46>]<#636c73>: ");
prefixDownsampled = main.parse("<gray>[<aqua>NotQuests</aqua>]</gray><dark_gray>: ");
prefixNoColor = Component.text("[NotQuests]: ");
}

public void lateInit() {
prefixText =
prefix =
main.parse(
main.getConfiguration().getColorsConsolePrefixPrefix()
+ "NotQuests"
+ main.getConfiguration().getColorsConsolePrefixSuffix();
+ main.getConfiguration().getColorsConsolePrefixSuffix()
);
}

public final ArrayList<String> getErrorLogs() {
Expand All @@ -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);
}
}

Expand All @@ -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);
}

Expand All @@ -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);
}
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 10d84b5

Please sign in to comment.