From 39e164c9c844d1cfd61a88cc223a481e1d96e44c Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Fri, 21 Oct 2022 00:46:01 +0200 Subject: [PATCH] Implements language selection properly Adds a configuration option for the plugin language Loads the selected language instead of always loading "en" Makes sure the language is updated upon reloading --- README.md | 6 ++++++ .../java/net/knarcraft/blacksmith/BlacksmithPlugin.java | 4 +++- src/main/resources/config.yml | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43b76f8..bf805fc 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,12 @@ All currently supported presets, and available filters for each preset: ## Configuration options +### Plugin Options + +| Key | Value type | Description | +| --- | --- | --- | +| language | string | The language used for this plugin. Only "en" is supported, unless you add a custom language. | + ### Global-only options | Key | Value type | Description | diff --git a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java index 5ed38f3..bb0a46b 100644 --- a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java +++ b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java @@ -51,6 +51,8 @@ public class BlacksmithPlugin extends JavaPlugin { */ public void reload() { config.load(); + this.reloadConfig(); + Translator.loadLanguages(this.getConfig().getString("language", "en")); } @Override @@ -73,7 +75,7 @@ public class BlacksmithPlugin extends JavaPlugin { config = new GlobalSettings(this); config.load(); - Translator.loadLanguages("en"); + Translator.loadLanguages(fileConfiguration.getString("language", "en")); //Set up Vault integration if (!setUpVault()) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9a6ff38..5449a15 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,8 @@ # Blacksmith Configuration +# The language used for messages. Only "en" is supported +language: en + # The settings which apply to all Blacksmith NPCs. These can also be changed using the /blacksmithconfig command global: # The minimum price of each cost