Updates to account for some changes in quests
All checks were successful
EpicKnarvik97/DynmapCitizens/pipeline/head This commit looks good
KnarCraft/DynmapCitizens/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2023-04-12 02:34:09 +02:00
parent 5618be7f99
commit 9312e2156b
4 changed files with 45 additions and 23 deletions

20
pom.xml
View File

@ -93,8 +93,8 @@
<url>https://repo.citizensnpcs.co/</url> <url>https://repo.citizensnpcs.co/</url>
</repository> </repository>
<repository> <repository>
<id>vault-repo</id> <id>jitpack.io</id>
<url>https://nexus.hc.to/content/repositories/pub_releases</url> <url>https://jitpack.io</url>
</repository> </repository>
</repositories> </repositories>
<distributionManagement> <distributionManagement>
@ -112,7 +112,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version> <version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -131,13 +131,13 @@
<dependency> <dependency>
<groupId>me.blackvein.quests</groupId> <groupId>me.blackvein.quests</groupId>
<artifactId>quests-api</artifactId> <artifactId>quests-api</artifactId>
<version>4.6.0</version> <version>4.8.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.blackvein.quests</groupId> <groupId>me.blackvein.quests</groupId>
<artifactId>quests-core</artifactId> <artifactId>quests-core</artifactId>
<version>4.6.0</version> <version>4.8.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -149,7 +149,7 @@
<dependency> <dependency>
<groupId>net.knarcraft</groupId> <groupId>net.knarcraft</groupId>
<artifactId>blacksmith</artifactId> <artifactId>blacksmith</artifactId>
<version>1.0.3-SNAPSHOT</version> <version>1.0.4-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -159,15 +159,15 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>com.github.MilkBowl</groupId>
<artifactId>Vault</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.7.3</version> <version>1.7</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.knarcraft</groupId> <groupId>net.knarcraft</groupId>
<artifactId>knarlib</artifactId> <artifactId>knarlib</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -62,7 +62,7 @@ public final class DynmapCitizens extends JavaPlugin {
translator.registerMessageCategory(TranslatableTimeUnit.UNIT_SECOND); translator.registerMessageCategory(TranslatableTimeUnit.UNIT_SECOND);
translator.registerMessageCategory(QuestsTranslatableMessage.QUESTS_REQUIREMENTS_FORMAT); translator.registerMessageCategory(QuestsTranslatableMessage.QUESTS_REQUIREMENTS_FORMAT);
translator.registerMessageCategory(SentinelTranslatableMessage.SENTINEL_DESCRIPTION); translator.registerMessageCategory(SentinelTranslatableMessage.SENTINEL_DESCRIPTION);
translator.loadLanguages(this.getDataFolder(), "en"); translator.loadLanguages(this.getDataFolder(), "en", "en");
stringFormatter = new StringFormatter(this.getDescription().getName(), translator); stringFormatter = new StringFormatter(this.getDescription().getName(), translator);
//Initialize all enabled traits //Initialize all enabled traits

View File

@ -1,5 +1,6 @@
package net.knarcraft.dynmapcitizens.handler.trait.quests; package net.knarcraft.dynmapcitizens.handler.trait.quests;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.quests.IQuest;
import me.blackvein.quests.quests.Requirements; import me.blackvein.quests.quests.Requirements;
import net.knarcraft.dynmapcitizens.DynmapCitizens; import net.knarcraft.dynmapcitizens.DynmapCitizens;
@ -31,15 +32,18 @@ import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.
*/ */
public class QuestRequirementsInfoGenerator { public class QuestRequirementsInfoGenerator {
private final QuestsAPI questsAPI;
private final IQuest quest; private final IQuest quest;
private final StringFormatter formatter; private final StringFormatter formatter;
/** /**
* Instantiates a new quest requirement info generator * Instantiates a new quest requirement info generator
* *
* @param quest <p>The quest to generate information about</p> * @param questsAPI <p>The API to use for getting quest information</p>
* @param quest <p>The quest to generate information about</p>
*/ */
public QuestRequirementsInfoGenerator(IQuest quest) { public QuestRequirementsInfoGenerator(QuestsAPI questsAPI, IQuest quest) {
this.questsAPI = questsAPI;
this.quest = quest; this.quest = quest;
formatter = DynmapCitizens.getFormatter(); formatter = DynmapCitizens.getFormatter();
} }
@ -68,14 +72,14 @@ public class QuestRequirementsInfoGenerator {
QUESTS_REQUIREMENTS_EXP, "{exp}", String.valueOf(requirements.getExp())) : ""); QUESTS_REQUIREMENTS_EXP, "{exp}", String.valueOf(requirements.getExp())) : "");
//Add info about blocking quests //Add info about blocking quests
replacer.add("{requirementBlockedByQuests}", !requirements.getBlockQuests().isEmpty() ? replacer.add("{requirementBlockedByQuests}", !requirements.getBlockQuestIds().isEmpty() ?
getRequirementList(getQuestNames(requirements.getBlockQuests()), getRequirementList(getQuestNames(requirements.getBlockQuestIds()),
QUESTS_REQUIREMENTS_BLOCKED_BY_QUEST_FORMAT, "{blockingQuests}", QUESTS_REQUIREMENTS_BLOCKED_BY_QUEST_FORMAT, "{blockingQuests}",
QUESTS_REQUIREMENTS_BLOCKED_BY_QUEST_ITEM, "{questName}") : ""); QUESTS_REQUIREMENTS_BLOCKED_BY_QUEST_ITEM, "{questName}") : "");
//Add info about required quests //Add info about required quests
replacer.add("{requirementRequiredQuests}", !requirements.getNeededQuests().isEmpty() ? replacer.add("{requirementRequiredQuests}", !requirements.getBlockQuestIds().isEmpty() ?
getRequirementList(getQuestNames(requirements.getNeededQuests()), getRequirementList(getQuestNames(requirements.getBlockQuestIds()),
QUESTS_REQUIREMENTS_REQUIRED_QUEST_FORMAT, "{requiredQuests}", QUESTS_REQUIREMENTS_REQUIRED_QUEST_FORMAT, "{requiredQuests}",
QUESTS_REQUIREMENTS_REQUIRED_QUEST_ITEM, "{questName}") : ""); QUESTS_REQUIREMENTS_REQUIRED_QUEST_ITEM, "{questName}") : "");
@ -138,17 +142,35 @@ public class QuestRequirementsInfoGenerator {
/** /**
* Gets a list of the quest names for the given quests * Gets a list of the quest names for the given quests
* *
* @param quests <p>The quests to get names for</p> * @param questIds <p>The quests to get names for</p>
* @return <p>A list of quest names</p> * @return <p>A list of quest names</p>
*/ */
private List<String> getQuestNames(List<IQuest> quests) { private List<String> getQuestNames(List<String> questIds) {
List<String> questNames = new ArrayList<>(quests.size()); List<String> questNames = new ArrayList<>(questIds.size());
for (IQuest quest : quests) { for (String questId : questIds) {
questNames.add(quest.getName()); IQuest quest = getQuest(questId);
if (quest != null) {
questNames.add(quest.getName());
}
} }
return questNames; return questNames;
} }
/**
* Gets the quest with the given id
*
* @param questId <p>The id of the quest to get</p>
* @return <p>The quest, or null if not found</p>
*/
private IQuest getQuest(String questId) {
for (IQuest quest : questsAPI.getLoadedQuests()) {
if (quest.getId().equals(questId)) {
return quest;
}
}
return null;
}
/** /**
* Gets a string for the given list of requirements * Gets a string for the given list of requirements
* *

View File

@ -163,7 +163,7 @@ public class QuestsHandler extends AbstractTraitHandler {
stringBuilder.append(new QuestRewardsInfoGenerator(quest).getQuestRewardsInfo()); stringBuilder.append(new QuestRewardsInfoGenerator(quest).getQuestRewardsInfo());
} }
if (settings.displayRequirementInfo()) { if (settings.displayRequirementInfo()) {
stringBuilder.append(new QuestRequirementsInfoGenerator(quest).getQuestRequirementsInfo()); stringBuilder.append(new QuestRequirementsInfoGenerator(questsAPI, quest).getQuestRequirementsInfo());
} }
if (settings.displayPlannerInfo()) { if (settings.displayPlannerInfo()) {
stringBuilder.append(new QuestPlannerInfoGenerator(quest).getQuestPlannerInfo()); stringBuilder.append(new QuestPlannerInfoGenerator(quest).getQuestPlannerInfo());