forked from virt-mirrors/Sit
fix ModMenu error if YACL isn't installed
This commit is contained in:
parent
02dd4e868c
commit
890216a19a
1 changed files with 15 additions and 0 deletions
|
@ -21,6 +21,8 @@ public class ModMenu implements ModMenuApi {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
|
// return null if YACL isn't installed to not throw an error
|
||||||
|
if (!yaclCheck()) return screen -> null;
|
||||||
return parent -> YetAnotherConfigLib.createBuilder().save(Config::save)
|
return parent -> YetAnotherConfigLib.createBuilder().save(Config::save)
|
||||||
.title(Text.of("Sit!"))
|
.title(Text.of("Sit!"))
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
|
@ -198,4 +200,17 @@ public class ModMenu implements ModMenuApi {
|
||||||
.build())
|
.build())
|
||||||
.build().generateScreen(parent);
|
.build().generateScreen(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if YACL is installed by getting a class and seeing if it throws
|
||||||
|
* @return if YACL is installed
|
||||||
|
*/
|
||||||
|
public static boolean yaclCheck() {
|
||||||
|
try {
|
||||||
|
Class.forName("dev.isxander.yacl3.platform.fabric.YACLPlatformImpl");
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue