1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

In case locale is a string list and not a string line

This commit is contained in:
Zrips 2019-10-28 14:09:17 +02:00
parent 0a7072ffab
commit 184430f4f6
2 changed files with 32 additions and 8 deletions

View File

@ -116,15 +116,15 @@ public class PlayerManager {
public void addPlayerToCache(JobsPlayer jPlayer) { public void addPlayerToCache(JobsPlayer jPlayer) {
if (jPlayer.getUserName() != null && playersCache.get(jPlayer.getUserName().toLowerCase()) == null) if (jPlayer.getUserName() != null && playersCache.get(jPlayer.getUserName().toLowerCase()) == null)
playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer); playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer);
if (jPlayer.getPlayerUUID() != null && playersUUIDCache.get(jPlayer.getPlayerUUID()) == null) if (jPlayer.getUniqueId() != null && playersUUIDCache.get(jPlayer.getUniqueId()) == null)
playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer); playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer);
} }
public void addPlayer(JobsPlayer jPlayer) { public void addPlayer(JobsPlayer jPlayer) {
if (jPlayer.getUserName() != null && players.get(jPlayer.getUserName().toLowerCase()) == null) if (jPlayer.getUserName() != null && players.get(jPlayer.getUserName().toLowerCase()) == null)
players.put(jPlayer.getUserName().toLowerCase(), jPlayer); players.put(jPlayer.getUserName().toLowerCase(), jPlayer);
if (jPlayer.getPlayerUUID() != null && playersUUID.get(jPlayer.getPlayerUUID()) == null) if (jPlayer.getUniqueId() != null && playersUUID.get(jPlayer.getUniqueId()) == null)
playersUUID.put(jPlayer.getPlayerUUID(), jPlayer); playersUUID.put(jPlayer.getUniqueId(), jPlayer);
} }
public JobsPlayer removePlayer(Player player) { public JobsPlayer removePlayer(Player player) {
@ -186,7 +186,7 @@ public class PlayerManager {
else else
jPlayer = Jobs.getJobsDAO().loadFromDao(player); jPlayer = Jobs.getJobsDAO().loadFromDao(player);
// Lets load quest progresion // Lets load quest progression
PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId()); PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId());
if (info != null) { if (info != null) {
jPlayer.setDoneQuests(info.getQuestsDone()); jPlayer.setDoneQuests(info.getQuestsDone());
@ -336,9 +336,9 @@ public class PlayerManager {
} }
if (points != null) if (points != null)
Jobs.getPointsData().addPlayer(jPlayer.getPlayerUUID(), points); Jobs.getPointsData().addPlayer(jPlayer.getUniqueId(), points);
else else
Jobs.getPointsData().addPlayer(jPlayer.getPlayerUUID()); Jobs.getPointsData().addPlayer(jPlayer.getUniqueId());
if (logs != null) if (logs != null)
jPlayer.setLog(logs); jPlayer.setLog(logs);
@ -771,7 +771,7 @@ public class PlayerManager {
*/ */
public void performCommandOnLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) { public void performCommandOnLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
int newLevel = oldLevel + 1; int newLevel = oldLevel + 1;
Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); Player player = Bukkit.getServer().getPlayer(jPlayer.getUniqueId());
JobProgression prog = jPlayer.getJobProgression(job); JobProgression prog = jPlayer.getJobProgression(job);
if (prog == null) if (prog == null)
return; return;

View File

@ -73,6 +73,30 @@ public class Language {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} }
if (msg.isEmpty() || msg.equals(missing)) {
msg = "";
try {
List<String> 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) if (variables.length > 0)
for (int i = 0; i < variables.length; i++) { for (int i = 0; i < variables.length; i++) {
if (variables.length >= i + 2) if (variables.length >= i + 2)