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;
|
2022-02-02 07:18:33 -06:00
|
|
|
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;
|
2022-05-24 01:07:50 -05:00
|
|
|
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 {
|
2022-05-27 14:32:24 -05:00
|
|
|
public String trackedQuestKey = "";
|
2018-09-13 12:03:28 -04:00
|
|
|
public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>();
|
|
|
|
|
public String selectedQuest = "";
|
|
|
|
|
public String selectedCategory = "";
|
2024-02-13 13:24:25 -06:00
|
|
|
public HashMap<String,String> questText = new HashMap<>();
|
2023-03-16 23:37:57 -05:00
|
|
|
public HashMap<String,String> questAlerts = new HashMap<>();
|
2024-02-13 13:24:25 -06:00
|
|
|
public HashMap<String,Vector<String>> questStatus = new HashMap<>();
|
|
|
|
|
public HashMap<String,String> finish = new HashMap<>();
|
2024-03-03 06:32:50 -05:00
|
|
|
public HashMap<String, Integer> partyQuests = new HashMap<>();
|
2024-03-05 00:40:48 -05:00
|
|
|
public HashMap<String,Vector<String>> partyOptions = new HashMap<>();
|
2024-03-02 04:09:36 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public NBTTagCompound writeNBT(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
compound.setTag("Categories", NBTTags.nbtVectorMap(categories));
|
|
|
|
|
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
|
2023-03-16 23:37:57 -05:00
|
|
|
compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts));
|
2018-09-13 12:03:28 -04:00
|
|
|
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
|
|
|
|
|
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
|
2022-05-27 14:32:24 -05:00
|
|
|
compound.setString("TrackedQuestID", trackedQuestKey);
|
2024-03-03 06:32:50 -05:00
|
|
|
compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests));
|
2024-03-05 00:40:48 -05:00
|
|
|
compound.setTag("PartyOptions", NBTTags.nbtVectorMap(partyOptions));
|
2018-09-13 12:03:28 -04:00
|
|
|
return compound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void readNBT(NBTTagCompound compound){
|
|
|
|
|
categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10));
|
|
|
|
|
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
|
2023-03-16 23:37:57 -05:00
|
|
|
questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
|
2018-09-13 12:03:28 -04:00
|
|
|
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
|
|
|
|
|
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
|
2022-05-27 14:32:24 -05:00
|
|
|
trackedQuestKey = compound.getString("TrackedQuestID");
|
2024-03-03 06:32:50 -05:00
|
|
|
partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10));
|
2024-03-05 00:40:48 -05:00
|
|
|
partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2024-03-15 15:43:29 -04:00
|
|
|
|
|
|
|
|
public NBTTagCompound writeTrackedQuest(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
compound.setString("TrackedQuestID", trackedQuestKey);
|
|
|
|
|
return compound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void readTrackedQuest(NBTTagCompound compound){
|
|
|
|
|
trackedQuestKey = compound.getString("TrackedQuestID");
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setData(EntityPlayer player){
|
2023-06-05 19:35:06 -04:00
|
|
|
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
2022-05-27 14:32:24 -05:00
|
|
|
|
|
|
|
|
for(Quest quest : PlayerQuestController.getActiveQuests(player))
|
2018-09-13 12:03:28 -04:00
|
|
|
{
|
|
|
|
|
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
|
|
|
|
2024-03-03 06:32:50 -05:00
|
|
|
String key = category + ":" + quest.title;
|
|
|
|
|
questText.put(key, quest.logText);
|
|
|
|
|
questAlerts.put(key, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts));
|
|
|
|
|
questStatus.put(key, quest.questInterface.getQuestLogStatus(player));
|
2022-02-02 07:18:33 -06:00
|
|
|
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
|
2024-03-03 06:32:50 -05:00
|
|
|
finish.put(key, quest.completerNpc);
|
2022-05-27 14:32:24 -05:00
|
|
|
|
2023-05-11 20:17:16 -05:00
|
|
|
if (playerData.questData.getTrackedQuest() != null) {
|
|
|
|
|
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
|
2024-03-03 06:32:50 -05:00
|
|
|
trackedQuestKey = key;
|
2022-05-27 14:32:24 -05:00
|
|
|
}
|
|
|
|
|
}
|
2024-02-13 13:24:25 -06:00
|
|
|
|
2024-02-13 14:14:21 -06:00
|
|
|
if (quest.partyOptions.allowParty) {
|
2024-03-03 06:32:50 -05:00
|
|
|
partyQuests.put(key, quest.id);
|
2024-03-05 00:40:48 -05:00
|
|
|
partyOptions.put(key, quest.partyOptions.getPartyOptionsList());
|
2024-02-13 13:24:25 -06:00
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2024-03-15 15:43:29 -04:00
|
|
|
|
|
|
|
|
Party party = playerData.getPlayerParty();
|
|
|
|
|
if(party != null && party.getQuest() != null){
|
|
|
|
|
if (playerData.questData.getTrackedQuest() != null) {
|
|
|
|
|
if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) {
|
|
|
|
|
trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 15:43:29 -04:00
|
|
|
public void setTrackedQuestKey(EntityPlayer player){
|
|
|
|
|
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
|
|
|
|
|
|
|
|
|
Party party = playerData.getPlayerParty();
|
|
|
|
|
if(party != null && party.getQuest() != null){
|
|
|
|
|
if (playerData.questData.getTrackedQuest() != null) {
|
|
|
|
|
if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) {
|
|
|
|
|
trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if(playerData.questData != null && playerData.questData.getTrackedQuest() != null){
|
|
|
|
|
IQuest quest = playerData.questData.getTrackedQuest();
|
|
|
|
|
trackedQuestKey = quest.getCategory().getName() + ":" + quest.getName();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
trackedQuestKey = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public boolean hasSelectedQuest() {
|
|
|
|
|
return !selectedQuest.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getQuestText() {
|
|
|
|
|
return questText.get(selectedCategory + ":" + selectedQuest);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-16 23:37:57 -05:00
|
|
|
public Boolean getQuestAlerts() {
|
|
|
|
|
return Boolean.valueOf(questAlerts.get(selectedCategory+":"+selectedQuest));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void toggleQuestAlerts() {
|
|
|
|
|
questAlerts.put(selectedCategory+":"+selectedQuest,String.valueOf(!getQuestAlerts()));
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public Vector<String> getQuestStatus() {
|
|
|
|
|
return questStatus.get(selectedCategory + ":" + selectedQuest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|