-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve config loading issues (#124)
* Resolve config loading issue * remove unused common dependency, uncomment mavenLocal() * Use timestamped floodgate core dependency * use isTransitive instead of manual exclusions
- Loading branch information
1 parent
3548ae5
commit fdd816d
Showing
3 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/org/geysermc/floodgate/util/FabricTemplateReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Path> 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; | ||
} | ||
} |