-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathDebugify.java
More file actions
50 lines (42 loc) · 1.81 KB
/
Copy pathDebugify.java
File metadata and controls
50 lines (42 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package dev.isxander.debugify;
import dev.isxander.debugify.config.DebugifyConfig;
import dev.isxander.debugify.fixes.BugFix;
import dev.isxander.debugify.mixinplugin.DebugifyErrorHandler;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.Mixins;
import java.util.List;
import java.util.Map;
import java.util.function.BooleanSupplier;
public class Debugify {
public static final Logger LOGGER = LoggerFactory.getLogger("Debugify");
public static final Version VERSION = FabricLoader.getInstance().getModContainer("debugify").orElseThrow().getMetadata().getVersion();
public static final DebugifyConfig CONFIG = new DebugifyConfig();
/**
* Called from mixin plugin to manage
* disabled bug fixes
*/
public static void onPreInitialize() {
CONFIG.preload();
Mixins.registerErrorHandlerClass(DebugifyErrorHandler.class.getName());
}
public static void onInitialize() {
List<String> enabledBugs = CONFIG.getBugFixes().entrySet()
.stream()
.filter(Map.Entry::getValue)
.map(entry -> entry.getKey().bugId())
.toList();
LOGGER.info("Enabled {} bug fixes: {}", enabledBugs.size(), enabledBugs);
LOGGER.info("Successfully Debugify'd your game!");
}
public static BugFix.Env getEnv() {
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT ? BugFix.Env.CLIENT : BugFix.Env.SERVER;
}
public static BooleanSupplier inMultiplayerWorld = () -> false;
public static boolean isGameplayFixesEnabled() {
return !inMultiplayerWorld.getAsBoolean() || Debugify.CONFIG.gameplayFixesInMultiplayer;
}
}