[ci skip] simplify code

This commit is contained in:
Helvetica Volubi
2026-07-28 01:29:59 +08:00
parent 78b3a8a6e7
commit d90c8567d3
5 changed files with 29 additions and 48 deletions
@@ -21,5 +21,4 @@ public final class MathUtilities {
int i = (int) d; int i = (int) d;
return d > (double) i ? i + 1 : i; return d > (double) i ? i + 1 : i;
} }
} }
@@ -6,7 +6,6 @@ import me.earthme.luminol.config.ConfigsInstance;
import me.earthme.luminol.config.IConfigModule; import me.earthme.luminol.config.IConfigModule;
import me.earthme.luminol.config.flags.ConfigClassInfo; import me.earthme.luminol.config.flags.ConfigClassInfo;
import me.earthme.luminol.config.flags.ConfigInfo; import me.earthme.luminol.config.flags.ConfigInfo;
import me.earthme.luminol.config.flags.DoNotLoad;
import me.earthme.luminol.config.flags.HotReloadUnsupported; import me.earthme.luminol.config.flags.HotReloadUnsupported;
import me.earthme.luminol.enums.EnumConfigCategory; import me.earthme.luminol.enums.EnumConfigCategory;
@@ -16,46 +15,15 @@ public class GlobalEntitiesCounter implements IConfigModule {
@ConfigInfo(name = "version") @ConfigInfo(name = "version")
public static GlobalEntitiesCounterType type = GlobalEntitiesCounterType.DISABLED; public static GlobalEntitiesCounterType type = GlobalEntitiesCounterType.DISABLED;
@DoNotLoad
private static boolean enabled;
@DoNotLoad
private static boolean async;
@DoNotLoad
private static boolean defaultModule;
public static boolean isEnabled() { public static boolean isEnabled() {
return enabled; return type.isEnabled();
} }
public static boolean isAsync() { public static boolean isAsync() {
return async; return type.isAsync();
} }
public static boolean isDefaultModule() { public static boolean isDefaultModule() {
return defaultModule; return type.isDefaultModule();
}
@Override
public void beforeFinalLoad() {
ConfigsInstance configsInstance = ConfigManager.getConfigs("lophine");
try {
Boolean enabled0 = configsInstance.getConfigOrigin("experiment.global_entities_counter.enabled");
Boolean async0 = configsInstance.getConfigOrigin("experiment.global_entities_counter.async");
if (enabled0 != null) {
if (enabled0) {
if (async0 != null && async0) {
type = GlobalEntitiesCounterType.DEFAULT_ASYNC;
} else {
type = GlobalEntitiesCounterType.DEFAULT_SYNC;
}
}
}
configsInstance.removeConfig("experiment.global_entities_counter.enabled");
configsInstance.removeConfig("experiment.global_entities_counter.async");
} catch (Exception ignored) {
}
enabled = type != GlobalEntitiesCounterType.DISABLED;
async = type == GlobalEntitiesCounterType.DEFAULT_ASYNC;
defaultModule = type == GlobalEntitiesCounterType.DEFAULT_SYNC || type == GlobalEntitiesCounterType.DEFAULT_ASYNC;
} }
} }
@@ -1,8 +1,30 @@
package fun.bm.lophine.enums; package fun.bm.lophine.enums;
public enum GlobalEntitiesCounterType { public enum GlobalEntitiesCounterType {
DISABLED, DISABLED(false, false, false),
DEFAULT_SYNC, DEFAULT_SYNC(true, false, true),
DEFAULT_ASYNC, DEFAULT_ASYNC(true, true, true),
PRECISE PRECISE(true, false, false);
private boolean enabled;
private boolean async;
private boolean defaultModule;
private GlobalEntitiesCounterType(boolean enabled, boolean async, boolean defaultModule) {
this.enabled = enabled;
this.async = async;
this.defaultModule = defaultModule;
}
public boolean isEnabled() {
return enabled;
}
public boolean isAsync() {
return async;
}
public boolean isDefaultModule() {
return defaultModule;
}
} }
@@ -23,7 +23,6 @@ import io.sentry.Breadcrumb;
import io.sentry.Sentry; import io.sentry.Sentry;
import io.sentry.SentryEvent; import io.sentry.SentryEvent;
import io.sentry.SentryLevel; import io.sentry.SentryLevel;
import io.sentry.protocol.Message;
import io.sentry.protocol.User; import io.sentry.protocol.User;
import me.earthme.luminol.config.modules.misc.SentryConfig; import me.earthme.luminol.config.modules.misc.SentryConfig;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
@@ -67,9 +66,6 @@ public class PufferfishSentryAppender extends AbstractAppender {
private void logException(LogEvent e) { private void logException(LogEvent e) {
SentryEvent event = new SentryEvent(e.getThrown()); SentryEvent event = new SentryEvent(e.getThrown());
Message sentryMessage = new Message();
sentryMessage.setMessage(e.getMessage().getFormattedMessage());
event.setThrowable(e.getThrown()); event.setThrowable(e.getThrown());
event.setLevel(getLevel(e.getLevel())); event.setLevel(getLevel(e.getLevel()));
event.setLogger(e.getLoggerName()); event.setLogger(e.getLoggerName());
@@ -26,10 +26,6 @@ public class SentryManager {
private static final Logger logger = LogManager.getLogger(SentryManager.class); private static final Logger logger = LogManager.getLogger(SentryManager.class);
private SentryManager() {
}
private static boolean initialized = false; private static boolean initialized = false;
public static synchronized void init(Level logLevel) { public static synchronized void init(Level logLevel) {