35 lines
1.3 KiB
Java
35 lines
1.3 KiB
Java
|
package com.thebrokenrail.freshcoffee.util;
|
||
|
|
||
|
import com.thebrokenrail.freshcoffee.config.HardcodedConfig;
|
||
|
import net.fabricmc.loader.api.FabricLoader;
|
||
|
import net.fabricmc.loader.api.ModContainer;
|
||
|
import net.fabricmc.loader.api.metadata.ModMetadata;
|
||
|
|
||
|
import java.lang.management.ManagementFactory;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
public final class PreviewUtil {
|
||
|
public static boolean arePreviewFeaturesRequired() {
|
||
|
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
|
||
|
ModMetadata metadata = mod.getMetadata();
|
||
|
if (metadata.containsCustomValue(HardcodedConfig.PREVIEW_JSON_KEY)) {
|
||
|
try {
|
||
|
boolean newValue = metadata.getCustomValue(HardcodedConfig.PREVIEW_JSON_KEY).getAsBoolean();
|
||
|
if (newValue) {
|
||
|
return true;
|
||
|
}
|
||
|
} catch (ClassCastException e) {
|
||
|
Util.getLogger().error("Invalid Value For Preview Features: " + metadata.getId());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public static boolean arePreviewFeaturesEnabled() {
|
||
|
List<String> vmArgs = new ArrayList<>(ManagementFactory.getRuntimeMXBean().getInputArguments());
|
||
|
return vmArgs.contains("--enable-preview");
|
||
|
}
|
||
|
}
|