fancydialogs: Make log level configurable

This commit is contained in:
Oliver
2025-05-31 11:12:46 +02:00
committed by Oliver
parent 7bad6fbe35
commit d566907305
2 changed files with 12 additions and 0 deletions

View File

@@ -66,6 +66,10 @@ public class FancyDialogsPlugin extends JavaPlugin {
fdConfig = new FancyDialogsConfig(); fdConfig = new FancyDialogsConfig();
fdConfig.load(); fdConfig.load();
if (!fdConfig.getLogLevel().equalsIgnoreCase("INFO")) {
fancyLogger.setCurrentLevel(LogLevel.valueOf(fdConfig.getLogLevel().toUpperCase()));
}
translator = new Translator(new TextConfig("#32e347", "#35ad1d", "#81E366", "#E3CA66", "#E36666", "")); translator = new Translator(new TextConfig("#32e347", "#35ad1d", "#81E366", "#E3CA66", "#E36666", ""));
translator.loadLanguages(getDataFolder().getAbsolutePath()); translator.loadLanguages(getDataFolder().getAbsolutePath());
final Language selectedLanguage = translator.getLanguages().stream() final Language selectedLanguage = translator.getLanguages().stream()

View File

@@ -9,6 +9,7 @@ import java.util.List;
public class FancyDialogsConfig { public class FancyDialogsConfig {
private String language; private String language;
private String logLevel;
private String welcomeDialogID; private String welcomeDialogID;
private String quickActionsDialogID; private String quickActionsDialogID;
@@ -19,6 +20,9 @@ public class FancyDialogsConfig {
language = (String) ConfigHelper.getOrDefault(config, "language", "default"); language = (String) ConfigHelper.getOrDefault(config, "language", "default");
config.setInlineComments("language", List.of("The language of the plugin.")); config.setInlineComments("language", List.of("The language of the plugin."));
logLevel = (String) ConfigHelper.getOrDefault(config, "log_level", "INFO");
config.setInlineComments("log_level", List.of("The log level of the plugin. Possible values: DEBUG, INFO, WARN, ERROR."));
welcomeDialogID = (String) ConfigHelper.getOrDefault(config, "welcome_dialog_id", "welcome-dialog"); welcomeDialogID = (String) ConfigHelper.getOrDefault(config, "welcome_dialog_id", "welcome-dialog");
config.setInlineComments("welcome_dialog_id", List.of("The ID of the dialog which will be shown to the player when they join the server for the first time.")); config.setInlineComments("welcome_dialog_id", List.of("The ID of the dialog which will be shown to the player when they join the server for the first time."));
@@ -30,6 +34,10 @@ public class FancyDialogsConfig {
return language; return language;
} }
public String getLogLevel() {
return logLevel;
}
public String getWelcomeDialogID() { public String getWelcomeDialogID() {
return welcomeDialogID; return welcomeDialogID;
} }