[ci skip] simplify code
This commit is contained in:
-1
@@ -21,5 +21,4 @@ public final class MathUtilities {
|
||||
int i = (int) d;
|
||||
return d > (double) i ? i + 1 : i;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-35
@@ -6,7 +6,6 @@ import me.earthme.luminol.config.ConfigsInstance;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
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.enums.EnumConfigCategory;
|
||||
|
||||
@@ -16,46 +15,15 @@ public class GlobalEntitiesCounter implements IConfigModule {
|
||||
@ConfigInfo(name = "version")
|
||||
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() {
|
||||
return enabled;
|
||||
return type.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isAsync() {
|
||||
return async;
|
||||
return type.isAsync();
|
||||
}
|
||||
|
||||
public static boolean isDefaultModule() {
|
||||
return defaultModule;
|
||||
}
|
||||
|
||||
@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;
|
||||
return type.isDefaultModule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
package fun.bm.lophine.enums;
|
||||
|
||||
public enum GlobalEntitiesCounterType {
|
||||
DISABLED,
|
||||
DEFAULT_SYNC,
|
||||
DEFAULT_ASYNC,
|
||||
PRECISE
|
||||
DISABLED(false, false, false),
|
||||
DEFAULT_SYNC(true, false, true),
|
||||
DEFAULT_ASYNC(true, true, true),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -23,7 +23,6 @@ import io.sentry.Breadcrumb;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.SentryEvent;
|
||||
import io.sentry.SentryLevel;
|
||||
import io.sentry.protocol.Message;
|
||||
import io.sentry.protocol.User;
|
||||
import me.earthme.luminol.config.modules.misc.SentryConfig;
|
||||
import org.apache.logging.log4j.Level;
|
||||
@@ -67,9 +66,6 @@ public class PufferfishSentryAppender extends AbstractAppender {
|
||||
private void logException(LogEvent e) {
|
||||
SentryEvent event = new SentryEvent(e.getThrown());
|
||||
|
||||
Message sentryMessage = new Message();
|
||||
sentryMessage.setMessage(e.getMessage().getFormattedMessage());
|
||||
|
||||
event.setThrowable(e.getThrown());
|
||||
event.setLevel(getLevel(e.getLevel()));
|
||||
event.setLogger(e.getLoggerName());
|
||||
|
||||
@@ -26,10 +26,6 @@ public class SentryManager {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(SentryManager.class);
|
||||
|
||||
private SentryManager() {
|
||||
|
||||
}
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static synchronized void init(Level logLevel) {
|
||||
|
||||
Reference in New Issue
Block a user