fix(Grasscutter.java): Exclude compiled protos package from being scanned by reflections

This commit is contained in:
KingRainbow44 2024-07-06 22:24:56 -04:00
parent d0e3720748
commit 655016c92e
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -29,13 +29,15 @@ import lombok.*;
import org.jline.reader.*; import org.jline.reader.*;
import org.jline.terminal.*; import org.jline.terminal.*;
import org.reflections.Reflections; import org.reflections.Reflections;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public final class Grasscutter { public final class Grasscutter {
public static final File configFile = new File("./config.json"); public static final File configFile = new File("./config.json");
public static final Reflections reflector = new Reflections("emu.grasscutter");
@Getter private static final Logger logger = (Logger) LoggerFactory.getLogger(Grasscutter.class); @Getter private static final Logger logger = (Logger) LoggerFactory.getLogger(Grasscutter.class);
public static final Reflections reflector;
@Getter public static ConfigContainer config; @Getter public static ConfigContainer config;
@Getter @Setter private static Language language; @Getter @Setter private static Language language;
@ -75,6 +77,15 @@ public final class Grasscutter {
var mongoLogger = (Logger) LoggerFactory.getLogger("org.mongodb.driver"); var mongoLogger = (Logger) LoggerFactory.getLogger("org.mongodb.driver");
mongoLogger.setLevel(Level.OFF); mongoLogger.setLevel(Level.OFF);
// Configure the reflector.
reflector = new Reflections(
new ConfigurationBuilder()
.forPackage("emu.grasscutter")
.filterInputsBy(new FilterBuilder()
.includePackage("emu.grasscutter")
.excludePackage("emu.grasscutter.net.proto"))
);
// Load server configuration. // Load server configuration.
Grasscutter.loadConfig(); Grasscutter.loadConfig();
// Attempt to update configuration. // Attempt to update configuration.