From 47d4cd12586d902556cbd1d7aef49c920a652248 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Mon, 27 Jul 2020 11:19:08 +0200 Subject: [PATCH] Fix when the bonus not works correctly https://github.com/Zrips/Jobs/issues/365#issuecomment-664134673 --- .../gamingmesh/jobs/PermissionManager.java | 1 - .../jobs/Placeholders/Placeholder.java | 2 +- .../gamingmesh/jobs/container/JobsPlayer.java | 21 +++++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index 0095bf6c..0eedc0dd 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -144,7 +144,6 @@ public class PermissionManager { try { t = Double.parseDouble(uno.getKey().replace(perm, "")); } catch (NumberFormatException e) { - continue; } amount += t; diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index 26ec21f6..be74907a 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -478,7 +478,7 @@ public class Placeholder { CurrencyType.getByName(vals.get(1)))); case user_jtoplvl_$1_$2: vals = placeHolder.getComplexValues(value); - if (vals.isEmpty()) + if (vals.isEmpty() || vals.size() < 2) return ""; Job job = getJobFromValue(vals.get(0)); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 4e2b02c8..25fa34b1 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -1039,6 +1039,7 @@ public class JobsPlayer { int i = g.size(); while (i > 0) { --i; + g.remove(g.entrySet().iterator().next().getKey()); if (g.size() <= job.getMaxDailyQuests()) @@ -1082,20 +1083,20 @@ public class JobsPlayer { for (QuestProgression one : getQuestProgressions()) { Quest q = one.getQuest(); - if (q == null) { + if (q == null || q.getObjectives().isEmpty()) continue; - } - if (q.getObjectives().isEmpty()) - continue; if (!prog.isEmpty()) prog += ";:;"; + prog += q.getJob().getName() + ":" + q.getConfigName() + ":" + one.getValidUntil() + ":"; + for (Entry> oneA : q.getObjectives().entrySet()) { for (Entry oneO : oneA.getValue().entrySet()) { prog += oneO.getValue().getAction().toString() + ";" + oneO.getKey() + ";" + one.getAmountDone(oneO.getValue()) + ":;:"; } } + prog = prog.endsWith(":;:") ? prog.substring(0, prog.length() - 3) : prog; } @@ -1105,21 +1106,18 @@ public class JobsPlayer { public void setQuestProgressionFromString(String qprog) { if (qprog == null || qprog.isEmpty()) return; + String[] byJob = qprog.split(";:;"); - for (String one : byJob) { - try { String jname = one.split(":")[0]; Job job = Jobs.getJob(jname); - if (job == null) continue; one = one.substring(jname.length() + 1); String qname = one.split(":")[0]; Quest quest = job.getQuest(qname); - if (quest == null) continue; @@ -1143,13 +1141,11 @@ public class JobsPlayer { } for (String oneA : one.split(":;:")) { - String prog = oneA.split(";")[0]; ActionType action = ActionType.getByName(prog); - if (action == null) - continue; - if (oneA.length() < prog.length() + 1) + if (action == null || oneA.length() < prog.length() + 1) continue; + oneA = oneA.substring(prog.length() + 1); String target = oneA.split(";")[0]; @@ -1158,7 +1154,6 @@ public class JobsPlayer { continue; QuestObjective obj = old.get(target); - if (obj == null) continue;