From b9bc944c00f5be11e9299279f5455de7d39a580e Mon Sep 17 00:00:00 2001 From: RawDiamondMC Date: Sun, 27 Oct 2024 15:34:18 +0800 Subject: [PATCH] chore: change the instance to a field --- .../lib/api/platform/DependencyInfo.java | 2 +- .../band/kessoku/lib/api/platform/Loader.java | 22 +++++++++---------- .../lib/service/platform/LoaderService.java | 4 +--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/platform/common/src/main/java/band/kessoku/lib/api/platform/DependencyInfo.java b/platform/common/src/main/java/band/kessoku/lib/api/platform/DependencyInfo.java index afb1c9d4..6ae7225e 100644 --- a/platform/common/src/main/java/band/kessoku/lib/api/platform/DependencyInfo.java +++ b/platform/common/src/main/java/band/kessoku/lib/api/platform/DependencyInfo.java @@ -90,7 +90,7 @@ public boolean isSoft() { */ @Nullable public String getKey() { - return LoaderService.getInstance().isFabric() ? fabricKey : neoKey; + return Loader.isFabric() ? fabricKey : neoKey; } } } diff --git a/platform/common/src/main/java/band/kessoku/lib/api/platform/Loader.java b/platform/common/src/main/java/band/kessoku/lib/api/platform/Loader.java index 8a43edd4..6b24cf51 100644 --- a/platform/common/src/main/java/band/kessoku/lib/api/platform/Loader.java +++ b/platform/common/src/main/java/band/kessoku/lib/api/platform/Loader.java @@ -25,46 +25,46 @@ private Loader() { } public static Metadata getModMetadata(String modid) { - return LoaderService.getInstance().getModMetadata(modid); + return LoaderService.INSTANCE.getModMetadata(modid); } public static boolean isFabric() { - return LoaderService.getInstance().isFabric(); + return LoaderService.INSTANCE.isFabric(); } public static boolean isNeoForge() { - return LoaderService.getInstance().isNeoForge(); + return LoaderService.INSTANCE.isNeoForge(); } public static Env getEnv() { - return LoaderService.getInstance().getEnv(); + return LoaderService.INSTANCE.getEnv(); } public static Path getGameFolder() { - return LoaderService.getInstance().getGameFolder(); + return LoaderService.INSTANCE.getGameFolder(); } public static Path getConfigFolder() { - return LoaderService.getInstance().getConfigFolder(); + return LoaderService.INSTANCE.getConfigFolder(); } public static Path getModsFolder() { - return LoaderService.getInstance().getModsFolder(); + return LoaderService.INSTANCE.getModsFolder(); } public static boolean isModLoaded(String id) { - return LoaderService.getInstance().isModLoaded(id); + return LoaderService.INSTANCE.isModLoaded(id); } public static Collection getModIds() { - return LoaderService.getInstance().getModIds(); + return LoaderService.INSTANCE.getModIds(); } public static Collection getMods() { - return LoaderService.getInstance().getMods(); + return LoaderService.INSTANCE.getMods(); } public static boolean isDevEnv() { - return LoaderService.getInstance().isDevEnv(); + return LoaderService.INSTANCE.isDevEnv(); } } diff --git a/platform/common/src/main/java/band/kessoku/lib/service/platform/LoaderService.java b/platform/common/src/main/java/band/kessoku/lib/service/platform/LoaderService.java index 390c1a44..9a303615 100644 --- a/platform/common/src/main/java/band/kessoku/lib/service/platform/LoaderService.java +++ b/platform/common/src/main/java/band/kessoku/lib/service/platform/LoaderService.java @@ -23,9 +23,7 @@ import band.kessoku.lib.api.platform.Metadata; public interface LoaderService { - static LoaderService getInstance() { - return KessokuLib.loadService(LoaderService.class); - } + LoaderService INSTANCE = KessokuLib.loadService(LoaderService.class); Metadata getModMetadata(String modid);