Check quest reqs despite number completed, fixes #2091

This commit is contained in:
PikaMug 2023-04-07 20:22:54 -04:00
parent cc916c5af4
commit 778c41f254
3 changed files with 37 additions and 30 deletions

View File

@ -69,8 +69,10 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
public class Quest implements IQuest {
@ -589,19 +591,22 @@ public class Quest implements IQuest {
if (quester.getQuestPoints() < requirements.getQuestPoints()) {
return false;
}
for (final IQuest q : quester.getCompletedQuestsTemp()) {
if (!requirements.getNeededQuestIds().isEmpty()
&& requirements.getNeededQuestIds().contains(q.getName())) {
return false;
}
if (!requirements.getBlockQuestIds().isEmpty()
&& !requirements.getBlockQuestIds().contains(q.getName())) {
return false;
}
final Set<String> completed = quester.getCompletedQuestsTemp().stream().map(IQuest::getId)
.collect(Collectors.toSet());
if (!requirements.getNeededQuestIds().isEmpty()
&& !completed.containsAll(requirements.getNeededQuestIds())) {
return false;
}
for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) {
if (!requirements.getBlockQuestIds().contains(q.getName())) {
return false;
if (!requirements.getBlockQuestIds().isEmpty()) {
for (final String questId : requirements.getBlockQuestIds()) {
if (completed.contains(questId)) {
return false;
}
}
for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) {
if (!requirements.getBlockQuestIds().contains(q.getId())) {
return false;
}
}
}
for (final String s : requirements.getMcmmoSkills()) {

View File

@ -1054,20 +1054,18 @@ public class Quester implements IQuester {
finishedRequirements.add(ChatColor.GRAY + "" + requirements.getQuestPoints() + " " + Lang.get("questPoints"));
}
}
for (final IQuest q : completedQuests) {
if (q != null) {
if (!requirements.getNeededQuestIds().isEmpty()) {
if (requirements.getNeededQuestIds().contains(q.getId())) {
finishedRequirements.add(ChatColor.GREEN + q.getName());
} else {
unfinishedRequirements.add(ChatColor.GRAY + q.getName());
}
}
if (!requirements.getBlockQuestIds().isEmpty()) {
if (requirements.getBlockQuestIds().contains(q.getId())) {
current.add(ChatColor.RED + quest.getName());
}
}
final Map<String, String> completed = completedQuests.stream()
.collect(Collectors.toMap(IQuest::getId, IQuest::getName));
for (final String questId : requirements.getNeededQuestIds()) {
if (completed.containsKey(questId)) {
finishedRequirements.add(ChatColor.GREEN + completed.get(questId));
} else {
unfinishedRequirements.add(ChatColor.GRAY + plugin.getQuestById(questId).getName());
}
}
for (final String questId : requirements.getBlockQuestIds()) {
if (completed.containsKey(questId)) {
current.add(ChatColor.RED + quest.getName());
}
}
for (final IQuest q : currentQuests.keySet()) {

View File

@ -28,6 +28,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class QuestCommandHandler {
@ -205,16 +207,18 @@ public class QuestCommandHandler {
+ ChatColor.ITALIC + quest.getName());
}
}
for (IQuest quest : quester.getCompletedQuestsTemp()) {
if (reqs.getBlockQuestIds().contains(quest.getId())) {
final Map<String, String> completed = quester.getCompletedQuestsTemp().stream()
.collect(Collectors.toMap(IQuest::getId, IQuest::getName));
for (final String questId : reqs.getBlockQuestIds()) {
if (completed.containsKey(questId)) {
String msg = Lang.get("haveCompleted");
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
+ quest.getName() + ChatColor.RED);
+ completed.get(questId) + ChatColor.RED);
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + msg);
} else {
String msg = Lang.get("cannotComplete");
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
+ quest.getName() + ChatColor.GREEN);
+ plugin.getQuestById(questId).getName() + ChatColor.GREEN);
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + msg);
}
}