mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-23 08:59:27 +00:00
feat(core): 添加配置过滤配置阶段断开连接日志的功能
This commit is contained in:
@@ -8,6 +8,8 @@ metrics: true
|
|||||||
update-checker: true
|
update-checker: true
|
||||||
# Forces a specific locale (e.g., zh_cn)
|
# Forces a specific locale (e.g., zh_cn)
|
||||||
forced-locale: ''
|
forced-locale: ''
|
||||||
|
# Filter configuration phase player disconnection logs
|
||||||
|
filter-configuration-phase-disconnect: false
|
||||||
|
|
||||||
resource-pack:
|
resource-pack:
|
||||||
# Should those images in minecraft:default font also work in minecraft:uniform
|
# Should those images in minecraft:default font also work in minecraft:uniform
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class ConfigManager implements Reloadable {
|
|||||||
protected boolean debug;
|
protected boolean debug;
|
||||||
protected boolean checkUpdate;
|
protected boolean checkUpdate;
|
||||||
protected boolean metrics;
|
protected boolean metrics;
|
||||||
|
protected boolean filterConfigurationPhaseDisconnect;
|
||||||
|
|
||||||
protected boolean resource_pack$generate_mod_assets;
|
protected boolean resource_pack$generate_mod_assets;
|
||||||
protected boolean resource_pack$override_uniform_font;
|
protected boolean resource_pack$override_uniform_font;
|
||||||
@@ -181,6 +182,7 @@ public class ConfigManager implements Reloadable {
|
|||||||
debug = config.getBoolean("debug", false);
|
debug = config.getBoolean("debug", false);
|
||||||
metrics = config.getBoolean("metrics", false);
|
metrics = config.getBoolean("metrics", false);
|
||||||
checkUpdate = config.getBoolean("update-checker", false);
|
checkUpdate = config.getBoolean("update-checker", false);
|
||||||
|
filterConfigurationPhaseDisconnect = config.getBoolean("filter-configuration-phase-disconnect", false);
|
||||||
|
|
||||||
// resource pack
|
// resource pack
|
||||||
resource_pack$override_uniform_font = config.getBoolean("resource-pack.override-uniform-font", false);
|
resource_pack$override_uniform_font = config.getBoolean("resource-pack.override-uniform-font", false);
|
||||||
@@ -309,6 +311,10 @@ public class ConfigManager implements Reloadable {
|
|||||||
return instance.metrics;
|
return instance.metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean filterConfigurationPhaseDisconnect() {
|
||||||
|
return instance.filterConfigurationPhaseDisconnect;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean resourcePack$overrideUniform() {
|
public static boolean resourcePack$overrideUniform() {
|
||||||
return instance.resource_pack$override_uniform_font;
|
return instance.resource_pack$override_uniform_font;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.momirealms.craftengine.core.plugin.logger.filter;
|
package net.momirealms.craftengine.core.plugin.logger.filter;
|
||||||
|
|
||||||
|
|
||||||
|
import net.momirealms.craftengine.core.plugin.config.ConfigManager;
|
||||||
import org.apache.logging.log4j.core.Filter;
|
import org.apache.logging.log4j.core.Filter;
|
||||||
import org.apache.logging.log4j.core.LogEvent;
|
import org.apache.logging.log4j.core.LogEvent;
|
||||||
import org.apache.logging.log4j.core.config.Node;
|
import org.apache.logging.log4j.core.config.Node;
|
||||||
@@ -15,6 +16,10 @@ public class DisconnectLogFilter extends AbstractFilter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result filter(LogEvent event) {
|
public Result filter(LogEvent event) {
|
||||||
|
if (!ConfigManager.filterConfigurationPhaseDisconnect()) {
|
||||||
|
return Result.NEUTRAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!event.getLoggerName().equals(TARGET_LOGGER)) {
|
if (!event.getLoggerName().equals(TARGET_LOGGER)) {
|
||||||
return Result.NEUTRAL;
|
return Result.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user