From ae1bd4ba38f8de1a7b889d23bdd85eaaccc35658 Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 1 Nov 2023 00:06:41 -0400 Subject: [PATCH] Max Party Size Config | for Quests | Read / Write NBTs --- src/api | 2 +- .../java/noppes/npcs/config/ConfigMain.java | 6 +++ .../noppes/npcs/controllers/data/Quest.java | 54 ++++++++++++++++++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/api b/src/api index fbc7ae91e..9a4fed3fd 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit fbc7ae91e7f8ff01e764d3a2750ac8169283ea2b +Subproject commit 9a4fed3fd551fd7ae47fd7405aa4bb0f03b4ac33 diff --git a/src/main/java/noppes/npcs/config/ConfigMain.java b/src/main/java/noppes/npcs/config/ConfigMain.java index a6230f45e..fc6efcf8d 100644 --- a/src/main/java/noppes/npcs/config/ConfigMain.java +++ b/src/main/java/noppes/npcs/config/ConfigMain.java @@ -63,6 +63,9 @@ public class ConfigMain public static Property DatFormatProperty; public static boolean DatFormat = false; + public static Property DefaultMaxPartySizetProperty; + public static int DefaultMaxPartySize = 4; + /** * General NPC Properties **/ @@ -149,6 +152,9 @@ public class ConfigMain DatFormatProperty = config.get(GENERAL, "Dat Format for PlayerData", false, "You need to use '/kamkeel config playerdata' to convert existing playerdata to new format."); DatFormat = DatFormatProperty.getBoolean(false); + DefaultMaxPartySizetProperty = config.get(GENERAL, "Default Max Party Size", 4, "When creating a new Quest sets the default max party size"); + DefaultMaxPartySize = DefaultMaxPartySizetProperty.getInt(4); + // NPC NpcNavRangeProperty = config.get(NPC, "NPC Navigation Range", 32, "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96."); NpcNavRange = NpcNavRangeProperty.getInt(32); diff --git a/src/main/java/noppes/npcs/controllers/data/Quest.java b/src/main/java/noppes/npcs/controllers/data/Quest.java index f277a6221..56fda6d7c 100644 --- a/src/main/java/noppes/npcs/controllers/data/Quest.java +++ b/src/main/java/noppes/npcs/controllers/data/Quest.java @@ -10,6 +10,7 @@ import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.api.handler.data.IQuestCategory; import noppes.npcs.api.handler.data.IQuestInterface; import noppes.npcs.api.handler.data.IQuestObjective; +import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestRepeat; @@ -39,6 +40,7 @@ public class Quest implements ICompatibilty, IQuest { public boolean allowParty = false; public byte partyRequirements = 0; // 0 - Only Party Leaders, 1 - Everyone public byte rewardControl = 0; // 0 - Only Party Leaders, 1 - Everyone + public int maxPartySize = 4; public QuestInterface questInterface = new QuestItem(); @@ -80,6 +82,29 @@ public class Quest implements ICompatibilty, IQuest { factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints")); mail.readNBT(compound.getCompoundTag("QuestMail")); + + // Party Management + allowParty = compound.getBoolean("AllowParty"); + if(allowParty){ + partyRequirements = compound.getByte("PartyRequirements"); + rewardControl = compound.getByte("RewardControl"); + maxPartySize = compound.getInteger("MaxPartySize"); + } + else { + if(compound.hasKey("PartyRequirements")){ + compound.removeTag("PartyRequirements"); + } + if(compound.hasKey("RewardControl")){ + compound.removeTag("RewardControl"); + } + if(compound.hasKey("MaxPartySize")){ + compound.removeTag("MaxPartySize"); + } + + partyRequirements = 0; + rewardControl = 0; + maxPartySize = ConfigMain.DefaultMaxPartySize; + } } public void setType(EnumQuestType questType) { @@ -121,7 +146,24 @@ public class Quest implements ICompatibilty, IQuest { this.questInterface.writeEntityToNBT(compound); compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound())); compound.setTag("QuestMail", mail.writeNBT()); - + + compound.setBoolean("AllowParty", allowParty); + if(allowParty){ + compound.setByte("PartyRequirements", partyRequirements); + compound.setByte("RewardControl", rewardControl); + compound.setInteger("MaxPartySize", maxPartySize); + } + else { + if(compound.hasKey("PartyRequirements")){ + compound.removeTag("PartyRequirements"); + } + if(compound.hasKey("RewardControl")){ + compound.removeTag("RewardControl"); + } + if(compound.hasKey("MaxPartySize")){ + compound.removeTag("MaxPartySize"); + } + } return compound; } @@ -301,4 +343,14 @@ public class Quest implements ICompatibilty, IQuest { public void setRewardControl(byte rewardControl) { this.rewardControl = rewardControl; } + + @Override + public int getMaxPartySize() { + return maxPartySize; + } + + @Override + public void setMaxPartySize(int newSize) { + maxPartySize = newSize; + } }