diff --git a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java index bfd5135..48e461b 100644 --- a/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java +++ b/Common/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatform.java @@ -6,11 +6,12 @@ import net.minecraft.world.item.Item; import java.nio.file.Path; import java.util.List; +import java.util.ServiceLoader; import java.util.Set; public interface AlmostUnifiedPlatform { - AlmostUnifiedPlatform INSTANCE = PlatformLoader.load(AlmostUnifiedPlatform.class); + AlmostUnifiedPlatform INSTANCE = load(AlmostUnifiedPlatform.class); /** * Gets the current platform @@ -27,13 +28,6 @@ public interface AlmostUnifiedPlatform { */ boolean isModLoaded(String modId); - /** - * Check if the game is currently in a development environment. - * - * @return True if in a development environment, false otherwise. - */ - boolean isDevelopmentEnvironment(); - boolean isClient(); Path getConfigPath(); @@ -43,4 +37,17 @@ public interface AlmostUnifiedPlatform { void bindRecipeHandlers(RecipeHandlerFactory factory); Set> getStoneStrataTags(List stoneStrataIds); + + static T load(Class clazz) { + T loadedService = ServiceLoader.load(clazz) + .findFirst() + .orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); + AlmostUnified.LOG.debug("Loaded {} for service {}", loadedService, clazz); + return loadedService; + } + + enum Platform { + FORGE, + FABRIC; + } } diff --git a/Common/src/main/java/com/almostreliable/unified/Platform.java b/Common/src/main/java/com/almostreliable/unified/Platform.java deleted file mode 100644 index c56383e..0000000 --- a/Common/src/main/java/com/almostreliable/unified/Platform.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.almostreliable.unified; - -public enum Platform { - FORGE, - FABRIC -} diff --git a/Common/src/main/java/com/almostreliable/unified/PlatformLoader.java b/Common/src/main/java/com/almostreliable/unified/PlatformLoader.java deleted file mode 100644 index b3d578e..0000000 --- a/Common/src/main/java/com/almostreliable/unified/PlatformLoader.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.almostreliable.unified; - -import java.util.ServiceLoader; - -@SuppressWarnings("UtilityClassWithoutPrivateConstructor") -public final class PlatformLoader { - static T load(Class clazz) { - final T loadedService = ServiceLoader.load(clazz) - .findFirst() - .orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); - AlmostUnified.LOG.debug("Loaded {} for service {}", loadedService, clazz); - return loadedService; - } -} diff --git a/Common/src/main/java/com/almostreliable/unified/config/Defaults.java b/Common/src/main/java/com/almostreliable/unified/config/Defaults.java index 30495fd..6eaeb2a 100644 --- a/Common/src/main/java/com/almostreliable/unified/config/Defaults.java +++ b/Common/src/main/java/com/almostreliable/unified/config/Defaults.java @@ -1,6 +1,6 @@ package com.almostreliable.unified.config; -import com.almostreliable.unified.Platform; +import com.almostreliable.unified.AlmostUnifiedPlatform; import com.almostreliable.unified.utils.JsonCompare; import net.minecraft.resources.ResourceLocation; @@ -70,7 +70,7 @@ public final class Defaults { private Defaults() {} - public static List getModPriorities(Platform platform) { + public static List getModPriorities(AlmostUnifiedPlatform.Platform platform) { return switch (platform) { case FORGE -> List.of( "minecraft", @@ -93,7 +93,7 @@ public final class Defaults { }; } - public static List getTags(Platform platform) { + public static List getTags(AlmostUnifiedPlatform.Platform platform) { return switch (platform) { case FORGE -> List.of( "forge:nuggets/{material}", @@ -129,13 +129,13 @@ public final class Defaults { }; } - public static List getIgnoredRecipeTypes(Platform platform) { + public static List getIgnoredRecipeTypes(AlmostUnifiedPlatform.Platform platform) { return switch (platform) { default -> List.of("cucumber:shaped_tag"); }; } - public static JsonCompare.CompareSettings getDefaultDuplicateRules(Platform platform) { + public static JsonCompare.CompareSettings getDefaultDuplicateRules(AlmostUnifiedPlatform.Platform platform) { JsonCompare.CompareSettings result = new JsonCompare.CompareSettings(); result.ignoreField(switch (platform) { case FORGE -> "conditions"; @@ -148,7 +148,7 @@ public final class Defaults { return result; } - public static LinkedHashMap getDefaultDuplicateOverrides(Platform platform) { + public static LinkedHashMap getDefaultDuplicateOverrides(AlmostUnifiedPlatform.Platform platform) { JsonCompare.CompareSettings result = new JsonCompare.CompareSettings(); result.ignoreField(switch (platform) { case FORGE -> "conditions"; diff --git a/Common/src/test/java/com/almostreliable/unified/TestUtils.java b/Common/src/test/java/com/almostreliable/unified/TestUtils.java index c232ba2..15586a7 100644 --- a/Common/src/test/java/com/almostreliable/unified/TestUtils.java +++ b/Common/src/test/java/com/almostreliable/unified/TestUtils.java @@ -38,7 +38,7 @@ public final class TestUtils { public static final UnifyConfig DEFAULT_UNIFY_CONFIG = new UnifyConfig( Defaults.STONE_STRATA, Defaults.MATERIALS, - Defaults.getTags(Platform.FORGE), + Defaults.getTags(AlmostUnifiedPlatform.Platform.FORGE), TEST_MOD_PRIORITIES, new HashMap<>(), new HashMap<>(), @@ -55,11 +55,13 @@ public final class TestUtils { private TestUtils() {} public static JsonCompare.CompareSettings getDefaultCompareSettings() { - return Defaults.getDefaultDuplicateRules(Platform.FORGE); + return Defaults.getDefaultDuplicateRules(AlmostUnifiedPlatform.Platform.FORGE); } public static JsonCompare.CompareSettings getDefaultShapedCompareSettings() { - return Defaults.getDefaultDuplicateOverrides(Platform.FORGE).get(new ResourceLocation("crafting_shaped")); + return Defaults + .getDefaultDuplicateOverrides(AlmostUnifiedPlatform.Platform.FORGE) + .get(new ResourceLocation("crafting_shaped")); } public static final ResourceKey> FAKE_ITEM_REGISTRY = FakeResourceKeyRegistry.create("item"); diff --git a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java index 713a6df..8d5baee 100644 --- a/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java +++ b/Fabric/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformFabric.java @@ -28,11 +28,6 @@ public class AlmostUnifiedPlatformFabric implements AlmostUnifiedPlatform { return FabricLoader.getInstance().isModLoaded(modId); } - @Override - public boolean isDevelopmentEnvironment() { - return FabricLoader.getInstance().isDevelopmentEnvironment(); - } - @Override public boolean isClient() { return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT; diff --git a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java index 37ff0f1..6dd225d 100644 --- a/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java +++ b/Forge/src/main/java/com/almostreliable/unified/AlmostUnifiedPlatformForge.java @@ -38,11 +38,6 @@ public class AlmostUnifiedPlatformForge implements AlmostUnifiedPlatform { return ModList.get().isLoaded(modId); } - @Override - public boolean isDevelopmentEnvironment() { - return !FMLLoader.isProduction(); - } - @Override public boolean isClient() { return FMLLoader.getDist() == Dist.CLIENT;