From df2716074fc9ea9f6d3621934147dfbae7af0fbc Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:24:23 -0400 Subject: [PATCH] NEW translate to client language with setting --- .../me/blackvein/quests/config/ISettings.java | 2 + .../java/me/blackvein/quests/util/Lang.java | 123 +++++++++++++----- .../java/me/blackvein/quests/Settings.java | 8 ++ .../questadmin/QuestadminCommandHandler.java | 8 +- .../commands/quests/QuestsCommandHandler.java | 17 +-- .../subcommands/QuestsActionsCommand.java | 4 +- .../subcommands/QuestsConditionsCommand.java | 4 +- .../subcommands/QuestsEditorCommand.java | 4 +- .../quests/subcommands/QuestsInfoCommand.java | 5 +- .../quests/subcommands/QuestsListCommand.java | 6 +- .../quests/subcommands/QuestsQuitCommand.java | 2 +- .../subcommands/QuestsStatsCommand.java | 12 +- .../quests/subcommands/QuestsTopCommand.java | 8 +- core/src/main/resources/config.yml | 1 + 14 files changed, 135 insertions(+), 69 deletions(-) diff --git a/api/src/main/java/me/blackvein/quests/config/ISettings.java b/api/src/main/java/me/blackvein/quests/config/ISettings.java index 02855e05e..f8bc1b110 100644 --- a/api/src/main/java/me/blackvein/quests/config/ISettings.java +++ b/api/src/main/java/me/blackvein/quests/config/ISettings.java @@ -43,6 +43,8 @@ public interface ISettings { void setKillDelay(final int killDelay); String getLanguage(); void setLanguage(final String language); + boolean canLanguageOverrideClient(); + void setLanguageOverrideClient(final boolean languageOverrideClient); int getMaxQuests(); void setMaxQuests(final int maxQuests); boolean canNpcEffects(); diff --git a/api/src/main/java/me/blackvein/quests/util/Lang.java b/api/src/main/java/me/blackvein/quests/util/Lang.java index 319eb30fb..a3c3b989b 100644 --- a/api/src/main/java/me/blackvein/quests/util/Lang.java +++ b/api/src/main/java/me/blackvein/quests/util/Lang.java @@ -16,10 +16,12 @@ import me.blackvein.quests.QuestsAPI; import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import java.io.File; import java.io.FileInputStream; @@ -37,20 +39,27 @@ import java.util.regex.Pattern; public class Lang { - //private static String iso = "en-US"; - private static final LinkedHashMap langMap = new LinkedHashMap<>(); + private static QuestsAPI plugin; + private static final LinkedHashMap defaultLang = new LinkedHashMap<>(); + private static final LinkedHashMap> otherLang = new LinkedHashMap<>(); private static final Pattern hexPattern = Pattern.compile("(?i)%#([0-9A-F]{6})%"); - - /*public static String getISO() { - return iso; + + /** + * @deprecated Use Settings#getLanguage() + */ + public static String getISO() { + return plugin.getSettings().getLanguage(); + } + + /** + * @deprecated Use Settings#setLanguage(String) + */ + public static void setISO(final String iso) { + plugin.getSettings().setLanguage(iso); } - public static void setISO(final String iso) { - Lang.iso = iso; - }*/ - public static Collection values() { - return langMap.values(); + return defaultLang.values(); } /** @@ -60,16 +69,49 @@ public class Lang { * @param key label as it appears in lang file, such as "journalNoQuests" * @return formatted string, plus processing through PlaceholderAPI by clip */ + @SuppressWarnings("deprecation") public static String get(final Player player, final String key) { + if (player == null) { + return get(key); + } String locale; try { locale = player.getLocale(); } catch (NoSuchMethodError e) { - // Older version of Minecraft locale = player.spigot().getLocale(); } + final int separator = locale.indexOf("_"); + if (separator == -1) { + return defaultLang.containsKey(key) ? LangToken.convertString(player, defaultLang.get(key)) : "NULL"; + } + final String language = locale.substring(0, separator); + final String country = locale.substring(separator + 1).toUpperCase(); + locale = language + "-" + country; + if (plugin.getSettings().canLanguageOverrideClient() || locale.equals(getISO())) { + return defaultLang.containsKey(key) ? LangToken.convertString(player, defaultLang.get(key)) : "NULL"; + } + if (!otherLang.containsKey(locale)) { + try { + init(plugin, locale); + } catch (Exception e) { + return defaultLang.containsKey(key) ? LangToken.convertString(player, defaultLang.get(key)) : "NULL"; + } + } + return LangToken.convertString(otherLang.get(locale).get(key)); + } - return langMap.containsKey(key) ? LangToken.convertString(player, langMap.get(key)) : "NULL"; + /** + * Get lang string AND pass sender for use with PlaceholderAPI, if installed + * + * @param commandSender the sender whom will receive the string + * @param key label as it appears in lang file, such as "journalNoQuests" + * @return formatted string, plus processing through PlaceholderAPI by clip + */ + public static String get(final CommandSender commandSender, final String key) { + if (commandSender instanceof Player) { + return get((Player)commandSender, key); + } + return get(key); } /** @@ -79,7 +121,7 @@ public class Lang { * @return formatted string */ public static String get(final String key) { - return langMap.containsKey(key) ? LangToken.convertString(langMap.get(key)) : "NULL"; + return defaultLang.containsKey(key) ? LangToken.convertString(defaultLang.get(key)) : "NULL"; } /** @@ -89,7 +131,7 @@ public class Lang { * @return key or "NULL" as String */ public static String getKey(final String value) { - for (final Entry entry : langMap.entrySet()) { + for (final Entry entry : defaultLang.entrySet()) { if (entry.getValue().equals(value)) { return entry.getKey(); } @@ -105,7 +147,7 @@ public class Lang { * @return full key or "NULL" as String */ public static String getKeyFromPrefix(final String keyPrefix, final String value) { - for (final Entry entry : langMap.entrySet()) { + for (final Entry entry : defaultLang.entrySet()) { if (entry.getValue().equalsIgnoreCase(value) && entry.getKey().toUpperCase().startsWith(keyPrefix)) { return entry.getKey(); } @@ -114,15 +156,15 @@ public class Lang { } public static void clear() { - langMap.clear(); + defaultLang.clear(); } public static int size() { - return langMap.size(); + return defaultLang.size(); } public static String getModified(final String key, final String[] tokens) { - String orig = langMap.get(key); + String orig = defaultLang.get(key); for (int i = 0; i < tokens.length; i++) { orig = orig.replace("%" + (i + 1), tokens[i]); } @@ -142,25 +184,28 @@ public class Lang { } public static void init(final QuestsAPI plugin, String iso) throws InvalidConfigurationException, IOException { - final File langFile = new File(plugin.getPluginDataFolder(), File.separator + "lang" + File.separator + iso + File.separator - + "strings.yml"); + Lang.plugin = plugin; + final File langFile = new File(plugin.getPluginDataFolder(), File.separator + "lang" + File.separator + iso + + File.separator + "strings.yml"); final File langFile_new = new File(plugin.getPluginDataFolder(), File.separator + "lang" + File.separator + iso + File.separator + "strings_new.yml"); final boolean exists_new = langFile_new.exists(); final LinkedHashMap allStrings = new LinkedHashMap<>(); if (!(langFile.exists() && iso.split("-").length > 1)) { - plugin.getPluginLogger().severe("Failed loading lang files for " + iso - + " because they were not found. Using default en-US"); - plugin.getPluginLogger() - .info("If the plugin has not generated language files, ensure Quests has write permissions"); - plugin.getPluginLogger() - .info("For help, visit https://github.com/PikaMug/Quests/wiki/Casual-%E2%80%90-Translations"); - plugin.getSettings().setLanguage("en-US"); - if (plugin.getSettings().getConsoleLogging() > 3) { - plugin.getPluginLogger().info("CodeSource: " + plugin.getClass().getProtectionDomain().getCodeSource() - .toString()); - plugin.getPluginLogger().info("LocationPath: " + plugin.getClass().getProtectionDomain().getCodeSource() - .getLocation().getPath()); + if (defaultLang.isEmpty()) { + plugin.getPluginLogger().severe("Failed loading lang files for " + iso + + " because they were not found. Using default en-US instead"); + plugin.getPluginLogger() + .info("If the plugin has not generated language files, ensure Quests has write permissions"); + plugin.getPluginLogger() + .info("For help, visit https://pikamug.gitbook.io/quests/casual/translations"); + plugin.getSettings().setLanguage("en-US"); + if (plugin.getSettings().getConsoleLogging() > 3) { + plugin.getPluginLogger().info("CodeSource: " + plugin.getClass().getProtectionDomain().getCodeSource() + .toString()); + plugin.getPluginLogger().info("LocationPath: " + plugin.getClass().getProtectionDomain().getCodeSource() + .getLocation().getPath()); + } } final FileConfiguration config = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects .requireNonNull(plugin.getPluginResource("strings.yml")), StandardCharsets.UTF_8)); @@ -182,7 +227,7 @@ public class Lang { config_new.set(key, null); } } - // Add new strings and notify user + // Add new strings and notify console if (exists_new) { for (final String key : config_new.getKeys(false)) { final String value = config_new.getString(key); @@ -236,7 +281,12 @@ public class Lang { allStrings.put(entry.getKey(), entry.getValue().replace("", strSemicolon)); } } - langMap.putAll(allStrings); + if (iso.equals(getISO())) { + defaultLang.clear(); + defaultLang.putAll(allStrings); + } else { + otherLang.put(iso, allStrings); + } plugin.getPluginLogger().info("Loaded language " + iso + ". Translations via Crowdin"); } @@ -298,8 +348,9 @@ public class Lang { LangToken.init(); } s = convertString(s); - if (Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null ) { - if (Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI").isEnabled()) { + final Plugin placeholderApi = Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI"); + if (placeholderApi != null ) { + if (placeholderApi.isEnabled()) { s = PlaceholderAPI.setPlaceholders(p, s); } } diff --git a/core/src/main/java/me/blackvein/quests/Settings.java b/core/src/main/java/me/blackvein/quests/Settings.java index b10fccb56..48de6c2e5 100644 --- a/core/src/main/java/me/blackvein/quests/Settings.java +++ b/core/src/main/java/me/blackvein/quests/Settings.java @@ -38,6 +38,7 @@ public class Settings implements ISettings { private boolean ignoreLockedQuests = false; private int killDelay = 0; private String language = "en-US"; + private boolean languageOverrideClient; private int maxQuests = 0; private boolean npcEffects = true; private String effect = "note"; @@ -159,6 +160,12 @@ public class Settings implements ISettings { public void setLanguage(final String language) { this.language = language; } + public boolean canLanguageOverrideClient() { + return languageOverrideClient; + } + public void setLanguageOverrideClient(final boolean languageOverrideClient) { + this.languageOverrideClient = languageOverrideClient; + } public int getMaxQuests() { return maxQuests; } @@ -259,6 +266,7 @@ public class Settings implements ISettings { } else { language = config.getString("language", "en-US"); } + languageOverrideClient = config.getBoolean("language-override-client", false); maxQuests = config.getInt("max-quests", maxQuests); npcEffects = config.getBoolean("npc-effects.enabled", true); effect = config.getString("npc-effects.new-quest", "note"); diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java index 994f5b94f..a023ee5ad 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java @@ -70,7 +70,7 @@ public class QuestadminCommandHandler { for (Map.Entry cmd : subCommands.entrySet()) { if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { if (args.length < cmd.getValue().getMaxArguments()) { - cs.sendMessage(getAdminCommandUsage(args[0])); + cs.sendMessage(getAdminCommandUsage(cs, args[0])); } cmd.getValue().execute(cs, args); return true; @@ -183,9 +183,9 @@ public class QuestadminCommandHandler { } } - private String getAdminCommandUsage(final String cmd) { - return ChatColor.RED + Lang.get("usage") + ": " + ChatColor.YELLOW + "/questadmin " - + Lang.get(Lang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP") + private String getAdminCommandUsage(final CommandSender cs, final String cmd) { + return ChatColor.RED + Lang.get(cs, "usage") + ": " + ChatColor.YELLOW + "/questadmin " + + Lang.get(cs, Lang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP") .replace("", cmd.toLowerCase()); } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java index 1ccfa3eca..325e7d722 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java @@ -65,13 +65,13 @@ public class QuestsCommandHandler { for (Map.Entry cmd : subCommands.entrySet()) { if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { if (args.length < cmd.getValue().getMaxArguments()) { - cs.sendMessage(getCommandUsage(args[0])); + cs.sendMessage(getCommandUsage(cs, args[0])); } cmd.getValue().execute(cs, args); return true; } } - cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownCommand")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(cs, "questsUnknownCommand")); return true; } @@ -106,20 +106,21 @@ public class QuestsCommandHandler { + ChatColor.YELLOW)); } if (cs instanceof Player) { - cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW + Lang.get("COMMAND_QUEST_HELP")); + cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW + Lang.get(cs, "COMMAND_QUEST_HELP")); if (cs.hasPermission("quests.questinfo")) { cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW - + Lang.get("COMMAND_QUESTINFO_HELP")); + + Lang.get(cs, "COMMAND_QUESTINFO_HELP")); } } if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) { cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_HELP")); + + Lang.get(cs, "COMMAND_QUESTADMIN_HELP")); } } - private String getCommandUsage(final String cmd) { - return ChatColor.RED + Lang.get("usage") + ": " + ChatColor.YELLOW + "/quests " - + Lang.get(Lang.getKeyFromPrefix("COMMAND_", cmd) + "_HELP").replace("", cmd.toLowerCase()); + private String getCommandUsage(final CommandSender cs, final String cmd) { + return ChatColor.RED + Lang.get(cs, "usage") + ": " + ChatColor.YELLOW + "/quests " + + Lang.get(cs, Lang.getKeyFromPrefix("COMMAND_", cmd) + "_HELP") + .replace("", cmd.toLowerCase()); } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java index 72e1ed5ff..cd41a3e5d 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java @@ -66,10 +66,10 @@ public class QuestsActionsCommand extends QuestsSubCommand { if (!c.isConversing()) { plugin.getActionFactory().getConversationFactory().buildConversation(c).begin(); } else { - cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "duplicateEditor")); } } else { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); } } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java index dec3bf94c..3fc8368f9 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java @@ -65,10 +65,10 @@ public class QuestsConditionsCommand extends QuestsSubCommand { if (!c.isConversing()) { plugin.getConditionFactory().getConversationFactory().buildConversation(c).begin(); } else { - cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "duplicateEditor")); } } else { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); } } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java index e10207cac..5fc251fd5 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java @@ -79,10 +79,10 @@ public class QuestsEditorCommand extends QuestsSubCommand { } cn.begin(); } else { - cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "duplicateEditor")); } } else { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); } } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java index 97e77eae5..6729c72f3 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java @@ -59,8 +59,9 @@ public class QuestsInfoCommand extends QuestsSubCommand { public void execute(CommandSender cs, String[] args) { if (cs.hasPermission("quests.info")) { cs.sendMessage(ChatColor.YELLOW + "Quests " + ChatColor.GOLD + plugin.getDescription().getVersion()); - cs.sendMessage(ChatColor.GOLD + Lang.get("createdBy") + " " + ChatColor.RED + "Blackvein" - + ChatColor.GOLD + " " + Lang.get("continuedBy") + " " + ChatColor.RED + "PikaMug & contributors"); + cs.sendMessage(ChatColor.GOLD + Lang.get(cs, "createdBy") + " " + ChatColor.RED + "Blackvein" + + ChatColor.GOLD + " " + Lang.get(cs, "continuedBy") + " " + ChatColor.RED + + "PikaMug & contributors"); cs.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.UNDERLINE + "https://github.com/PikaMug/Quests"); } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java index b9388bfe8..a995d30b2 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java @@ -87,7 +87,7 @@ public class QuestsListCommand extends QuestsSubCommand { try { page = Integer.parseInt(args[1]); if (page < 1) { - cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageSelectionPosNum")); } else { final Quester quester = plugin.getQuester(player.getUniqueId()); final QuestsCommandPreQuestsListEvent preEvent @@ -100,11 +100,11 @@ public class QuestsListCommand extends QuestsSubCommand { plugin.listQuests(quester, page); } } catch (final NumberFormatException e) { - cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionNum")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageSelectionNum")); } } } else { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); + cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); } } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java index 8a6ff250a..a88b6f914 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java @@ -80,7 +80,7 @@ public class QuestsQuitCommand extends QuestsSubCommand { final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' ')); if (quest != null) { if (quest.getOptions().canAllowQuitting()) { - final String msg = ChatColor.YELLOW + Lang.get("questQuit").replace("", + final String msg = ChatColor.YELLOW + Lang.get(player, "questQuit").replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); quester.abandonQuest(quest, msg); } else { diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java index 2a0a04c7a..aeca6fa67 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java @@ -70,20 +70,22 @@ public class QuestsStatsCommand extends QuestsSubCommand { if (cs.hasPermission(getPermission())) { final IQuester quester = plugin.getQuester(player.getUniqueId()); cs.sendMessage(ChatColor.GOLD + "- " + player.getName() + " -"); - cs.sendMessage(ChatColor.YELLOW + Lang.get("questPoints") + " - " + ChatColor.DARK_PURPLE + cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "questPoints") + " - " + ChatColor.DARK_PURPLE + quester.getQuestPoints()); if (quester.getCurrentQuestsTemp().isEmpty()) { - cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ Lang.get("none")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "currentQuest") + " " + ChatColor.DARK_PURPLE + + Lang.get("none")); } else { - cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "currentQuest")); for (final Map.Entry set : quester.getCurrentQuestsTemp().entrySet()) { final IQuest q = set.getKey(); final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName() - + ChatColor.LIGHT_PURPLE + " (" + Lang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")"; + + ChatColor.LIGHT_PURPLE + " (" + Lang.get(player, "stageEditorStage") + " " + + (set.getValue() + 1) + ")"; cs.sendMessage(msg); } } - cs.sendMessage(ChatColor.YELLOW + Lang.get("completedQuest")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "completedQuest")); if (quester.getCompletedQuestsTemp().isEmpty()) { cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none")); diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTopCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTopCommand.java index 3708876bc..8b81bfa45 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTopCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTopCommand.java @@ -76,12 +76,12 @@ public class QuestsTopCommand extends QuestsSubCommand { try { topNumber = Integer.parseInt(args[1]); } catch (final NumberFormatException e) { - cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum")); + cs.sendMessage(ChatColor.YELLOW + Lang.get(cs, "inputNum")); return; } } if (topNumber < 1 || topNumber > plugin.getSettings().getTopLimit()) { - cs.sendMessage(ChatColor.YELLOW + Lang.get("invalidRange").replace("", "1") + cs.sendMessage(ChatColor.YELLOW + Lang.get(cs, "invalidRange").replace("", "1") .replace("", String.valueOf(plugin.getSettings().getTopLimit()))); return; } @@ -105,14 +105,14 @@ public class QuestsTopCommand extends QuestsSubCommand { } final LinkedHashMap sortedMap = (LinkedHashMap) sort(questPoints); int numPrinted = 0; - String msg = Lang.get("topQuestersTitle"); + String msg = Lang.get(cs, "topQuestersTitle"); msg = msg.replace("", ChatColor.DARK_PURPLE + "" + topNumber + ChatColor.GOLD); cs.sendMessage(ChatColor.GOLD + msg); for (final Map.Entry entry : sortedMap.entrySet()) { numPrinted++; cs.sendMessage(ChatColor.YELLOW + String.valueOf(numPrinted) + ". " + entry.getKey() + " - " + ChatColor.DARK_PURPLE + entry.getValue() + ChatColor.YELLOW + " " - + Lang.get("questPoints")); + + Lang.get(cs, "questPoints")); if (numPrinted == topNumber) { break; } diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index da992c227..dd4d0fc92 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -14,6 +14,7 @@ give-journal-item: false ignore-locked-quests: false kill-delay: 600 language: en-US +language-override-client: false max-quests: 0 npc-effects: enabled: true