Files
CustomNPC-Plus/src/main/java/noppes/npcs/QuestLogData.java
T

146 lines
6.3 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
2024-03-15 15:43:29 -04:00
import noppes.npcs.api.handler.data.IQuest;
2018-09-13 12:03:28 -04:00
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.controllers.PlayerDataController;
2018-09-13 12:03:28 -04:00
import noppes.npcs.controllers.PlayerQuestController;
2024-03-15 15:43:29 -04:00
import noppes.npcs.controllers.data.Party;
2023-01-12 21:33:06 -05:00
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest;
2018-09-13 12:03:28 -04:00
2023-01-12 21:33:06 -05:00
import java.util.HashMap;
import java.util.Vector;
2018-09-13 12:03:28 -04:00
public class QuestLogData {
2025-03-13 17:14:45 -04:00
public String trackedQuestKey = "";
public HashMap<String, Vector<String>> categories = new HashMap<String, Vector<String>>();
public String selectedQuest = "";
public String selectedCategory = "";
public HashMap<String, String> questText = new HashMap<>();
public HashMap<String, String> questAlerts = new HashMap<>();
public HashMap<String, Vector<String>> questStatus = new HashMap<>();
public HashMap<String, String> finish = new HashMap<>();
public HashMap<String, Integer> partyQuests = new HashMap<>();
public HashMap<String, Vector<String>> partyOptions = new HashMap<>();
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Categories", NBTTags.nbtVectorMap(categories));
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts));
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
compound.setString("TrackedQuestID", trackedQuestKey);
compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests));
2024-03-05 00:40:48 -05:00
compound.setTag("PartyOptions", NBTTags.nbtVectorMap(partyOptions));
2025-03-13 17:14:45 -04:00
return compound;
}
public void readNBT(NBTTagCompound compound) {
categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10));
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
trackedQuestKey = compound.getString("TrackedQuestID");
partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10));
2024-03-05 00:40:48 -05:00
partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10));
2025-03-13 17:14:45 -04:00
}
2024-03-15 15:43:29 -04:00
2025-03-13 17:14:45 -04:00
public NBTTagCompound writeTrackedQuest() {
2024-03-15 15:43:29 -04:00
NBTTagCompound compound = new NBTTagCompound();
compound.setString("TrackedQuestID", trackedQuestKey);
return compound;
}
2025-03-13 17:14:45 -04:00
public void readTrackedQuest(NBTTagCompound compound) {
2024-03-15 15:43:29 -04:00
trackedQuestKey = compound.getString("TrackedQuestID");
}
2025-03-13 17:14:45 -04:00
public void setData(EntityPlayer player) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
2025-03-13 17:14:45 -04:00
for (Quest quest : PlayerQuestController.getActiveQuests(player)) {
String category = quest.category.title;
if (!categories.containsKey(category))
categories.put(category, new Vector<String>());
Vector<String> list = categories.get(category);
list.add(quest.title);
2024-03-02 04:09:36 -05:00
String key = category + ":" + quest.title;
2025-03-13 17:14:45 -04:00
questText.put(key, quest.logText);
questAlerts.put(key, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts));
questStatus.put(key, quest.questInterface.getQuestLogStatus(player));
if (quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(key, quest.completerNpc);
if (playerData.questData.getTrackedQuest() != null) {
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = key;
}
}
if (quest.partyOptions.allowParty) {
partyQuests.put(key, quest.id);
2024-03-05 00:40:48 -05:00
partyOptions.put(key, quest.partyOptions.getPartyOptionsList());
2025-03-13 17:14:45 -04:00
}
2018-09-13 12:03:28 -04:00
}
2024-03-15 15:43:29 -04:00
Party party = playerData.getPlayerParty();
2025-03-13 17:14:45 -04:00
if (party != null && party.getQuest() != null) {
2024-03-15 15:43:29 -04:00
if (playerData.questData.getTrackedQuest() != null) {
if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName();
}
}
}
2025-03-13 17:14:45 -04:00
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
public void setTrackedQuestKey(EntityPlayer player) {
2024-03-15 15:43:29 -04:00
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
Party party = playerData.getPlayerParty();
2025-03-13 17:14:45 -04:00
if (party != null && party.getQuest() != null) {
2024-03-15 15:43:29 -04:00
if (playerData.questData.getTrackedQuest() != null) {
if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName();
}
}
2025-03-13 17:14:45 -04:00
} else if (playerData.questData != null && playerData.questData.getTrackedQuest() != null) {
2024-03-15 15:43:29 -04:00
IQuest quest = playerData.questData.getTrackedQuest();
trackedQuestKey = quest.getCategory().getName() + ":" + quest.getName();
2025-03-13 17:14:45 -04:00
} else {
2024-03-15 15:43:29 -04:00
trackedQuestKey = "";
}
}
2025-03-13 17:14:45 -04:00
public boolean hasSelectedQuest() {
return !selectedQuest.isEmpty();
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
public String getQuestText() {
return questText.get(selectedCategory + ":" + selectedQuest);
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
public Boolean getQuestAlerts() {
return Boolean.valueOf(questAlerts.get(selectedCategory + ":" + selectedQuest));
}
2025-03-13 17:14:45 -04:00
public void toggleQuestAlerts() {
questAlerts.put(selectedCategory + ":" + selectedQuest, String.valueOf(!getQuestAlerts()));
}
2025-03-13 17:14:45 -04:00
public Vector<String> getQuestStatus() {
return questStatus.get(selectedCategory + ":" + selectedQuest);
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
public String getComplete() {
return finish.get(selectedCategory + ":" + selectedQuest);
}
2024-03-05 00:40:48 -05:00
public Vector<String> getPartyOptions() {
return partyOptions.get(selectedCategory + ":" + selectedQuest);
}
2018-09-13 12:03:28 -04:00
}