This commit is contained in:
Kam committed 2024-02-13 14:32:34 -05:00
commit 88a7164f46
7 files changed
+128 -35

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)
@@ -181,6 +181,25 @@ public class PacketHandlerServer{
UUID uuid = UUID.fromString(uuidString);
playerData.ignoreInvite(uuid);
}
} else if (type == EnumPacketServer.SetPartyQuest) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
Party party = PartyController.Instance().getParty(playerData.partyUUID);
if (party != null) {
if (party.getPartyLeader() != player) {
return;
}
String questCategory = Server.readString(buffer);
String questName = Server.readString(buffer);
party.setQuest(null);
for (Quest quest : QuestController.Instance.quests.values()) {
if (quest.allowParty && quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
party.setQuest(quest);
break;
}
}
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
}
}
if(type.needsNpc && npc == null){
+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);
}
}
}
@@ -9,13 +9,11 @@ import net.minecraft.util.StatCollector;
import noppes.npcs.NBTTags;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.QuestLogData;
import noppes.npcs.client.Client;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.TextBlockClient;
import noppes.npcs.client.*;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.util.ValueUtil;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
@@ -89,19 +87,30 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
addButton(new GuiButtonNextPage(1, guiLeft + 286, guiTop + 176, true));
addButton(new GuiButtonNextPage(2, guiLeft + 144, guiTop + 176, false));
GuiNpcButton trackingButton = new GuiNpcButton(3, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"quest.track", "quest.tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0);
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);
if (Objects.equals(questName, data.selectedQuest)) {
partyButton.packedFGColour = 0x32CD32;
}
addButton(partyButton);
}
GuiNpcButton trackingButton = new GuiNpcButton(4, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"quest.track", "quest.tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0);
if (trackingButton.displayString.equals("quest.tracking")) {
trackingButton.packedFGColour = 0x32CD32;
}
addButton(trackingButton);
GuiNpcButton alertButton = new GuiNpcButton(4, guiLeft + 205, guiTop + 151, 50, 20, new String[]{"quest.alerts", "quest.noAlerts"}, data.getQuestAlerts() ? 0 : 1);
GuiNpcButton alertButton = new GuiNpcButton(5, guiLeft + 205, guiTop + 151, 50, 20, new String[]{"quest.alerts", "quest.noAlerts"}, data.getQuestAlerts() ? 0 : 1);
addButton(alertButton);
getButton(1).visible = questDetails && data.hasSelectedQuest();
getButton(2).visible = !questDetails && data.hasSelectedQuest();
getButton(3).visible = !data.selectedQuest.isEmpty() && getButton(1).visible;
getButton(4).visible = getButton(3).visible;
getButton(4).visible = !data.selectedQuest.isEmpty() && getButton(1).visible;
getButton(5).visible = getButton(4).visible;
}
@Override
protected void actionPerformed(GuiButton guibutton){
@@ -111,14 +120,22 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
if(guibutton.id == 2){
questDetails = true;
}
if(guibutton.id == 3){
if (guibutton.id == 3)
{
if (Objects.equals(ClientCacheHandler.party.getCurrentQuestName(), data.selectedQuest)) {
Client.sendData(EnumPacketServer.SetPartyQuest, "", "");
} else {
Client.sendData(EnumPacketServer.SetPartyQuest, data.selectedCategory, data.selectedQuest);
}
}
if(guibutton.id == 4){
if (!data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest)) {
data.trackedQuestKey = data.selectedCategory + ":" + data.selectedQuest;
} else {
data.trackedQuestKey = "";
}
}
if(guibutton.id == 4){
if(guibutton.id == 5){
data.toggleQuestAlerts();
}
initGui();
@@ -270,11 +287,17 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
}
@Override
public void setGuiData(NBTTagCompound compound) {
QuestLogData data = new QuestLogData();
data.readNBT(compound);
this.data = data;
this.questAlertsOnOpen = new HashMap<>(data.questAlerts);
this.trackedQuestKeyOnOpen = data.trackedQuestKey;
if (compound.hasKey("PartyUUID")) {
UUID uuid = UUID.fromString(compound.getString("PartyUUID"));
ClientCacheHandler.party = new Party(uuid);
ClientCacheHandler.party.readFromNBT(compound);
} else {
QuestLogData data = new QuestLogData();
data.readNBT(compound);
this.data = data;
this.questAlertsOnOpen = new HashMap<>(data.questAlerts);
this.trackedQuestKeyOnOpen = data.trackedQuestKey;
}
initGui();
}
@@ -97,7 +97,8 @@ public enum EnumPacketServer {
CustomGuiButton,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused,
SavePartyData, CreateParty, GetPartyData, DisbandParty, KickPlayer, PartyInvite, GetPartyInviteList, AcceptInvite, IgnoreInvite, SetPartyLeader,
SavePartyData, CreateParty, GetPartyData, DisbandParty, KickPlayer, PartyInvite, GetPartyInviteList, AcceptInvite,
IgnoreInvite, SetPartyLeader, SetPartyQuest,
ServerUpdateSkinOverlays;
@@ -28,6 +28,8 @@ public class Party {
private final ArrayList<UUID> partyOrder = new ArrayList<>();
private int currentQuestID = -1;
private String currentQuestName = "";
private boolean friendlyFire;
private boolean partyLocked = false;
@@ -50,16 +52,28 @@ public class Party {
return this.partyLocked;
}
public void setIsLocked(boolean val) {
this.partyLocked = val;
public void setQuest(IQuest quest) {
if (quest != null) {
this.currentQuestID = quest.getId();
this.currentQuestName = quest.getName();
} else {
this.currentQuestID = -1;
this.currentQuestName = "";
}
this.partyLocked = quest != null;
}
public IQuest getQuest() {
return QuestController.Instance.get(this.currentQuestID);
}
public int getCurrentQuestID() {
return currentQuestID;
}
public void setCurrentQuestID(int currentQuestID) {
this.currentQuestID = currentQuestID;
public String getCurrentQuestName() {
return this.currentQuestName;
}
public boolean addPlayer(EntityPlayer player) {
@@ -279,6 +293,7 @@ public class Party {
public void readFromNBT(NBTTagCompound compound) {
this.partyLeaderName = compound.getString("PartyLeader");
this.currentQuestID = compound.getInteger("PartyQuestID");
this.currentQuestName = compound.getString("PartyQuestName");
this.friendlyFire = compound.getBoolean("FriendlyFire");
this.partyLocked = compound.getBoolean("PartyLocked");
@@ -297,6 +312,7 @@ public class Party {
compound.setString("PartyUUID", this.partyUUID.toString());
compound.setInteger("PartyQuestID", this.currentQuestID);
compound.setString("PartyQuestName", this.currentQuestName);
compound.setBoolean("FriendlyFire", this.friendlyFire);
compound.setBoolean("PartyLocked", this.partyLocked);
@@ -321,12 +337,14 @@ public class Party {
public void readClientNBT(NBTTagCompound compound) {
this.currentQuestID = compound.getInteger("PartyQuestID");
this.currentQuestName = compound.getString("PartyQuestName");
this.friendlyFire = compound.getBoolean("FriendlyFire");
}
public NBTTagCompound writeClientNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("PartyQuestID", this.currentQuestID);
compound.setString("PartyQuestName", this.currentQuestName);
compound.setBoolean("FriendlyFire", this.friendlyFire);
return compound;
}