diff --git a/build.gradle.kts b/build.gradle.kts index eb3c6bb..e6045a5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,9 +22,9 @@ dependencies { modImplementation("net.fabricmc.fabric-api:fabric-api:0.97.6+1.20.5") // Base Floodgate - implementation("org.geysermc.floodgate:core:2.2.3-SNAPSHOT") - shadow("org.geysermc.floodgate:core:2.2.3-SNAPSHOT") { isTransitive = false } - shadow("org.geysermc.floodgate:api:2.2.3-SNAPSHOT") { isTransitive = false } + implementation("org.geysermc.floodgate:core:2.2.3-20240508.151752-4") + shadow("org.geysermc.floodgate:core:2.2.3-20240508.151752-4") { isTransitive = false } + shadow("org.geysermc.floodgate:api:2.2.3-20240508.151752-4") { isTransitive = false } // Requires relocation shadow("org.bstats:bstats-base:3.0.2") @@ -50,7 +50,7 @@ dependencies { include("org.lanternpowered", "lmbda", "2.0.0") // used in events // Geyser dependency for the fun injector mixin :))) - modImplementation("org.geysermc.geyser:fabric:2.2.3-SNAPSHOT") + modCompileOnly("org.geysermc.geyser:fabric:2.2.3-SNAPSHOT") { isTransitive = false } // cloud include("org.incendo:cloud-fabric:2.0.0-SNAPSHOT") @@ -62,7 +62,7 @@ dependencies { } repositories { - //mavenLocal() + // mavenLocal() mavenCentral() maven("https://maven.fabricmc.net/") maven("https://repo.opencollab.dev/main/") diff --git a/src/main/java/org/geysermc/floodgate/FabricMod.java b/src/main/java/org/geysermc/floodgate/FabricMod.java index 090ee15..e93365f 100644 --- a/src/main/java/org/geysermc/floodgate/FabricMod.java +++ b/src/main/java/org/geysermc/floodgate/FabricMod.java @@ -10,6 +10,7 @@ import net.fabricmc.loader.api.FabricLoader; import org.geysermc.floodgate.api.logger.FloodgateLogger; import org.geysermc.floodgate.module.*; +import org.geysermc.floodgate.util.FabricTemplateReader; public class FabricMod implements ModInitializer { @@ -20,7 +21,7 @@ public void onInitialize() { FabricInjector.setInstance(new FabricInjector()); Injector injector = Guice.createInjector( - new ServerCommonModule(FabricLoader.getInstance().getConfigDir().resolve("floodgate")), + new ServerCommonModule(FabricLoader.getInstance().getConfigDir().resolve("floodgate"), new FabricTemplateReader()), new FabricPlatformModule() ); diff --git a/src/main/java/org/geysermc/floodgate/util/FabricTemplateReader.java b/src/main/java/org/geysermc/floodgate/util/FabricTemplateReader.java new file mode 100644 index 0000000..b772fde --- /dev/null +++ b/src/main/java/org/geysermc/floodgate/util/FabricTemplateReader.java @@ -0,0 +1,38 @@ +package org.geysermc.floodgate.util; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import org.geysermc.configutils.file.template.TemplateReader; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.Optional; + +public class FabricTemplateReader implements TemplateReader { + + private final ModContainer container; + + public FabricTemplateReader() { + container = FabricLoader.getInstance().getModContainer("floodgate").orElseThrow(); + } + + @Override + public BufferedReader read(String configName) { + Optional optional = container.findPath(configName); + if (optional.isPresent()) { + try { + InputStream stream = optional.get().getFileSystem() + .provider() + .newInputStream(optional.get()); + return new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + return null; + } +}