mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-04-02 09:25:56 +02:00
[BLEEDING] Move configuration for logging back-ends to sub-sections.
This commit is contained in:
parent
be91af4e51
commit
2bf28c4982
@ -98,9 +98,9 @@ public class LogAction extends ActionWithParameters<ViolationData, ActionList> {
|
||||
@Override
|
||||
public Action<ViolationData, ActionList> getOptimizedCopy(final ConfigFileWithActions<ViolationData, ActionList> config, final Integer threshold) {
|
||||
if (!config.getBoolean(ConfPaths.LOGGING_ACTIVE)) return null;
|
||||
final boolean toConsole = this.toConsole && config.getBoolean(ConfPaths.LOGGING_CONSOLE);
|
||||
final boolean toFile = this.toFile&& config.getBoolean(ConfPaths.LOGGING_FILE);
|
||||
final boolean toChat= this.toChat&& config.getBoolean(ConfPaths.LOGGING_INGAMECHAT);
|
||||
final boolean toConsole = this.toConsole && config.getBoolean(ConfPaths.LOGGING_BACKEND_CONSOLE_ACTIVE);
|
||||
final boolean toFile = this.toFile&& config.getBoolean(ConfPaths.LOGGING_BACKEND_FILE_ACTIVE);
|
||||
final boolean toChat= this.toChat&& config.getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_ACTIVE);
|
||||
if (!toChat && ! toConsole && !toFile) return null;
|
||||
return new LogAction(name, delay, repeat, toChat, toConsole, toFile, message);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class ReloadCommand extends NCPCommand {
|
||||
ConfigManager.cleanup();
|
||||
ConfigManager.init(plugin);
|
||||
StaticLogFile.cleanup();
|
||||
StaticLogFile.setupLogger(new File(plugin.getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_FILENAME)));
|
||||
StaticLogFile.setupLogger(new File(plugin.getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_BACKEND_FILE_FILENAME)));
|
||||
// Remove all cached configs.
|
||||
DataManager.clearConfigs(); // There you have to add XConfig.clear() form now on.
|
||||
// Remove some checks data.
|
||||
@ -74,7 +74,7 @@ public class ReloadCommand extends NCPCommand {
|
||||
final String info = "[NoCheatPlus] Configuration reloaded.";
|
||||
if (!(sender instanceof ConsoleCommandSender)) Bukkit.getLogger().info(info);
|
||||
final ConfigFile config = ConfigManager.getConfigFile();
|
||||
if (config.getBoolean(ConfPaths.LOGGING_ACTIVE) && config.getBoolean(ConfPaths.LOGGING_FILE)) StaticLogFile.fileLogger.info(info);
|
||||
if (config.getBoolean(ConfPaths.LOGGING_ACTIVE) && config.getBoolean(ConfPaths.LOGGING_BACKEND_FILE_ACTIVE)) StaticLogFile.fileLogger.info(info);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,11 +37,28 @@ public abstract class ConfPaths {
|
||||
@GlobalConfig
|
||||
private static final String LOGGING = "logging.";
|
||||
public static final String LOGGING_ACTIVE = LOGGING + "active";
|
||||
public static final String LOGGING_CONSOLE = LOGGING + "console";
|
||||
public static final String LOGGING_DEBUG = LOGGING + "debug";
|
||||
|
||||
private static final String LOGGING_BACKEND = LOGGING + "backend.";
|
||||
private static final String LOGGING_BACKEND_CONSOLE = LOGGING_BACKEND + "console.";
|
||||
public static final String LOGGING_BACKEND_CONSOLE_ACTIVE = LOGGING_BACKEND_CONSOLE + "active";
|
||||
private static final String LOGGING_BACKEND_FILE = LOGGING_BACKEND + "file.";
|
||||
public static final String LOGGING_BACKEND_FILE_ACTIVE = LOGGING_BACKEND_FILE + "active";
|
||||
public static final String LOGGING_BACKEND_FILE_FILENAME = LOGGING_BACKEND_FILE + "filename";
|
||||
private static final String LOGGING_BACKEND_INGAMECHAT = LOGGING_BACKEND + "ingamechat.";
|
||||
public static final String LOGGING_BACKEND_INGAMECHAT_ACTIVE = LOGGING_BACKEND_INGAMECHAT + "active";
|
||||
public static final String LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS = LOGGING_BACKEND_INGAMECHAT + "subscriptions";
|
||||
|
||||
// Deprecated.
|
||||
@Moved(newPath=LOGGING_BACKEND_CONSOLE_ACTIVE)
|
||||
public static final String LOGGING_CONSOLE = LOGGING + "console";
|
||||
@Moved(newPath=LOGGING_BACKEND_FILE_ACTIVE)
|
||||
public static final String LOGGING_FILE = LOGGING + "file";
|
||||
@Moved(newPath=LOGGING_BACKEND_FILE_FILENAME)
|
||||
public static final String LOGGING_FILENAME = LOGGING + "filename";
|
||||
@Moved(newPath=LOGGING_BACKEND_INGAMECHAT_ACTIVE)
|
||||
public static final String LOGGING_INGAMECHAT = LOGGING + "ingamechat";
|
||||
@Moved(newPath=LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS)
|
||||
public static final String LOGGING_USESUBSCRIPTIONS = LOGGING + "usesubscriptions";
|
||||
|
||||
/*
|
||||
|
@ -51,13 +51,13 @@ public class DefaultConfig extends ConfigFile {
|
||||
*/
|
||||
set(ConfPaths.LOGGING_ACTIVE, true);
|
||||
set(ConfPaths.LOGGING_DEBUG, false);
|
||||
set(ConfPaths.LOGGING_CONSOLE, true);
|
||||
set(ConfPaths.LOGGING_FILE, true);
|
||||
set(ConfPaths.LOGGING_FILENAME, "nocheatplus.log");
|
||||
set(ConfPaths.LOGGING_INGAMECHAT, true);
|
||||
set(ConfPaths.LOGGING_BACKEND_CONSOLE_ACTIVE, true);
|
||||
set(ConfPaths.LOGGING_BACKEND_FILE_ACTIVE, true);
|
||||
set(ConfPaths.LOGGING_BACKEND_FILE_FILENAME, "nocheatplus.log");
|
||||
set(ConfPaths.LOGGING_BACKEND_INGAMECHAT_ACTIVE, true);
|
||||
|
||||
// Notifications settings.
|
||||
set(ConfPaths.LOGGING_USESUBSCRIPTIONS, false);
|
||||
set(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS, false);
|
||||
|
||||
/*
|
||||
* e e ,e, 888 888
|
||||
|
@ -259,7 +259,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
|
||||
@Override
|
||||
public int sendAdminNotifyMessage(final String message){
|
||||
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_USESUBSCRIPTIONS)){
|
||||
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS)){
|
||||
// TODO: Might respect console settings, or add extra config section (e.g. notifications).
|
||||
return sendAdminNotifyMessageSubscriptions(message);
|
||||
}
|
||||
@ -656,7 +656,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
ConfigManager.init(this);
|
||||
|
||||
// Setup file logger.
|
||||
StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_FILENAME)));
|
||||
StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_BACKEND_FILE_FILENAME)));
|
||||
|
||||
final ConfigFile config = ConfigManager.getConfigFile();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user