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

View File

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

View File

@ -1,5 +1,6 @@
package net.knarcraft.dynmapcitizens.handler.trait.quests;
import me.blackvein.quests.QuestsAPI;
import me.blackvein.quests.quests.IQuest;
import me.blackvein.quests.quests.Requirements;
import net.knarcraft.dynmapcitizens.DynmapCitizens;
@ -31,15 +32,18 @@ import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.
*/
public class QuestRequirementsInfoGenerator {
private final QuestsAPI questsAPI;
private final IQuest quest;
private final StringFormatter formatter;
/**
* Instantiates a new quest requirement info generator
*
* @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;
formatter = DynmapCitizens.getFormatter();
}
@ -68,14 +72,14 @@ public class QuestRequirementsInfoGenerator {
QUESTS_REQUIREMENTS_EXP, "{exp}", String.valueOf(requirements.getExp())) : "");
//Add info about blocking quests
replacer.add("{requirementBlockedByQuests}", !requirements.getBlockQuests().isEmpty() ?
getRequirementList(getQuestNames(requirements.getBlockQuests()),
replacer.add("{requirementBlockedByQuests}", !requirements.getBlockQuestIds().isEmpty() ?
getRequirementList(getQuestNames(requirements.getBlockQuestIds()),
QUESTS_REQUIREMENTS_BLOCKED_BY_QUEST_FORMAT, "{blockingQuests}",
QUESTS_REQUIREMENTS_BLOCKED_BY_QUEST_ITEM, "{questName}") : "");
//Add info about required quests
replacer.add("{requirementRequiredQuests}", !requirements.getNeededQuests().isEmpty() ?
getRequirementList(getQuestNames(requirements.getNeededQuests()),
replacer.add("{requirementRequiredQuests}", !requirements.getBlockQuestIds().isEmpty() ?
getRequirementList(getQuestNames(requirements.getBlockQuestIds()),
QUESTS_REQUIREMENTS_REQUIRED_QUEST_FORMAT, "{requiredQuests}",
QUESTS_REQUIREMENTS_REQUIRED_QUEST_ITEM, "{questName}") : "");
@ -138,17 +142,35 @@ public class QuestRequirementsInfoGenerator {
/**
* 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>
*/
private List<String> getQuestNames(List<IQuest> quests) {
List<String> questNames = new ArrayList<>(quests.size());
for (IQuest quest : quests) {
private List<String> getQuestNames(List<String> questIds) {
List<String> questNames = new ArrayList<>(questIds.size());
for (String questId : questIds) {
IQuest quest = getQuest(questId);
if (quest != null) {
questNames.add(quest.getName());
}
}
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
*

View File

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