Only partyable quests can be set as party quests.

This commit is contained in:
luisc committed 2024-02-13 13:24:25 -06:00
1 parent 2b292d01f5
commit 5e5e212c9a
4 files changed
+47 -16

No files matched your search

+34 -12
View File
@@ -91,6 +91,28 @@ public class NBTTags {
}
return list;
}
public static HashSet<String> getStringSet(NBTTagList tagList) {
HashSet<String> list = new HashSet<>();
for(int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.add(nbttagcompound.getString("String"));
}
return list;
}
public static NBTTagList nbtStringSet(HashSet<String> collection) {
NBTTagList nbttaglist = new NBTTagList();
if(collection == null)
return nbttaglist;
for (String slot : collection) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("String", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static HashSet<Integer> getIntegerSet(NBTTagList tagList) {
HashSet<Integer> list = new HashSet<Integer>();
@@ -102,6 +124,18 @@ public class NBTTags {
return list;
}
public static NBTTagList nbtIntegerSet(HashSet<Integer> set) {
NBTTagList nbttaglist = new NBTTagList();
if(set == null)
return nbttaglist;
for (int slot : set) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Integer", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static HashMap<String, String> getStringStringMap(NBTTagList tagList) {
HashMap<String, String> list = new HashMap<String, String>();
for(int i = 0; i < tagList.tagCount(); i++)
@@ -304,18 +338,6 @@ public class NBTTags {
return nbttaglist;
}
public static NBTTagList nbtIntegerSet(HashSet<Integer> set) {
NBTTagList nbttaglist = new NBTTagList();
if(set == null)
return nbttaglist;
for (int slot : set) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Integer", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtVectorMap(HashMap<String, Vector<String>> map) {
NBTTagList list = new NBTTagList();
if(map == null)
@@ -193,7 +193,7 @@ public class PacketHandlerServer{
String questName = Server.readString(buffer);
party.setQuest(null);
for (Quest quest : QuestController.Instance.quests.values()) {
if (quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
if (quest.allowParty && quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
party.setQuest(quest);
break;
}
+11 -3
View File
@@ -9,6 +9,7 @@ import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Vector;
public class QuestLogData {
@@ -16,10 +17,11 @@ public class QuestLogData {
public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>();
public String selectedQuest = "";
public String selectedCategory = "";
public HashMap<String,String> questText = new HashMap<String,String>();
public HashMap<String,String> questText = new HashMap<>();
public HashMap<String,String> questAlerts = new HashMap<>();
public HashMap<String,Vector<String>> questStatus = new HashMap<String,Vector<String>>();
public HashMap<String,String> finish = new HashMap<String,String>();
public HashMap<String,Vector<String>> questStatus = new HashMap<>();
public HashMap<String,String> finish = new HashMap<>();
public HashSet<String> partyAbleQuests = new HashSet<>();
public NBTTagCompound writeNBT(){
NBTTagCompound compound = new NBTTagCompound();
@@ -29,6 +31,7 @@ public class QuestLogData {
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
compound.setString("TrackedQuestID", trackedQuestKey);
compound.setTag("PartyQuests", NBTTags.nbtStringSet(partyAbleQuests));
return compound;
}
@@ -39,6 +42,7 @@ public class QuestLogData {
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
trackedQuestKey = compound.getString("TrackedQuestID");
partyAbleQuests = NBTTags.getStringSet(compound.getTagList("PartyQuests", 10));
}
public void setData(EntityPlayer player){
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
@@ -62,6 +66,10 @@ public class QuestLogData {
trackedQuestKey = category + ":" + quest.title;
}
}
if (quest.allowParty) {
partyAbleQuests.add(category + ":" + quest.title);
}
}
}
@@ -88,6 +88,7 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
addButton(new GuiButtonNextPage(2, guiLeft + 144, guiTop + 176, false));
if (ClientCacheHandler.party != null && data.hasSelectedQuest()
&& data.partyAbleQuests.contains(data.selectedCategory + ":" + data.selectedQuest)
&& ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName())) {
String questName = ClientCacheHandler.party.getCurrentQuestName();
GuiNpcButton partyButton = new GuiNpcButton(3, guiLeft + 150, guiTop + 151, 50, 20, new String[]{"party.party", "party.partying"}, Objects.equals(questName, data.selectedQuest) ? 1 : 0);