Added functionality to the disband party button

This commit is contained in:
luisc committed 2024-01-11 18:24:33 -06:00
1 parent ae43f0548d
commit cdd3f22826
5 files changed
+35 -3

No files matched your search

@@ -131,6 +131,15 @@ public class PacketHandlerServer{
}
}
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if (type == EnumPacketServer.DisbandParty) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
if (playerData.partyUUID != null) {
PartyController.Instance().disbandParty(playerData.partyUUID);
}
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("Disband", true);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
if(type.needsNpc && npc == null){
@@ -16,6 +16,7 @@ import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
import java.util.UUID;
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData {
@@ -78,6 +79,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
playerScroll.setSize(150, 160);
playerScroll.guiLeft = guiLeft + 5;
playerScroll.guiTop = guiTop + 5;
playerScroll.setList(new ArrayList<>(party.getPlayerNames()));
this.addScroll(playerScroll);
//set leader button
@@ -126,6 +128,10 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
Client.sendData(EnumPacketServer.CreateParty);
receivedData = false;
break;
case 335:
Client.sendData(EnumPacketServer.DisbandParty);
receivedData = false;
break;
}
initGui();
if (guibutton.id == 100 && activeTab != 0) {
@@ -193,6 +199,8 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
party = ClientCacheHandler.party;
}
party.readFromNBT(compound);
} else if (compound.hasKey("Disband")) {
ClientCacheHandler.party = null;
}
initGui();
@@ -95,7 +95,7 @@ public enum EnumPacketServer {
CustomGuiButton,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused,
CreateParty, GetPartyData,
CreateParty, GetPartyData, DisbandParty,
ServerUpdateSkinOverlays;
@@ -1,6 +1,9 @@
package noppes.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
import java.util.HashMap;
import java.util.UUID;
@@ -30,7 +33,15 @@ public class PartyController {
return this.parties.get(partyUUID);
}
public void deleteParty(UUID partyUUID) {
this.parties.remove(partyUUID);
public void disbandParty(UUID partyUUID) {
Party party = this.parties.get(partyUUID);
if (party != null) {
for (UUID uuid: party.getPlayerUUIDs()) {
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
playerData.partyUUID = null;
}
this.parties.remove(partyUUID);
}
}
}
@@ -152,6 +152,10 @@ public class Party {
return this.partyMembers.values();
}
public Collection<UUID> getPlayerUUIDs() {
return this.partyMembers.keySet();
}
// To Be Called DURING Invite, Leave, Quest Switch, Leader Switch, etc.
public static boolean validateQuest(int questID, Collection<EntityPlayer> players){
IQuest quest = QuestController.Instance.get(questID);