Skip to content

Commit f2147ad

Browse files
committed
make Rhizo check lazy to prevent crash
due to accessing too early
1 parent 2176abf commit f2147ad

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/main/java/com/probejs/ProbeCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static void register(
106106
}
107107

108108
private static int dump(CommandContext<CommandSourceStack> context) {
109-
if (!ProbeJS.RHIZO_LOADED) {
109+
if (!ProbeJS.isRhizoLoaded()) {
110110
sendSuccess(PText.translatable("probejs.rhizo_missing").withStyle(ChatFormatting.RED), context);
111111
sendSuccess(PText.translatable("probejs.download_rhizo_help")
112112
.append(PText.url("CurseForge",

src/main/java/com/probejs/ProbeJS.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ProbeJS {
2323
.create();
2424
public static final ProbeConfig CONFIG = ProbeConfig.instance();
2525
public static final boolean ENABLED = CONFIG.enabled;
26-
public static final boolean RHIZO_LOADED = Platform.isModLoaded("rhizo");
26+
public static Boolean RHIZO_LOADED = null;
2727

2828
public ProbeJS() {
2929
CommandRegistrationEvent.EVENT.register(ProbeCommands::register);
@@ -41,4 +41,11 @@ public ProbeJS() {
4141
);
4242
}
4343
}
44+
45+
public static boolean isRhizoLoaded() {
46+
if (RHIZO_LOADED == null) {
47+
RHIZO_LOADED = Platform.isModLoaded("rhizo");
48+
}
49+
return RHIZO_LOADED;
50+
}
4451
}

src/main/java/com/probejs/formatter/resolver/ClazzFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void skipClass(Class<?>... clazz) {
2222
}
2323

2424
public static boolean acceptMethod(String methodName) {
25-
if (!ProbeJS.RHIZO_LOADED) {
25+
if (!ProbeJS.isRhizoLoaded()) {
2626
//fallback for Rhino
2727
return !methodName.equals("constructor");
2828
}
@@ -32,7 +32,7 @@ public static boolean acceptMethod(String methodName) {
3232
}
3333

3434
public static boolean acceptField(String fieldName) {
35-
if (!ProbeJS.RHIZO_LOADED) {
35+
if (!ProbeJS.isRhizoLoaded()) {
3636
//fallback for Rhino
3737
return !fieldName.equals("constructor");
3838
}

src/main/java/com/probejs/util/RemapperBridge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static IRemapper getRemapper() {
1616
}
1717

1818
public static void refreshRemapper() {
19-
if (!ProbeJS.RHIZO_LOADED) {
19+
if (!ProbeJS.isRhizoLoaded()) {
2020
ProbeJS.LOGGER.warn("You seem to be using Rhino instead of newer Rhizo, skipping Remapper check");
2121
return;
2222
}

0 commit comments

Comments
 (0)