Created
March 22, 2019 01:42
-
-
Save Daomephsta/30434524375315cfecebf792d24df1b0 to your computer and use it in GitHub Desktop.
Lambda Configs
This file contains hidden or 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 is a comment */ | |
| "identifiers": ["minecraft:potato"] | |
| } |
This file contains hidden or 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
| public class ConfigMod implements ModInitializer | |
| { | |
| @Override | |
| public void onInitialize() | |
| { | |
| Configuration<Config> configBuilder = FabricConfigManager.INSTANCE.newConfig("config-mod", Config::new) | |
| .property | |
| ( | |
| PropertyType.STRING_ARRAY, "identifiers", | |
| (config, array) -> config.identifiers = Arrays.stream(array).map(Identifier::new).collect(Collectors.toList()), | |
| config -> config.identifiers.stream().map(Identifier::toString).toArray(String[]::new), | |
| new String[0], "This is a comment" | |
| ) | |
| .build(); | |
| System.out.println(configBuilder.load()); | |
| } | |
| private static class Config | |
| { | |
| public Collection<Identifier> identifiers; | |
| @Override | |
| public String toString() | |
| { | |
| return String.format("Config [identifiers=%s]", identifiers); | |
| } | |
| } | |
| } |
This file contains hidden or 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
| [main/INFO]: [STDOUT]: Config [identifiers=[minecraft:potato]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment