From 64d8d00fad8d63c8a08c8c83de976ede6826015e Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 4 Mar 2024 05:15:50 -0500 Subject: [PATCH] Min/Max Party Size, Execute Command for, Lang Updates --- src/api | 2 +- .../java/noppes/npcs/NoppesUtilPlayer.java | 19 +++-- .../client/gui/SubGuiNpcPartyOptions.java | 85 +++++++++++++------ .../java/noppes/npcs/config/ConfigMain.java | 11 ++- .../noppes/npcs/controllers/data/Party.java | 5 ++ .../npcs/controllers/data/PartyOptions.java | 77 ++++++++++++++++- .../assets/customnpcs/lang/en_US.lang | 11 +-- 7 files changed, 169 insertions(+), 41 deletions(-) diff --git a/src/api b/src/api index fa75b6cdc..4e763f7d8 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit fa75b6cdc98df506caba287526d861fc2522babf +Subproject commit 4e763f7d8deb56ada24287e8366c65904c9aad3f diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index 0269fbcb8..3e3388801 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -471,6 +471,7 @@ public class NoppesUtilPlayer { PartyOptions partyOptions = quest.partyOptions; EnumPartyExchange complete = partyOptions.completeFor; EnumPartyExchange reward = partyOptions.rewardControl; + EnumPartyExchange command = partyOptions.executeCommand; for(String name : party.getPlayerNames()){ EntityPlayer player = NoppesUtilServer.getPlayerByName(name); if(player == null) @@ -487,6 +488,7 @@ public class NoppesUtilPlayer { boolean meetsComplete = meetsPartyExchange(complete, hasActiveQuest, hasFinishedQuest, isLeader); boolean meetsReward = meetsPartyExchange(reward, hasActiveQuest, hasFinishedQuest, isLeader); + boolean meetsCommand = meetsPartyExchange(command, hasActiveQuest, hasFinishedQuest, isLeader); if(meetsComplete){ if (data.quest.completion == EnumQuestCompletion.Instant) { @@ -547,19 +549,22 @@ public class NoppesUtilPlayer { } } - if(meetsComplete){ + if(meetsCommand){ if(!data.quest.command.isEmpty()){ NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command); } - PlayerQuestController.setQuestPartyFinished(data.quest, player, data); } - if (data.quest.hasNewQuest()) { - QuestData nextQuest = new QuestData(data.quest.getNextQuest()); - nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts; - PlayerQuestController.addActiveQuest(nextQuest, player); - // questData.trackQuest(nextQuest.quest); + if(meetsComplete){ + PlayerQuestController.setQuestPartyFinished(data.quest, player, data); + if (data.quest.hasNewQuest()) { + QuestData nextQuest = new QuestData(data.quest.getNextQuest()); + nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts; + PlayerQuestController.addActiveQuest(nextQuest, player); + // questData.trackQuest(nextQuest.quest); + } } + playerData.save(); if(meetsComplete){ diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java index 0604b6c62..f1d2f2101 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java @@ -24,42 +24,68 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield { super.initGui(); + int y = 0; //Allow party - T/F button - addButton(new GuiNpcButton(0, guiLeft + 130, guiTop + 10, 60, 20, + addButton(new GuiNpcButton(0, guiLeft + 130, guiTop + 10 + y, 60, 20, new String[]{"gui.no", "gui.yes"}, options.allowParty ? 1 : 0)); - addLabel(new GuiNpcLabel(1, "party.allowParty", guiLeft + 10, guiTop + 17)); + addLabel(new GuiNpcLabel(1, "party.allowParty", guiLeft + 10, guiTop + 17 + y)); if (options.allowParty) { + y += 23; + //Only party - enum button + addButton(new GuiNpcButton(24, guiLeft + 130, guiTop + 10 + y, 60, 20, + new String[]{"gui.no", "gui.yes"}, options.onlyParty ? 1 : 0)); + addLabel(new GuiNpcLabel(24, "party.only", guiLeft + 10, guiTop + 17 + y)); + + y += 23; //Party requirements - enum button - addButton(new GuiNpcButton(5, guiLeft + 130, guiTop + 35, 60, 20, + addButton(new GuiNpcButton(5, guiLeft + 130, guiTop + 10 + y, 60, 20, EnumPartyRequirements.values(), options.partyRequirements.ordinal())); - addLabel(new GuiNpcLabel(6, "party.partyRequirements", guiLeft + 10, guiTop + 42)); - - //Party rewards - enum button - addButton(new GuiNpcButton(10, guiLeft + 130, guiTop + 60, 60, 20, - EnumPartyExchange.values(), options.rewardControl.ordinal())); - addLabel(new GuiNpcLabel(11, "party.partyRewards", guiLeft + 10, guiTop + 67)); - - //Complete for - enum button - addButton(new GuiNpcButton(15, guiLeft + 130, guiTop + 85, 60, 20, - EnumPartyExchange.values(), options.completeFor.ordinal())); - addLabel(new GuiNpcLabel(16, "party.completeFor", guiLeft + 10, guiTop + 92)); + addLabel(new GuiNpcLabel(6, "party.partyRequirements", guiLeft + 10, guiTop + 17 + y)); + y += 23; //Objective Requirement - enum button - addButton(new GuiNpcButton(18, guiLeft + 130, guiTop + 110, 60, 20, + addButton(new GuiNpcButton(18, guiLeft + 130, guiTop + 10 + y, 60, 20, EnumPartyObjectives.values(), options.objectiveRequirement.ordinal())); - addLabel(new GuiNpcLabel(19, "party.objectiveRequirement", guiLeft + 10, guiTop + 117)); + addLabel(new GuiNpcLabel(19, "quest.objectives", guiLeft + 10, guiTop + 17 + y)); + + y += 23; + //Party rewards - enum button + addButton(new GuiNpcButton(10, guiLeft + 130, guiTop + 10 + y, 60, 20, + EnumPartyExchange.values(), options.rewardControl.ordinal())); + addLabel(new GuiNpcLabel(11, "quest.reward", guiLeft + 10, guiTop + 17 + y)); + + y += 23; + //Complete for - enum button + addButton(new GuiNpcButton(15, guiLeft + 130, guiTop + 10 + y, 60, 20, + EnumPartyExchange.values(), options.completeFor.ordinal())); + addLabel(new GuiNpcLabel(16, "party.completeFor", guiLeft + 10, guiTop + 17 + y)); + + y += 23; + //Commmand for - enum button + addButton(new GuiNpcButton(25, guiLeft + 130, guiTop + 10 + y, 60, 20, + EnumPartyExchange.values(), options.executeCommand.ordinal())); + addLabel(new GuiNpcLabel(25, "party.commandFor", guiLeft + 10, guiTop + 17 + y)); + + y += 23; + //min party size - number field + GuiNpcTextField minField = new GuiNpcTextField(21, this, guiLeft + 60, guiTop + 10 + y, + 30, 20, String.valueOf(options.minPartySize)); + minField.integersOnly = true; + minField.setMinMaxDefault(1, Integer.MAX_VALUE, 1); + addTextField(minField); + addLabel(new GuiNpcLabel(21, "party.minPartySize", guiLeft + 10, guiTop + 17 + y)); //max party size - number field - GuiNpcTextField textField = new GuiNpcTextField(20, this, guiLeft + 130, guiTop + 135, - 40, 20, String.valueOf(options.maxPartySize)); - textField.integersOnly = true; - textField.setMinMaxDefault(1, Integer.MAX_VALUE, 4); - addTextField(textField); - addLabel(new GuiNpcLabel(20, "party.maxPartySize", guiLeft + 10, guiTop + 142)); + GuiNpcTextField maxField = new GuiNpcTextField(20, this, guiLeft + 160, guiTop + 10 + y, + 30, 20, String.valueOf(options.maxPartySize)); + maxField.integersOnly = true; + maxField.setMinMaxDefault(1, Integer.MAX_VALUE, 4); + addTextField(maxField); + addLabel(new GuiNpcLabel(20, "party.maxPartySize", guiLeft + 110, guiTop + 17 + y)); } - addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 200, guiTop + 192, 50, 20, "gui.done")); } protected void actionPerformed(GuiButton guibutton) @@ -81,6 +107,12 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield case 18: options.objectiveRequirement = EnumPartyObjectives.valueOf(guibutton.displayString); break; + case 24: + options.onlyParty = !options.onlyParty; + break; + case 25: + options.executeCommand = EnumPartyExchange.valueOf(guibutton.displayString); + break; case 66: close(); break; @@ -91,7 +123,12 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield @Override public void unFocused(GuiNpcTextField textfield) { if (textfield.id == 20) { - options.maxPartySize = textfield.getInteger(); + options.setMaxPartySize(textfield.getInteger()); + initGui(); + } + if (textfield.id == 21) { + options.setMinPartySize(textfield.getInteger()); + initGui(); } } } diff --git a/src/main/java/noppes/npcs/config/ConfigMain.java b/src/main/java/noppes/npcs/config/ConfigMain.java index f7e10f428..31b809340 100644 --- a/src/main/java/noppes/npcs/config/ConfigMain.java +++ b/src/main/java/noppes/npcs/config/ConfigMain.java @@ -66,8 +66,10 @@ public class ConfigMain public static Property MarketDatFormatProperty; public static boolean MarketDatFormat = false; + public static Property DefaultMinPartySizeProperty; + public static int DefaultMinPartySize = 1; - public static Property DefaultMaxPartySizetProperty; + public static Property DefaultMaxPartySizeProperty; public static int DefaultMaxPartySize = 4; /** @@ -159,8 +161,11 @@ public class ConfigMain MarketDatFormatProperty = config.get(GENERAL, "Dat Format for Market", false, "You need to use '/kamkeel config market' to convert existing market to new format."); MarketDatFormat = MarketDatFormatProperty.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); + DefaultMinPartySizeProperty = config.get(GENERAL, "Default Min Party Size", 1, "When creating a new Quest sets the default min party size"); + DefaultMinPartySize = DefaultMinPartySizeProperty.getInt(4); + + DefaultMaxPartySizeProperty = config.get(GENERAL, "Default Max Party Size", 4, "When creating a new Quest sets the default max party size"); + DefaultMaxPartySize = DefaultMaxPartySizeProperty.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."); diff --git a/src/main/java/noppes/npcs/controllers/data/Party.java b/src/main/java/noppes/npcs/controllers/data/Party.java index c5786ecb8..70fc5bae0 100644 --- a/src/main/java/noppes/npcs/controllers/data/Party.java +++ b/src/main/java/noppes/npcs/controllers/data/Party.java @@ -230,6 +230,11 @@ public class Party { return false; } + if (partyMembers.size() < quest.getPartyOptions().getMinPartySize()) { + sendInfoMessage(leader, String.format("Party too small. Min %d members", quest.getPartyOptions().getMaxPartySize())); + return false; + } + if (partyMembers.size() > quest.getPartyOptions().getMaxPartySize()) { sendInfoMessage(leader, String.format("Party too large. Max %d members", quest.getPartyOptions().getMaxPartySize())); return false; diff --git a/src/main/java/noppes/npcs/controllers/data/PartyOptions.java b/src/main/java/noppes/npcs/controllers/data/PartyOptions.java index b8befa04f..3afcd0f1f 100644 --- a/src/main/java/noppes/npcs/controllers/data/PartyOptions.java +++ b/src/main/java/noppes/npcs/controllers/data/PartyOptions.java @@ -9,13 +9,17 @@ import noppes.npcs.constants.EnumPartyRequirements; public class PartyOptions implements IPartyOptions { public boolean allowParty = false; + public boolean onlyParty = false; public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader; public EnumPartyExchange rewardControl = EnumPartyExchange.Leader; public EnumPartyExchange completeFor = EnumPartyExchange.Leader; + public EnumPartyExchange executeCommand = EnumPartyExchange.Leader; public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared; + + public int minPartySize = ConfigMain.DefaultMinPartySize; public int maxPartySize = ConfigMain.DefaultMaxPartySize; public void readFromNBT(NBTTagCompound compound) @@ -23,13 +27,19 @@ public class PartyOptions implements IPartyOptions { // Party Management allowParty = compound.getBoolean("AllowParty"); if(allowParty){ + onlyParty = compound.getBoolean("OnlyParty"); partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")]; rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")]; completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")]; + executeCommand = EnumPartyExchange.values()[compound.getInteger("ExecuteCommand")]; + minPartySize = compound.getInteger("MinPartySize"); maxPartySize = compound.getInteger("MaxPartySize"); objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")]; } else { + if(compound.hasKey("OnlyParty")){ + compound.removeTag("OnlyParty"); + } if(compound.hasKey("PartyRequirements")){ compound.removeTag("PartyRequirements"); } @@ -39,6 +49,12 @@ public class PartyOptions implements IPartyOptions { if(compound.hasKey("CompleteFor")){ compound.removeTag("CompleteFor"); } + if(compound.hasKey("ExecuteCommand")){ + compound.removeTag("ExecuteCommand"); + } + if(compound.hasKey("MinPartySize")){ + compound.removeTag("MinPartySize"); + } if(compound.hasKey("MaxPartySize")){ compound.removeTag("MaxPartySize"); } @@ -46,9 +62,12 @@ public class PartyOptions implements IPartyOptions { compound.removeTag("ObjectiveRequirement"); } + onlyParty = false; partyRequirements = EnumPartyRequirements.Leader; rewardControl = EnumPartyExchange.Leader; completeFor = EnumPartyExchange.Leader; + executeCommand = EnumPartyExchange.Leader; + minPartySize = ConfigMain.DefaultMinPartySize; maxPartySize = ConfigMain.DefaultMaxPartySize; objectiveRequirement = EnumPartyObjectives.Shared; } @@ -58,13 +77,19 @@ public class PartyOptions implements IPartyOptions { NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("AllowParty", allowParty); if(allowParty){ + compound.setBoolean("OnlyParty", onlyParty); compound.setInteger("PartyRequirements", partyRequirements.ordinal()); compound.setInteger("RewardControl", rewardControl.ordinal()); compound.setInteger("CompleteFor", completeFor.ordinal()); + compound.setInteger("ExecuteCommand", executeCommand.ordinal()); + compound.setInteger("MinPartySize", minPartySize); compound.setInteger("MaxPartySize", maxPartySize); compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal()); } else { + if(compound.hasKey("OnlyParty")){ + compound.removeTag("OnlyParty"); + } if(compound.hasKey("PartyRequirements")){ compound.removeTag("PartyRequirements"); } @@ -74,6 +99,12 @@ public class PartyOptions implements IPartyOptions { if(compound.hasKey("CompleteFor")){ compound.removeTag("CompleteFor"); } + if(compound.hasKey("ExecuteCommand")){ + compound.removeTag("ExecuteCommand"); + } + if(compound.hasKey("MinPartySize")){ + compound.removeTag("MinPartySize"); + } if(compound.hasKey("MaxPartySize")){ compound.removeTag("MaxPartySize"); } @@ -95,6 +126,16 @@ public class PartyOptions implements IPartyOptions { this.allowParty = allowParty; } + @Override + public boolean isOnlyParty() { + return onlyParty; + } + + @Override + public void setOnlyParty(boolean onlyParty) { + this.onlyParty = onlyParty; + } + @Override public int getPartyRequirements() { return partyRequirements.ordinal(); @@ -134,10 +175,25 @@ public class PartyOptions implements IPartyOptions { this.completeFor = EnumPartyExchange.values()[compFor]; } + @Override + public int getExecuteCommandFor() { + return executeCommand.ordinal(); + } + + @Override + public void setExecuteCommandFor(int commandFor) { + if (commandFor < 0 || commandFor >= EnumPartyExchange.values().length) { + return; + } + this.executeCommand = EnumPartyExchange.values()[commandFor]; + } + + @Override public int getObjectiveRequirement() { return objectiveRequirement.ordinal(); } + @Override public void setObjectiveRequirement(int requirement) { if (requirement < 0 || requirement >= EnumPartyObjectives.values().length) { return; @@ -145,13 +201,32 @@ public class PartyOptions implements IPartyOptions { this.objectiveRequirement = EnumPartyObjectives.values()[requirement]; } - @Override + @Override + public int getMinPartySize() { + return minPartySize; + } + + @Override + public void setMinPartySize(int newSize) { + if(newSize < 1) + newSize = 1; + + if(newSize > maxPartySize) + newSize = maxPartySize; + + minPartySize = newSize; + } + + @Override public int getMaxPartySize() { return maxPartySize; } @Override public void setMaxPartySize(int newSize) { + if(newSize < minPartySize) + newSize = minPartySize; + maxPartySize = newSize; } } diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 79e7eb0c2..b54334921 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -135,8 +135,6 @@ gui.on=On party.accept=Accept party.allowParty=Allow Partying -party.completeFor=Complete For -party.objectiveRequirement=Objective Requirement party.createParty=Create Party party.disbandParty=Disband Party party.disbandConfirm=Are you sure you want to disband the party? @@ -167,13 +165,16 @@ party.disbandAlert=Party Disbanded party.disbandMessage=The party has been disbanded party.setLeader=Set Leader party.track=Track Quest -party.maxPartySize=Max Party Size +party.only=Only Party +party.minPartySize=Min Size +party.maxPartySize=Max Size party.options=Party Options +party.completeFor=Complete for +party.commandFor=Execute Command for party.party=Party party.partying=Partying! party.messageNoParty=You're not in a party! Either wait for an invite or create one. -party.partyRequirements=Party Requirements -party.partyRewards=Party Rewards +party.partyRequirements=Required by party.setQuestConfirm=Setting a Quest to a party will clear its progress! party.dropQuestConfirm=Are you sure you want to drop the party quest?`