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

148 lines
5.9 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 {
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 = "";
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<>();
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));
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));
compound.setString("TrackedQuestID", trackedQuestKey);
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));
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));
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));
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);
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
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);
2024-03-05 00:40:48 -05:00
partyOptions.put(key, quest.partyOptions.getPartyOptionsList());
}
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);
}
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
}