generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make Unknown Item Namespace IDs remappable (config/wayf.cfg)
- Loading branch information
1 parent
c6d600b
commit 75ce5ca
Showing
4 changed files
with
49 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.campersamu.shoutout; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Properties; | ||
|
||
public final class Config { | ||
private Config(){} | ||
|
||
private static final Path FILE = FabricLoader.getInstance().getConfigDir().resolve("wayf.cfg"); | ||
private static final Properties MAPPED_MODS = new Properties(); | ||
|
||
static { | ||
load(); | ||
} | ||
|
||
private static void save() { | ||
try (final OutputStream out = Files.newOutputStream(FILE)) { | ||
MAPPED_MODS.store(out, """ | ||
Remap Unknown Item IDs to Mod IDs. | ||
Format: | ||
item_id_namespace = mod_id | ||
Example: | ||
gofish = go-fish"""); | ||
} catch (IOException ignored) {} | ||
|
||
} | ||
private static void load() { | ||
try (final InputStream in = Files.newInputStream(FILE)) { | ||
MAPPED_MODS.load(in); | ||
} catch (IOException ignored) { | ||
save(); | ||
} | ||
} | ||
|
||
public static String getMappedId(String itemNamespaceId) { | ||
return MAPPED_MODS.getProperty(itemNamespaceId, itemNamespaceId); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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