From 184430f4f60669907e1bfafb437261eea527e761 Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 28 Oct 2019 14:09:17 +0200 Subject: [PATCH] In case locale is a string list and not a string line --- .../com/gamingmesh/jobs/PlayerManager.java | 16 ++++++------- .../com/gamingmesh/jobs/i18n/Language.java | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 9dd36401..9078f471 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -116,15 +116,15 @@ public class PlayerManager { public void addPlayerToCache(JobsPlayer jPlayer) { if (jPlayer.getUserName() != null && playersCache.get(jPlayer.getUserName().toLowerCase()) == null) playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer); - if (jPlayer.getPlayerUUID() != null && playersUUIDCache.get(jPlayer.getPlayerUUID()) == null) - playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer); + if (jPlayer.getUniqueId() != null && playersUUIDCache.get(jPlayer.getUniqueId()) == null) + playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer); } public void addPlayer(JobsPlayer jPlayer) { if (jPlayer.getUserName() != null && players.get(jPlayer.getUserName().toLowerCase()) == null) players.put(jPlayer.getUserName().toLowerCase(), jPlayer); - if (jPlayer.getPlayerUUID() != null && playersUUID.get(jPlayer.getPlayerUUID()) == null) - playersUUID.put(jPlayer.getPlayerUUID(), jPlayer); + if (jPlayer.getUniqueId() != null && playersUUID.get(jPlayer.getUniqueId()) == null) + playersUUID.put(jPlayer.getUniqueId(), jPlayer); } public JobsPlayer removePlayer(Player player) { @@ -186,7 +186,7 @@ public class PlayerManager { else jPlayer = Jobs.getJobsDAO().loadFromDao(player); - // Lets load quest progresion + // Lets load quest progression PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId()); if (info != null) { jPlayer.setDoneQuests(info.getQuestsDone()); @@ -336,9 +336,9 @@ public class PlayerManager { } if (points != null) - Jobs.getPointsData().addPlayer(jPlayer.getPlayerUUID(), points); + Jobs.getPointsData().addPlayer(jPlayer.getUniqueId(), points); else - Jobs.getPointsData().addPlayer(jPlayer.getPlayerUUID()); + Jobs.getPointsData().addPlayer(jPlayer.getUniqueId()); if (logs != null) jPlayer.setLog(logs); @@ -771,7 +771,7 @@ public class PlayerManager { */ public void performCommandOnLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) { int newLevel = oldLevel + 1; - Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); + Player player = Bukkit.getServer().getPlayer(jPlayer.getUniqueId()); JobProgression prog = jPlayer.getJobProgression(job); if (prog == null) return; diff --git a/src/main/java/com/gamingmesh/jobs/i18n/Language.java b/src/main/java/com/gamingmesh/jobs/i18n/Language.java index b036ab13..4f2fa7e9 100644 --- a/src/main/java/com/gamingmesh/jobs/i18n/Language.java +++ b/src/main/java/com/gamingmesh/jobs/i18n/Language.java @@ -73,6 +73,30 @@ public class Language { e.printStackTrace(); throw e; } + + if (msg.isEmpty() || msg.equals(missing)) { + msg = ""; + try { + + List ls = null; + if (customlocale.isList(key)) + ls = ColorsArray(customlocale.getStringList(key), true); + else if (enlocale.isList(key)) + ls = !enlocale.getStringList(key).isEmpty() ? ColorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing); + if (ls != null) + for (String one : ls) { + if (!msg.isEmpty()) + msg += "\n"; + msg += one; + } + } catch (Throwable e) { + Jobs.consoleMsg("&e[Jobs] &2Can't read language file for: " + key); + Bukkit.getServer().getPluginManager().disablePlugin(plugin); + e.printStackTrace(); + throw e; + } + } + if (variables.length > 0) for (int i = 0; i < variables.length; i++) { if (variables.length >= i + 2)