Updates Quests-related code for the Quests 5 pre-release
This commit is contained in:
parent
87a99ed559
commit
d288b5c575
28
pom.xml
28
pom.xml
@ -68,10 +68,6 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
|
||||||
<id>knarcraft-repo</id>
|
|
||||||
<url>https://git.knarcraft.net/api/packages/EpicKnarvik97/maven</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>codemc-repo</id>
|
<id>codemc-repo</id>
|
||||||
<url>https://repo.codemc.io/repository/maven-public/</url>
|
<url>https://repo.codemc.io/repository/maven-public/</url>
|
||||||
@ -96,6 +92,10 @@
|
|||||||
<id>jitpack.io</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>knarcraft-repo</id>
|
||||||
|
<url>https://git.knarcraft.net/api/packages/EpicKnarvik97/maven</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
@ -109,10 +109,16 @@
|
|||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.pikamug.quests</groupId>
|
||||||
|
<artifactId>quests-api</artifactId>
|
||||||
|
<version>5.0.0-rc.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -128,18 +134,6 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>me.blackvein.quests</groupId>
|
|
||||||
<artifactId>quests-api</artifactId>
|
|
||||||
<version>4.8.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.blackvein.quests</groupId>
|
|
||||||
<artifactId>quests-core</artifactId>
|
|
||||||
<version>4.8.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
<artifactId>dynmap-api</artifactId>
|
<artifactId>dynmap-api</artifactId>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import net.knarcraft.dynmapcitizens.property.Icon;
|
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -11,17 +11,17 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class NPCQuestInfo {
|
public class NPCQuestInfo {
|
||||||
|
|
||||||
private final List<IQuest> questStart = new ArrayList<>();
|
private final List<Quest> questStart = new ArrayList<>();
|
||||||
private final List<IQuest> questKill = new ArrayList<>();
|
private final List<Quest> questKill = new ArrayList<>();
|
||||||
private final List<IQuest> questDeliver = new ArrayList<>();
|
private final List<Quest> questDeliver = new ArrayList<>();
|
||||||
private final List<IQuest> questInteract = new ArrayList<>();
|
private final List<Quest> questInteract = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given quest to the list of quests this NPC provides
|
* Adds the given quest to the list of quests this NPC provides
|
||||||
*
|
*
|
||||||
* @param quest <p>The quest to add</p>
|
* @param quest <p>The quest to add</p>
|
||||||
*/
|
*/
|
||||||
public void addQuestStart(IQuest quest) {
|
public void addQuestStart(Quest quest) {
|
||||||
this.questStart.add(quest);
|
this.questStart.add(quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @param quest <p>The quest to add</p>
|
* @param quest <p>The quest to add</p>
|
||||||
*/
|
*/
|
||||||
public void addQuestKill(IQuest quest) {
|
public void addQuestKill(Quest quest) {
|
||||||
this.questKill.add(quest);
|
this.questKill.add(quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @param quest <p>The quest to add</p>
|
* @param quest <p>The quest to add</p>
|
||||||
*/
|
*/
|
||||||
public void addQuestDeliver(IQuest quest) {
|
public void addQuestDeliver(Quest quest) {
|
||||||
this.questDeliver.add(quest);
|
this.questDeliver.add(quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @param quest <p>The quest to add</p>
|
* @param quest <p>The quest to add</p>
|
||||||
*/
|
*/
|
||||||
public void addQuestInteract(IQuest quest) {
|
public void addQuestInteract(Quest quest) {
|
||||||
this.questInteract.add(quest);
|
this.questInteract.add(quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @return <p>All quests this NPC is used to start</p>
|
* @return <p>All quests this NPC is used to start</p>
|
||||||
*/
|
*/
|
||||||
public List<IQuest> getQuestStarts() {
|
public List<Quest> getQuestStarts() {
|
||||||
return new ArrayList<>(this.questStart);
|
return new ArrayList<>(this.questStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @return <p>All kill quests involving this NPC</p>
|
* @return <p>All kill quests involving this NPC</p>
|
||||||
*/
|
*/
|
||||||
public List<IQuest> getQuestKills() {
|
public List<Quest> getQuestKills() {
|
||||||
return new ArrayList<>(this.questKill);
|
return new ArrayList<>(this.questKill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @return <p>All quests delivering to this NPC</p>
|
* @return <p>All quests delivering to this NPC</p>
|
||||||
*/
|
*/
|
||||||
public List<IQuest> getQuestDeliveries() {
|
public List<Quest> getQuestDeliveries() {
|
||||||
return new ArrayList<>(this.questDeliver);
|
return new ArrayList<>(this.questDeliver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class NPCQuestInfo {
|
|||||||
*
|
*
|
||||||
* @return <p>All quests requiring interaction with this NPC</p>
|
* @return <p>All quests requiring interaction with this NPC</p>
|
||||||
*/
|
*/
|
||||||
public List<IQuest> getQuestInteractions() {
|
public List<Quest> getQuestInteractions() {
|
||||||
return new ArrayList<>(this.questInteract);
|
return new ArrayList<>(this.questInteract);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.QuestsAPI;
|
import me.pikamug.quests.Quests;
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.IStage;
|
import me.pikamug.quests.quests.components.Stage;
|
||||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
import net.knarcraft.dynmapcitizens.settings.QuestsSettings;
|
import net.knarcraft.dynmapcitizens.settings.QuestsSettings;
|
||||||
import net.knarcraft.dynmapcitizens.util.DynmapHelper;
|
import net.knarcraft.dynmapcitizens.util.DynmapHelper;
|
||||||
@ -28,11 +28,11 @@ import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.
|
|||||||
*/
|
*/
|
||||||
public class QuestAreaHandler {
|
public class QuestAreaHandler {
|
||||||
|
|
||||||
private final QuestsAPI questsAPI;
|
private final Quests questsAPI;
|
||||||
private final MarkerSet killAreaMarkerSet;
|
private final MarkerSet killAreaMarkerSet;
|
||||||
private final MarkerSet reachAreaMarkerSet;
|
private final MarkerSet reachAreaMarkerSet;
|
||||||
private final QuestsSettings settings;
|
private final QuestsSettings settings;
|
||||||
private final List<IQuest> unavailableQuests;
|
private final List<Quest> unavailableQuests;
|
||||||
private final StringFormatter formatter;
|
private final StringFormatter formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,8 +43,8 @@ public class QuestAreaHandler {
|
|||||||
* @param settings <p>The quests settings to use</p>
|
* @param settings <p>The quests settings to use</p>
|
||||||
* @param unavailableQuests <p>The list of currently unavailable quests to possibly skip</p>
|
* @param unavailableQuests <p>The list of currently unavailable quests to possibly skip</p>
|
||||||
*/
|
*/
|
||||||
public QuestAreaHandler(QuestsAPI questsAPI, DynmapAPI dynmapAPI, QuestsSettings settings,
|
public QuestAreaHandler(Quests questsAPI, DynmapAPI dynmapAPI, QuestsSettings settings,
|
||||||
List<IQuest> unavailableQuests) {
|
List<Quest> unavailableQuests) {
|
||||||
this.questsAPI = questsAPI;
|
this.questsAPI = questsAPI;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.unavailableQuests = unavailableQuests;
|
this.unavailableQuests = unavailableQuests;
|
||||||
@ -59,12 +59,12 @@ public class QuestAreaHandler {
|
|||||||
public void updateQuestAreas() {
|
public void updateQuestAreas() {
|
||||||
this.killAreaMarkerSet.getCircleMarkers().forEach(GenericMarker::deleteMarker);
|
this.killAreaMarkerSet.getCircleMarkers().forEach(GenericMarker::deleteMarker);
|
||||||
this.reachAreaMarkerSet.getCircleMarkers().forEach(GenericMarker::deleteMarker);
|
this.reachAreaMarkerSet.getCircleMarkers().forEach(GenericMarker::deleteMarker);
|
||||||
for (IQuest quest : questsAPI.getLoadedQuests()) {
|
for (Quest quest : questsAPI.getLoadedQuests()) {
|
||||||
//Skip marker if quest is unavailable, and unavailable quests are hidden
|
//Skip marker if quest is unavailable, and unavailable quests are hidden
|
||||||
if (settings.hideUnavailableQuests() && this.unavailableQuests.contains(quest)) {
|
if (settings.hideUnavailableQuests() && this.unavailableQuests.contains(quest)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (IStage stage : quest.getStages()) {
|
for (Stage stage : quest.getStages()) {
|
||||||
markKillLocations(quest, stage);
|
markKillLocations(quest, stage);
|
||||||
markReachLocations(quest, stage);
|
markReachLocations(quest, stage);
|
||||||
}
|
}
|
||||||
@ -78,12 +78,12 @@ public class QuestAreaHandler {
|
|||||||
* @param quest <p>The quest the stage belongs to</p>
|
* @param quest <p>The quest the stage belongs to</p>
|
||||||
* @param stage <p>The stage to search for reach locations</p>
|
* @param stage <p>The stage to search for reach locations</p>
|
||||||
*/
|
*/
|
||||||
private void markReachLocations(IQuest quest, IStage stage) {
|
private void markReachLocations(Quest quest, Stage stage) {
|
||||||
if (settings.getReachAreaSettings().isDisabled()) {
|
if (settings.getReachAreaSettings().isDisabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < stage.getLocationsToReach().size(); i++) {
|
for (int i = 0; i < stage.getLocationsToReach().size(); i++) {
|
||||||
Location location = stage.getLocationsToReach().get(i);
|
Location location = (Location) stage.getLocationsToReach().get(i);
|
||||||
int radius = stage.getRadiiToReachWithin().get(i);
|
int radius = stage.getRadiiToReachWithin().get(i);
|
||||||
String areaName = stage.getLocationNames().get(i);
|
String areaName = stage.getLocationNames().get(i);
|
||||||
|
|
||||||
@ -106,14 +106,14 @@ public class QuestAreaHandler {
|
|||||||
* @param quest <p>The quest the stage belongs to</p>
|
* @param quest <p>The quest the stage belongs to</p>
|
||||||
* @param stage <p>The stage to search for kill locations</p>
|
* @param stage <p>The stage to search for kill locations</p>
|
||||||
*/
|
*/
|
||||||
private void markKillLocations(IQuest quest, IStage stage) {
|
private void markKillLocations(Quest quest, Stage stage) {
|
||||||
if (settings.getKillAreaSettings().isDisabled()) {
|
if (settings.getKillAreaSettings().isDisabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < stage.getLocationsToKillWithin().size(); i++) {
|
for (int i = 0; i < stage.getLocationsToKillWithin().size(); i++) {
|
||||||
Location location = stage.getLocationsToKillWithin().get(i);
|
Location location = (Location) stage.getLocationsToKillWithin().get(i);
|
||||||
int radius = stage.getRadiiToKillWithin().get(i);
|
int radius = stage.getRadiiToKillWithin().get(i);
|
||||||
EntityType mob = stage.getMobsToKill().get(i);
|
EntityType mob = (EntityType) stage.getMobsToKill().get(i);
|
||||||
int mobAmount = stage.getMobNumToKill().get(i);
|
int mobAmount = stage.getMobNumToKill().get(i);
|
||||||
String areaName = stage.getKillNames().get(i);
|
String areaName = stage.getKillNames().get(i);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.Planner;
|
import me.pikamug.quests.quests.components.Planner;
|
||||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
import net.knarcraft.knarlib.formatting.TimeFormatter;
|
import net.knarcraft.knarlib.formatting.TimeFormatter;
|
||||||
|
|
||||||
@ -14,14 +14,14 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
public class QuestPlannerInfoGenerator {
|
public class QuestPlannerInfoGenerator {
|
||||||
|
|
||||||
private final IQuest quest;
|
private final Quest quest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest planner info generator
|
* Instantiates a new quest planner info generator
|
||||||
*
|
*
|
||||||
* @param quest <p>The quest to generate information about</p>
|
* @param quest <p>The quest to generate information about</p>
|
||||||
*/
|
*/
|
||||||
public QuestPlannerInfoGenerator(IQuest quest) {
|
public QuestPlannerInfoGenerator(Quest quest) {
|
||||||
this.quest = quest;
|
this.quest = quest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.QuestsAPI;
|
import me.pikamug.quests.Quests;
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.Requirements;
|
import me.pikamug.quests.quests.components.Requirements;
|
||||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||||
@ -32,8 +32,8 @@ import static net.knarcraft.dynmapcitizens.formatting.QuestsTranslatableMessage.
|
|||||||
*/
|
*/
|
||||||
public class QuestRequirementsInfoGenerator {
|
public class QuestRequirementsInfoGenerator {
|
||||||
|
|
||||||
private final QuestsAPI questsAPI;
|
private final Quests questsAPI;
|
||||||
private final IQuest quest;
|
private final Quest quest;
|
||||||
private final StringFormatter formatter;
|
private final StringFormatter formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +42,7 @@ public class QuestRequirementsInfoGenerator {
|
|||||||
* @param questsAPI <p>The API to use for getting quest information</p>
|
* @param questsAPI <p>The API to use for getting quest information</p>
|
||||||
* @param quest <p>The quest to generate information about</p>
|
* @param quest <p>The quest to generate information about</p>
|
||||||
*/
|
*/
|
||||||
public QuestRequirementsInfoGenerator(QuestsAPI questsAPI, IQuest quest) {
|
public QuestRequirementsInfoGenerator(Quests questsAPI, Quest quest) {
|
||||||
this.questsAPI = questsAPI;
|
this.questsAPI = questsAPI;
|
||||||
this.quest = quest;
|
this.quest = quest;
|
||||||
formatter = DynmapCitizens.getFormatter();
|
formatter = DynmapCitizens.getFormatter();
|
||||||
@ -131,10 +131,10 @@ public class QuestRequirementsInfoGenerator {
|
|||||||
* @param items <p>The items to get the names of</p>
|
* @param items <p>The items to get the names of</p>
|
||||||
* @return <p>The names of the given items</p>
|
* @return <p>The names of the given items</p>
|
||||||
*/
|
*/
|
||||||
private List<String> getItemNames(List<ItemStack> items) {
|
private List<String> getItemNames(List<?> items) {
|
||||||
List<String> itemNames = new ArrayList<>();
|
List<String> itemNames = new ArrayList<>();
|
||||||
for (ItemStack itemStack : items) {
|
for (Object itemStack : items) {
|
||||||
itemNames.add(QuestsHelper.getUpperCasedItemStackString(itemStack));
|
itemNames.add(QuestsHelper.getUpperCasedItemStackString((ItemStack) itemStack));
|
||||||
}
|
}
|
||||||
return itemNames;
|
return itemNames;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public class QuestRequirementsInfoGenerator {
|
|||||||
private List<String> getQuestNames(List<String> questIds) {
|
private List<String> getQuestNames(List<String> questIds) {
|
||||||
List<String> questNames = new ArrayList<>(questIds.size());
|
List<String> questNames = new ArrayList<>(questIds.size());
|
||||||
for (String questId : questIds) {
|
for (String questId : questIds) {
|
||||||
IQuest quest = getQuest(questId);
|
Quest quest = getQuest(questId);
|
||||||
if (quest != null) {
|
if (quest != null) {
|
||||||
questNames.add(quest.getName());
|
questNames.add(quest.getName());
|
||||||
}
|
}
|
||||||
@ -162,8 +162,8 @@ public class QuestRequirementsInfoGenerator {
|
|||||||
* @param questId <p>The id of the quest to get</p>
|
* @param questId <p>The id of the quest to get</p>
|
||||||
* @return <p>The quest, or null if not found</p>
|
* @return <p>The quest, or null if not found</p>
|
||||||
*/
|
*/
|
||||||
private IQuest getQuest(String questId) {
|
private Quest getQuest(String questId) {
|
||||||
for (IQuest quest : questsAPI.getLoadedQuests()) {
|
for (Quest quest : questsAPI.getLoadedQuests()) {
|
||||||
if (quest.getId().equals(questId)) {
|
if (quest.getId().equals(questId)) {
|
||||||
return quest;
|
return quest;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.Rewards;
|
import me.pikamug.quests.quests.components.Rewards;
|
||||||
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -10,14 +10,14 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
*/
|
*/
|
||||||
public class QuestRewardsInfoGenerator {
|
public class QuestRewardsInfoGenerator {
|
||||||
|
|
||||||
private final IQuest quest;
|
private final Quest quest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest reward info generator
|
* Instantiates a new quest reward info generator
|
||||||
*
|
*
|
||||||
* @param quest <p>The quest to generate information about</p>
|
* @param quest <p>The quest to generate information about</p>
|
||||||
*/
|
*/
|
||||||
public QuestRewardsInfoGenerator(IQuest quest) {
|
public QuestRewardsInfoGenerator(Quest quest) {
|
||||||
this.quest = quest;
|
this.quest = quest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ public class QuestRewardsInfoGenerator {
|
|||||||
rewardInfo.append("<li>").append("Permission: ").append(permission).append("</li>");
|
rewardInfo.append("<li>").append("Permission: ").append(permission).append("</li>");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack item : reward.getItems()) {
|
for (Object item : reward.getItems()) {
|
||||||
rewardInfo.append("<li>").append(QuestsHelper.getUpperCasedItemStackString(item)).append("</li>");
|
rewardInfo.append("<li>").append(QuestsHelper.getUpperCasedItemStackString((ItemStack) item)).append("</li>");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String command : reward.getCommands()) {
|
for (String command : reward.getCommands()) {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.IStage;
|
import me.pikamug.quests.quests.components.Stage;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -17,14 +18,14 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class QuestStagesInfoGenerator {
|
public class QuestStagesInfoGenerator {
|
||||||
|
|
||||||
private final IQuest quest;
|
private final Quest quest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest stages info generator
|
* Instantiates a new quest stages info generator
|
||||||
*
|
*
|
||||||
* @param quest <p>The quest to generate information about</p>
|
* @param quest <p>The quest to generate information about</p>
|
||||||
*/
|
*/
|
||||||
public QuestStagesInfoGenerator(IQuest quest) {
|
public QuestStagesInfoGenerator(Quest quest) {
|
||||||
this.quest = quest;
|
this.quest = quest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class QuestStagesInfoGenerator {
|
|||||||
questInfo.append(getStageInfo(quest.getStage(0), registry));
|
questInfo.append(getStageInfo(quest.getStage(0), registry));
|
||||||
} else {
|
} else {
|
||||||
questInfo.append("<b>Stages:</b><ul>");
|
questInfo.append("<b>Stages:</b><ul>");
|
||||||
for (IStage stage : quest.getStages()) {
|
for (Stage stage : quest.getStages()) {
|
||||||
questInfo.append("<li><b>Stage ").append(stageCounter).append(" tasks:</b><ul>");
|
questInfo.append("<li><b>Stage ").append(stageCounter).append(" tasks:</b><ul>");
|
||||||
|
|
||||||
questInfo.append(getStageInfo(stage, registry));
|
questInfo.append(getStageInfo(stage, registry));
|
||||||
@ -64,11 +65,11 @@ public class QuestStagesInfoGenerator {
|
|||||||
* @param registry <p>The registry to get NPC info from</p>
|
* @param registry <p>The registry to get NPC info from</p>
|
||||||
* @return <p>Information about the stage's tasks</p>
|
* @return <p>Information about the stage's tasks</p>
|
||||||
*/
|
*/
|
||||||
private String getStageInfo(IStage stage, NPCRegistry registry) {
|
private String getStageInfo(Stage stage, NPCRegistry registry) {
|
||||||
StringBuilder questInfo = new StringBuilder();
|
StringBuilder questInfo = new StringBuilder();
|
||||||
int mobTypes = stage.getMobsToKill().size();
|
int mobTypes = stage.getMobsToKill().size();
|
||||||
for (int i = 0; i < mobTypes; i++) {
|
for (int i = 0; i < mobTypes; i++) {
|
||||||
questInfo.append("<li>Kill ").append(QuestsHelper.normalizeName(stage.getMobsToKill().get(i).name()));
|
questInfo.append("<li>Kill ").append(QuestsHelper.normalizeName(((DyeColor) stage.getMobsToKill().get(i)).name()));
|
||||||
questInfo.append(" x ").append(stage.getMobNumToKill().get(i));
|
questInfo.append(" x ").append(stage.getMobNumToKill().get(i));
|
||||||
if (stage.getKillNames().size() > i) {
|
if (stage.getKillNames().size() > i) {
|
||||||
questInfo.append(" at ").append(stage.getKillNames().get(i));
|
questInfo.append(" at ").append(stage.getKillNames().get(i));
|
||||||
@ -79,13 +80,13 @@ public class QuestStagesInfoGenerator {
|
|||||||
for (int i = 0; i < reachLocations; i++) {
|
for (int i = 0; i < reachLocations; i++) {
|
||||||
questInfo.append("<li>Reach ").append(stage.getLocationNames().get(i)).append(", within ");
|
questInfo.append("<li>Reach ").append(stage.getLocationNames().get(i)).append(", within ");
|
||||||
questInfo.append(stage.getRadiiToReachWithin().get(i)).append(" blocks of ");
|
questInfo.append(stage.getRadiiToReachWithin().get(i)).append(" blocks of ");
|
||||||
questInfo.append(getLocationString(stage.getLocationsToReach().get(i))).append("</li>");
|
questInfo.append(getLocationString((Location) stage.getLocationsToReach().get(i))).append("</li>");
|
||||||
}
|
}
|
||||||
|
|
||||||
int deliveries = stage.getItemDeliveryTargets().size();
|
int deliveries = stage.getItemDeliveryTargets().size();
|
||||||
for (int i = 0; i < deliveries; i++) {
|
for (int i = 0; i < deliveries; i++) {
|
||||||
NPC npc = registry.getByUniqueId(stage.getItemDeliveryTargets().get(i));
|
NPC npc = registry.getByUniqueId(stage.getItemDeliveryTargets().get(i));
|
||||||
questInfo.append("<li>Deliver ").append(QuestsHelper.getItemStackString(stage.getItemsToDeliver().get(i))).append(
|
questInfo.append("<li>Deliver ").append(QuestsHelper.getItemStackString((ItemStack) stage.getItemsToDeliver().get(i))).append(
|
||||||
" to ").append(npc.getName()).append("</li>");
|
" to ").append(npc.getName()).append("</li>");
|
||||||
}
|
}
|
||||||
if (stage.getFishToCatch() != null) {
|
if (stage.getFishToCatch() != null) {
|
||||||
@ -113,7 +114,7 @@ public class QuestStagesInfoGenerator {
|
|||||||
int sheepTypes = stage.getSheepToShear().size();
|
int sheepTypes = stage.getSheepToShear().size();
|
||||||
for (int i = 0; i < sheepTypes; i++) {
|
for (int i = 0; i < sheepTypes; i++) {
|
||||||
questInfo.append("<li>Shear ").append(stage.getSheepNumToShear().get(i)).append(" ").append(
|
questInfo.append("<li>Shear ").append(stage.getSheepNumToShear().get(i)).append(" ").append(
|
||||||
QuestsHelper.normalizeName(stage.getSheepToShear().get(i).name())).append(" sheep").append("</li>");
|
QuestsHelper.normalizeName(((DyeColor) stage.getSheepToShear().get(i)).name())).append(" sheep").append("</li>");
|
||||||
}
|
}
|
||||||
if (stage.getCowsToMilk() != null) {
|
if (stage.getCowsToMilk() != null) {
|
||||||
questInfo.append("<li>Milk ").append(stage.getCowsToMilk()).append(" cows").append("</li>");
|
questInfo.append("<li>Milk ").append(stage.getCowsToMilk()).append(" cows").append("</li>");
|
||||||
@ -122,7 +123,7 @@ public class QuestStagesInfoGenerator {
|
|||||||
int mobTamingEntries = stage.getMobsToTame().size();
|
int mobTamingEntries = stage.getMobsToTame().size();
|
||||||
for (int i = 0; i < mobTamingEntries; i++) {
|
for (int i = 0; i < mobTamingEntries; i++) {
|
||||||
questInfo.append("<li>Tame ").append(stage.getMobNumToTame().get(i)).append(" ").append(
|
questInfo.append("<li>Tame ").append(stage.getMobNumToTame().get(i)).append(" ").append(
|
||||||
QuestsHelper.normalizeName(stage.getMobsToTame().get(i).name())).append("</li>");
|
QuestsHelper.normalizeName(((DyeColor) stage.getMobsToTame().get(i)).name())).append("</li>");
|
||||||
}
|
}
|
||||||
|
|
||||||
return questInfo.toString();
|
return questInfo.toString();
|
||||||
@ -149,10 +150,10 @@ public class QuestStagesInfoGenerator {
|
|||||||
* @param explanation <p>The explanation of what the player needs to do with the items</p>
|
* @param explanation <p>The explanation of what the player needs to do with the items</p>
|
||||||
* @return <p>A string describing the necessary tasks</p>
|
* @return <p>A string describing the necessary tasks</p>
|
||||||
*/
|
*/
|
||||||
private String getQuestItemsTaskString(List<ItemStack> items, String explanation) {
|
private String getQuestItemsTaskString(List<?> items, String explanation) {
|
||||||
StringBuilder questInfo = new StringBuilder();
|
StringBuilder questInfo = new StringBuilder();
|
||||||
for (ItemStack itemStack : items) {
|
for (Object itemStack : items) {
|
||||||
questInfo.append(explanation).append(QuestsHelper.getItemStackString(itemStack));
|
questInfo.append(explanation).append(QuestsHelper.getItemStackString((ItemStack) itemStack));
|
||||||
}
|
}
|
||||||
return questInfo.toString();
|
return questInfo.toString();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.QuestsAPI;
|
import me.pikamug.quests.Quests;
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.IStage;
|
import me.pikamug.quests.quests.components.Stage;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
@ -29,16 +29,16 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class QuestsHandler extends AbstractTraitHandler {
|
public class QuestsHandler extends AbstractTraitHandler {
|
||||||
|
|
||||||
private QuestsAPI questsAPI;
|
private Quests questsAPI;
|
||||||
private Map<Icon, MarkerIcon> markerIcons;
|
private Map<Icon, MarkerIcon> markerIcons;
|
||||||
private final Map<UUID, NPCQuestInfo> questGiverInfo = new HashMap<>();
|
private final Map<UUID, NPCQuestInfo> questGiverInfo = new HashMap<>();
|
||||||
private final QuestsSettings settings = new QuestsSettings();
|
private final QuestsSettings settings = new QuestsSettings();
|
||||||
private final List<IQuest> unavailableQuests = new ArrayList<>();
|
private final List<Quest> unavailableQuests = new ArrayList<>();
|
||||||
private QuestAreaHandler questAreaHandler;
|
private QuestAreaHandler questAreaHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
questsAPI = (QuestsAPI) Bukkit.getServer().getPluginManager().getPlugin("Quests");
|
questsAPI = (Quests) Bukkit.getServer().getPluginManager().getPlugin("Quests");
|
||||||
DynmapAPI dynmapAPI = DynmapCitizens.getInstance().getDynmapAPI();
|
DynmapAPI dynmapAPI = DynmapCitizens.getInstance().getDynmapAPI();
|
||||||
markerIcons = DynmapCitizens.getInstance().getGlobalSettings().getMarkerIcons();
|
markerIcons = DynmapCitizens.getInstance().getGlobalSettings().getMarkerIcons();
|
||||||
if (questsAPI != null) {
|
if (questsAPI != null) {
|
||||||
@ -87,7 +87,7 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
questGiverInfo.clear();
|
questGiverInfo.clear();
|
||||||
unavailableQuests.clear();
|
unavailableQuests.clear();
|
||||||
//Generation information about NPC's parts in each quest
|
//Generation information about NPC's parts in each quest
|
||||||
for (IQuest quest : questsAPI.getLoadedQuests()) {
|
for (Quest quest : questsAPI.getLoadedQuests()) {
|
||||||
if (QuestsHelper.isQuestUnavailable(quest)) {
|
if (QuestsHelper.isQuestUnavailable(quest)) {
|
||||||
unavailableQuests.add(quest);
|
unavailableQuests.add(quest);
|
||||||
//If unavailable quests aren't displayed, there is no point in continuing
|
//If unavailable quests aren't displayed, there is no point in continuing
|
||||||
@ -98,7 +98,7 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
if (quest.getNpcStart() != null) {
|
if (quest.getNpcStart() != null) {
|
||||||
getInfo(quest.getNpcStart()).addQuestStart(quest);
|
getInfo(quest.getNpcStart()).addQuestStart(quest);
|
||||||
}
|
}
|
||||||
for (IStage stage : quest.getStages()) {
|
for (Stage stage : quest.getStages()) {
|
||||||
for (UUID npcId : stage.getNpcsToKill()) {
|
for (UUID npcId : stage.getNpcsToKill()) {
|
||||||
getInfo(npcId).addQuestKill(quest);
|
getInfo(npcId).addQuestKill(quest);
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
for (UUID npcId : questGiverInfo.keySet()) {
|
for (UUID npcId : questGiverInfo.keySet()) {
|
||||||
NPCQuestInfo info = questGiverInfo.get(npcId);
|
NPCQuestInfo info = questGiverInfo.get(npcId);
|
||||||
MarkerIcon icon = markerIcons.get(info.getNPCIcon());
|
MarkerIcon icon = markerIcons.get(info.getNPCIcon());
|
||||||
List<IQuest> offeredQuests = info.getQuestStarts();
|
List<Quest> offeredQuests = info.getQuestStarts();
|
||||||
StringBuilder markerDescription = new StringBuilder();
|
StringBuilder markerDescription = new StringBuilder();
|
||||||
|
|
||||||
markerDescription.append("<h2>").append(registry.getByUniqueId(npcId).getName()).append("</h2>");
|
markerDescription.append("<h2>").append(registry.getByUniqueId(npcId).getName()).append("</h2>");
|
||||||
@ -151,9 +151,9 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
* @param stringBuilder <p>The string builder to append to</p>
|
* @param stringBuilder <p>The string builder to append to</p>
|
||||||
* @param offeredQuests <p>The list of quests the NPC offers</p>
|
* @param offeredQuests <p>The list of quests the NPC offers</p>
|
||||||
*/
|
*/
|
||||||
private void appendOfferedQuestsInfo(StringBuilder stringBuilder, List<IQuest> offeredQuests) {
|
private void appendOfferedQuestsInfo(StringBuilder stringBuilder, List<Quest> offeredQuests) {
|
||||||
stringBuilder.append("<h3>Quests offered:</h3><ul>");
|
stringBuilder.append("<h3>Quests offered:</h3><ul>");
|
||||||
for (IQuest quest : offeredQuests) {
|
for (Quest quest : offeredQuests) {
|
||||||
stringBuilder.append("<li><h4><b>").append(quest.getName()).append("</b></h4><h5><b>- ");
|
stringBuilder.append("<li><h4><b>").append(quest.getName()).append("</b></h4><h5><b>- ");
|
||||||
stringBuilder.append(quest.getDescription()).append("</b></h5>");
|
stringBuilder.append(quest.getDescription()).append("</b></h5>");
|
||||||
if (settings.displayStageInfo()) {
|
if (settings.displayStageInfo()) {
|
||||||
@ -180,9 +180,9 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
* @return <p>Information about an NPC's involvement in different quests</p>
|
* @return <p>Information about an NPC's involvement in different quests</p>
|
||||||
*/
|
*/
|
||||||
private String getInvolvedInQuestsString(NPCQuestInfo info) {
|
private String getInvolvedInQuestsString(NPCQuestInfo info) {
|
||||||
List<IQuest> questKills = info.getQuestKills();
|
List<Quest> questKills = info.getQuestKills();
|
||||||
List<IQuest> questInteractions = info.getQuestInteractions();
|
List<Quest> questInteractions = info.getQuestInteractions();
|
||||||
List<IQuest> questDeliveries = info.getQuestDeliveries();
|
List<Quest> questDeliveries = info.getQuestDeliveries();
|
||||||
|
|
||||||
if (questKills.isEmpty() && questInteractions.isEmpty() && questDeliveries.isEmpty()) {
|
if (questKills.isEmpty() && questInteractions.isEmpty() && questDeliveries.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
@ -203,8 +203,8 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
* @param quests <p>The quests the NPC is involved in</p>
|
* @param quests <p>The quests the NPC is involved in</p>
|
||||||
* @param builder <p>The string builder to append to</p>
|
* @param builder <p>The string builder to append to</p>
|
||||||
*/
|
*/
|
||||||
private void addInvolvedInString(String prefix, List<IQuest> quests, StringBuilder builder) {
|
private void addInvolvedInString(String prefix, List<Quest> quests, StringBuilder builder) {
|
||||||
for (IQuest quest : new HashSet<>(quests)) {
|
for (Quest quest : new HashSet<>(quests)) {
|
||||||
builder.append("<li>").append(prefix).append(": ").append(quest.getName()).append("</li>");
|
builder.append("<li>").append(prefix).append(": ").append(quest.getName()).append("</li>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.knarcraft.dynmapcitizens.util;
|
package net.knarcraft.dynmapcitizens.util;
|
||||||
|
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.pikamug.quests.quests.Quest;
|
||||||
import me.blackvein.quests.quests.Planner;
|
import me.pikamug.quests.quests.components.Planner;
|
||||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
import net.knarcraft.dynmapcitizens.handler.VaultHandler;
|
import net.knarcraft.dynmapcitizens.handler.VaultHandler;
|
||||||
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestNPCType;
|
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestNPCType;
|
||||||
@ -89,7 +89,7 @@ public class QuestsHelper {
|
|||||||
* @param quest <p>The quest to check for availability</p>
|
* @param quest <p>The quest to check for availability</p>
|
||||||
* @return <p>True if the quest is unavailable</p>
|
* @return <p>True if the quest is unavailable</p>
|
||||||
*/
|
*/
|
||||||
public static boolean isQuestUnavailable(IQuest quest) {
|
public static boolean isQuestUnavailable(Quest quest) {
|
||||||
Planner planner = quest.getPlanner();
|
Planner planner = quest.getPlanner();
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user