Plugin API that allows to register configs and get messages in the correct language for the player.
- Register configs
- Automaticly apply new keys and values to the config
- Get different Strings dependent on language.
- Clone the repository.
- Build the plugin.
- Put the plugin in the /build/libs/ folder.
- Change the build.gradle and Paper-Plugin.yml
build.gradle:
dependencies {
compileOnly files("build/libs/ConfigAPI-0.0.jar")
}
Paper-Plugin.yml:
dependencies:
server:
ConfigAPI:
load: BEFORE
required: true
join-classpath: true
"this" will always refer to the plugin.
An language file can look like this and woud be named "en_US.json". The prefix key can be usefull later on.
{
"prefix": "[GL]",
"playerNotFound": "<red>This player wasn't found!</red>",
"key": "value"
}
registerLanguage(this, "en_US.json", this.getResource("lang/en_US.json"))
Multilanguage registration is recommended as it do less IO on config loads.
Map<String, InputStream> lang = new HashMap<>();
lang.put("en_US.json", this.getResource("lang/en_US.json"));
LoadConfig.registerLanguage(this, lang);
Language.getValue(this, Player, "key")
Language.getValue(this, Player, "key", true)
String langCode = "en_US";
Language.getValue(this, langCode, "key")
String langCode = "en_US";
Language.getValue(this, langCode, "key", true)