Added dev env detection
This commit is contained in:
6 files changed
+26
No files matched your search
@@ -51,6 +51,8 @@ public abstract sealed class PlatformService permits PlatformServiceFabric, Plat
|
||||
return modsMap.computeIfAbsent(modId, this::createModContainer);
|
||||
}
|
||||
|
||||
public abstract boolean isDevEnv();
|
||||
|
||||
@Contract(pure = true)
|
||||
protected abstract Optional<PlatformModContainer> createModContainer(String modId);
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@ final class PlatformServiceFabric extends PlatformService {
|
||||
.map(FabricModContainer::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
static final class FabricModContainer extends PlatformModContainer {
|
||||
|
||||
private FabricModContainer(ModMetadata modMetadata) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.nerjal.moddingutils.platform;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -13,6 +14,11 @@ final class PlatformServiceForge extends PlatformService {
|
||||
return Optional.ofNullable(ModList.get().getModFileById(modId)).map(i -> new ForgeModContainer(modId, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
static final class ForgeModContainer extends PlatformModContainer {
|
||||
|
||||
ForgeModContainer(String modId, IModFileInfo modInfo) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.nerjal.moddingutils.platform;
|
||||
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
import net.neoforged.neoforgespi.language.IModFileInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -13,6 +14,11 @@ final class PlatformServiceNeoForge extends PlatformService {
|
||||
return Optional.ofNullable(ModList.get().getModFileById(modId)).map(i -> new NeoForgeModContainer(modId, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
static final class NeoForgeModContainer extends PlatformModContainer {
|
||||
NeoForgeModContainer(String modId, IModFileInfo modInfo) {
|
||||
super(modId, Arrays.stream(modInfo.getConfig().getConfigElement("authors")
|
||||
|
||||
@@ -10,4 +10,9 @@ final class PlatformServiceOther extends PlatformService {
|
||||
protected Optional<PlatformModContainer> createModContainer(String modId) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ module ModdingUtils {
|
||||
requires net.minecraftforge.forgespi;
|
||||
requires net.neoforged.neoforgespi;
|
||||
requires fml_core;
|
||||
requires fmlloader;
|
||||
requires fml_loader;
|
||||
opens com.nerjal.moddingutils.compat;
|
||||
opens com.nerjal.moddingutils.mod;
|
||||
opens com.nerjal.moddingutils.platform;
|
||||
|
||||
Reference in new issue
Block a user