package noppes.npcs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.Quest; import java.util.HashMap; import java.util.Vector; public class QuestLogData { public String trackedQuestKey = ""; public HashMap> categories = new HashMap>(); public String selectedQuest = ""; public String selectedCategory = ""; public HashMap questText = new HashMap<>(); public HashMap questAlerts = new HashMap<>(); public HashMap> questStatus = new HashMap<>(); public HashMap finish = new HashMap<>(); public HashMap partyQuests = new HashMap<>(); public HashMap> 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)); compound.setTag("PartyOptions", NBTTags.nbtVectorMap(partyOptions)); 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)); partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10)); } public NBTTagCompound writeTrackedQuest() { NBTTagCompound compound = new NBTTagCompound(); compound.setString("TrackedQuestID", trackedQuestKey); return compound; } public void readTrackedQuest(NBTTagCompound compound) { trackedQuestKey = compound.getString("TrackedQuestID"); } public void setData(EntityPlayer player) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); for (Quest quest : PlayerQuestController.getActiveQuests(player)) { String category = quest.category.title; if (!categories.containsKey(category)) categories.put(category, new Vector()); Vector list = categories.get(category); list.add(quest.title); 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)); 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); partyOptions.put(key, quest.partyOptions.getPartyOptionsList()); } } 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(); } } } } 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 = ""; } } public boolean hasSelectedQuest() { return !selectedQuest.isEmpty(); } public String getQuestText() { return questText.get(selectedCategory + ":" + selectedQuest); } public Boolean getQuestAlerts() { return Boolean.valueOf(questAlerts.get(selectedCategory + ":" + selectedQuest)); } public void toggleQuestAlerts() { questAlerts.put(selectedCategory + ":" + selectedQuest, String.valueOf(!getQuestAlerts())); } public Vector getQuestStatus() { return questStatus.get(selectedCategory + ":" + selectedQuest); } public String getComplete() { return finish.get(selectedCategory + ":" + selectedQuest); } public Vector getPartyOptions() { return partyOptions.get(selectedCategory + ":" + selectedQuest); } }