1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-21 15:41:19 +01:00

Fixed quest actions does not worked on lower case names

Now we replaces the material names to upper cased one for better match.

Fixes #1091
Fixes #967
This commit is contained in:
montlikadani 2021-03-29 15:07:21 +02:00
parent 21305dcc7e
commit 5337e2c36d
4 changed files with 19 additions and 24 deletions

View File

@ -963,10 +963,7 @@ public class Jobs extends JavaPlugin {
// no job // no job
if (numjobs == 0) { if (numjobs == 0) {
if (noneJob == null) if (noneJob == null || noneJob.isWorldBlackListed(block) || noneJob.isWorldBlackListed(block, ent) || noneJob.isWorldBlackListed(victim))
return;
if (noneJob.isWorldBlackListed(block) || noneJob.isWorldBlackListed(block, ent) || noneJob.isWorldBlackListed(victim))
return; return;
JobInfo jobinfo = noneJob.getJobInfo(info, 1); JobInfo jobinfo = noneJob.getJobInfo(info, 1);

View File

@ -1141,11 +1141,10 @@ public class ConfigManager {
if (sqsection.isString("Target")) { if (sqsection.isString("Target")) {
ActionType actionType = ActionType.getByName(sqsection.getString("Action")); ActionType actionType = ActionType.getByName(sqsection.getString("Action"));
KeyValues kv = getKeyValue(sqsection.getString("Target"), actionType, jobFullName); KeyValues kv = getKeyValue(sqsection.getString("Target").toUpperCase(), actionType, jobFullName);
if (kv != null) { if (kv != null) {
int amount = sqsection.getInt("Amount", 1); int amount = sqsection.getInt("Amount", 1);
QuestObjective objective = new QuestObjective(actionType, kv.getId(), kv.getMeta(), kv.getType() + kv.getSubType(), amount); quest.addObjective(new QuestObjective(actionType, kv.getId(), kv.getMeta(), (kv.getType() + kv.getSubType()).toUpperCase(), amount));
quest.addObjective(objective);
} }
} }
@ -1159,7 +1158,7 @@ public class ConfigManager {
try { try {
ActionType actionType = ActionType.getByName(split[0]); ActionType actionType = ActionType.getByName(split[0]);
String mats = split[1]; String mats = split[1].toUpperCase();
String[] co = mats.split(","); String[] co = mats.split(",");
int amount = 1; int amount = 1;
@ -1175,14 +1174,14 @@ public class ConfigManager {
} }
QuestObjective objective = new QuestObjective(actionType, kv.getId(), kv.getMeta(), QuestObjective objective = new QuestObjective(actionType, kv.getId(), kv.getMeta(),
kv.getType() + kv.getSubType(), amount); (kv.getType() + kv.getSubType()).toUpperCase(), amount);
quest.addObjective(objective); quest.addObjective(objective);
} }
} else { } else {
KeyValues kv = getKeyValue(mats, actionType, jobFullName); KeyValues kv = getKeyValue(mats, actionType, jobFullName);
if (kv != null) { if (kv != null) {
QuestObjective objective = new QuestObjective(actionType, kv.getId(), kv.getMeta(), QuestObjective objective = new QuestObjective(actionType, kv.getId(), kv.getMeta(),
kv.getType() + kv.getSubType(), amount); (kv.getType() + kv.getSubType()).toUpperCase(), amount);
quest.addObjective(objective); quest.addObjective(objective);
} }
} }

View File

@ -1083,8 +1083,7 @@ public class JobsPlayer {
if (qProg != null) if (qProg != null)
g = new HashMap<>(qProg); g = new HashMap<>(qProg);
Map<String, QuestProgression> tmp = new HashMap<>(); for (Entry<String, QuestProgression> one : new HashMap<>(g).entrySet()) {
for (Entry<String, QuestProgression> one : (new HashMap<>(g)).entrySet()) {
QuestProgression qp = one.getValue(); QuestProgression qp = one.getValue();
if (qp.isEnded()) { if (qp.isEnded()) {
@ -1098,8 +1097,7 @@ public class JobsPlayer {
while (i <= job.getQuests().size()) { while (i <= job.getQuests().size()) {
++i; ++i;
List<String> currentQuests = new ArrayList<>(g.keySet()); Quest q = job.getNextQuest(new ArrayList<>(g.keySet()), getJobProgression(job).getLevel());
Quest q = job.getNextQuest(currentQuests, getJobProgression(job).getLevel());
if (q == null) if (q == null)
continue; continue;
@ -1126,6 +1124,7 @@ public class JobsPlayer {
qProgression.put(job.getName(), g); qProgression.put(job.getName(), g);
Map<String, QuestProgression> tmp = new HashMap<>();
for (QuestProgression oneJ : g.values()) { for (QuestProgression oneJ : g.values()) {
Quest q = oneJ.getQuest(); Quest q = oneJ.getQuest();
if (q == null) { if (q == null) {
@ -1219,13 +1218,13 @@ public class JobsPlayer {
if (action == null || oneA.length() < prog.length() + 1) if (action == null || oneA.length() < prog.length() + 1)
continue; continue;
oneA = oneA.substring(prog.length() + 1);
String target = oneA.split(";")[0];
Map<String, QuestObjective> old = quest.getObjectives().get(action); Map<String, QuestObjective> old = quest.getObjectives().get(action);
if (old == null) if (old == null)
continue; continue;
oneA = oneA.substring(prog.length() + 1);
String target = oneA.split(";")[0];
QuestObjective obj = old.get(target); QuestObjective obj = old.get(target);
if (obj == null) if (obj == null)
continue; continue;

View File

@ -92,21 +92,21 @@ public class QuestProgression {
if (quest.isStopped() || !quest.hasAction(action.getType())) if (quest.isStopped() || !quest.hasAction(action.getType()))
return; return;
if (!quest.getObjectives().containsKey(action.getType()) || !quest.getObjectives().get(action.getType()).containsKey(action.getNameWithSub()) && !quest.getObjectives().get(action.getType()) Map<String, QuestObjective> map = quest.getObjectives().get(action.getType());
.containsKey(action.getName())) if (map == null || (!map.containsKey(action.getNameWithSub()) && !map.containsKey(action.getName())))
return; return;
for (String area : quest.getRestrictedAreas()) { for (String area : quest.getRestrictedAreas()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) { for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) {
if (quest.getRestrictedAreas().contains(a.getKey()) && a.getKey().equalsIgnoreCase(area) if (a.getKey().equalsIgnoreCase(area) && a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) {
&& a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) {
return; return;
} }
} }
} }
if (quest.getJob() != null) { Job questJob = quest.getJob();
int maxQuest = jPlayer.getPlayerMaxQuest(quest.getJob().getName()); if (questJob != null) {
int maxQuest = jPlayer.getPlayerMaxQuest(questJob.getName());
if (maxQuest > 0 && jPlayer.getDoneQuests() >= maxQuest) { if (maxQuest > 0 && jPlayer.getDoneQuests() >= maxQuest) {
return; return;
} }
@ -135,7 +135,7 @@ public class QuestProgression {
givenReward = true; givenReward = true;
jPlayer.addDoneQuest(quest.getJob()); jPlayer.addDoneQuest(questJob);
for (String one : quest.getRewardCmds()) { for (String one : quest.getRewardCmds()) {
ServerCommandEvent ev = new ServerCommandEvent(Bukkit.getConsoleSender(), one.replace("[playerName]", jPlayer.getPlayer().getName())); ServerCommandEvent ev = new ServerCommandEvent(Bukkit.getConsoleSender(), one.replace("[playerName]", jPlayer.getPlayer().getName()));