From cad906965aef5c99641a0d244b84c75d9677b1a4 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Fri, 13 Sep 2019 11:13:01 -0400 Subject: [PATCH] Add option for fellow party members to receive progress outside quest --- .../java/me/blackvein/quests/Options.java | 9 + .../main/java/me/blackvein/quests/Quest.java | 4 +- .../me/blackvein/quests/QuestFactory.java | 6 + .../java/me/blackvein/quests/Quester.java | 73 ++++-- .../main/java/me/blackvein/quests/Quests.java | 3 + .../quests/listeners/PlayerListener.java | 235 +++++++++--------- .../quests/prompts/OptionsPrompt.java | 18 +- .../java/me/blackvein/quests/util/CK.java | 1 + main/src/main/resources/strings.yml | 1 + 9 files changed, 214 insertions(+), 136 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Options.java b/main/src/main/java/me/blackvein/quests/Options.java index f559231c7..2f3dd8158 100644 --- a/main/src/main/java/me/blackvein/quests/Options.java +++ b/main/src/main/java/me/blackvein/quests/Options.java @@ -18,6 +18,7 @@ public class Options { private boolean useDungeonsXLPlugin = false; private boolean usePartiesPlugin = true; private int shareProgressLevel = 1; + private boolean requireSameQuest = true; public boolean getAllowCommands() { return allowCommands; @@ -58,4 +59,12 @@ public class Options { public void setShareProgressLevel(int shareProgressLevel) { this.shareProgressLevel = shareProgressLevel; } + + public boolean getRequireSameQuest() { + return requireSameQuest; + } + + public void setRequireSameQuest(boolean requireSameQuest) { + this.requireSameQuest = requireSameQuest; + } } \ No newline at end of file diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java index 1a0a3f926..b88d4f9d8 100644 --- a/main/src/main/java/me/blackvein/quests/Quest.java +++ b/main/src/main/java/me/blackvein/quests/Quest.java @@ -208,7 +208,7 @@ public class Quest { // Multiplayer if (opts.getShareProgressLevel() == 3) { - List mq = quester.getMultiplayerQuestersByQuest(this); + List mq = quester.getMultiplayerQuesters(this); for (Quester qq : mq) { if (currentStage.equals(qq.getCurrentStage(this))) { nextStage(qq, allowSharedProgress); @@ -694,7 +694,7 @@ public class Quest { // Multiplayer if (opts.getShareProgressLevel() == 4) { - List mq = q.getMultiplayerQuestersByQuest(this); + List mq = q.getMultiplayerQuesters(this); for (Quester qq : mq) { completeQuest(qq); } diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index eea29a726..eb1a20034 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -999,6 +999,7 @@ public class QuestFactory implements ConversationAbandonedListener { boolean useDungeonsXLPluginOpt = false; boolean usePartiesPluginOpt = true; Integer shareProgressLevelOpt = 1; + boolean requireSameQuestOpt = true; if (cc.getSessionData(CK.Q_START_NPC) != null) { npcStart = (Integer) cc.getSessionData(CK.Q_START_NPC); } @@ -1129,6 +1130,9 @@ public class QuestFactory implements ConversationAbandonedListener { if (cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null) { shareProgressLevelOpt = (Integer) cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL); } + if (cc.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null) { + requireSameQuestOpt = (Boolean) cc.getSessionData(CK.OPT_REQUIRE_SAME_QUEST); + } cs.set("name", name); cs.set("npc-giver-id", npcStart); cs.set("block-start", blockStart); @@ -1593,6 +1597,7 @@ public class QuestFactory implements ConversationAbandonedListener { sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt); sch.set("use-parties-plugin", usePartiesPluginOpt); sch.set("share-progress-level", shareProgressLevelOpt); + sch.set("require-same-quest", requireSameQuestOpt); } @SuppressWarnings("deprecation") @@ -1713,6 +1718,7 @@ public class QuestFactory implements ConversationAbandonedListener { cc.setSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN, opt.getUseDungeonsXLPlugin()); cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin()); cc.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel()); + cc.setSessionData(CK.OPT_REQUIRE_SAME_QUEST, opt.getRequireSameQuest()); // Stages (Objectives) int index = 1; for (Stage stage : q.getStages()) { diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 611431a94..a86f8d10a 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -26,7 +26,6 @@ import java.util.Random; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.BiFunction; import java.util.function.Function; import org.bukkit.Bukkit; @@ -3278,16 +3277,14 @@ public class Quester { * @param objectiveType The type of objective to progress * @param fun The function to execute, the event call */ - public void dispatchMultiplayerEverything(String objectiveType, BiFunction fun) { - Map mq = getMultiplayerQuesters(); - for (Entry q : mq.entrySet()) { - for (Quest quest : q.getKey().getCurrentQuests().keySet()) { - if (q.getKey().containsObjective(quest, objectiveType) - && quest.getOptions().getShareProgressLevel() == 1 - && ((quest.getOptions().getUsePartiesPlugin() && q.getValue().parties) - || (quest.getOptions().getUseDungeonsXLPlugin() && q.getValue().dungeonxl))) { - fun.apply(q.getKey(), quest); + public void dispatchMultiplayerEverything(Quest quest, String objectiveType, Function fun) { + if (quest.getOptions().getShareProgressLevel() == 1) { + List mq = getMultiplayerQuesters(quest); + for (Quester q : mq) { + if (q.containsObjective(quest, objectiveType) || !quest.getOptions().getRequireSameQuest()) { + fun.apply(q); } + } } } @@ -3301,9 +3298,10 @@ public class Quester { */ public void dispatchMultiplayerObjectives(Quest quest, Stage currentStage, Function fun) { if (quest.getOptions().getShareProgressLevel() == 2) { - List mq = getMultiplayerQuestersByQuest(quest); + List mq = getMultiplayerQuesters(quest); for (Quester q : mq) { - if (q.getCurrentQuests().containsKey(quest) && currentStage.equals(q.getCurrentStage(quest))) { + if ((q.getCurrentQuests().containsKey(quest) && currentStage.equals(q.getCurrentStage(quest))) + || !quest.getOptions().getRequireSameQuest()) { fun.apply(q); } } @@ -3315,7 +3313,7 @@ public class Quester { * * @return empty if no linked plugins, or party/group is null */ - public Map getMultiplayerQuesters() { + /*public Map getMultiplayerQuesters() { Map ret = new LinkedHashMap<>(); if (plugin.getDependencies().getPartiesApi() != null) { Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID()).getPartyName()); @@ -3342,7 +3340,7 @@ public class Quester { } } return ret; - } + }*/ /** * Get a map of fellow Questers in a party or group @@ -3351,7 +3349,7 @@ public class Quester { * @param quest the quest to check * @return empty if no linked plugins, or party/group is null */ - public List getMultiplayerQuestersByQuest(Quest quest) { + /*public List getMultiplayerQuestersByQuest(Quest quest) { List ret = new LinkedList<>(); Map mq = getMultiplayerQuesters(); for (Entry q : mq.entrySet()) { @@ -3364,9 +3362,9 @@ public class Quester { } return ret; - } + }*/ - public class MultiplayerType { + /*public class MultiplayerType { public boolean parties; public boolean dungeonxl; @@ -3374,6 +3372,47 @@ public class Quester { this.parties = parties; this.dungeonxl = dungeonxl; } + }*/ + + /** + * Get a list of follow Questers in a party or group + * + * @param quest The quest which uses a linked plugin, i.e. Parties or DungeonsXL + * @return null if quest is null, no linked plugins, or party/group is null + */ + public List getMultiplayerQuesters(Quest quest) { + if (quest == null) { + return null; + } + if (plugin.getDependencies().getPartiesApi() != null) { + if (quest.getOptions().getUsePartiesPlugin()) { + Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID()).getPartyName()); + if (party != null) { + List mq = new LinkedList(); + for (UUID id : party.getMembers()) { + if (!id.equals(getUUID())) { + mq.add(plugin.getQuester(id)); + } + } + return mq; + } + } + } + if (plugin.getDependencies().getDungeonsApi() != null) { + if (quest.getOptions().getUseDungeonsXLPlugin()) { + DGroup group = DGroup.getByPlayer(getPlayer()); + if (group != null) { + List mq = new LinkedList(); + for (UUID id : group.getPlayers()) { + if (!id.equals(getUUID())) { + mq.add(plugin.getQuester(id)); + } + } + return mq; + } + } + } + return null; } /** diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index d40f069bc..71e66a16e 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -1946,6 +1946,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (config.contains("quests." + questKey + ".options.share-progress-level")) { opts.setShareProgressLevel(config.getInt("quests." + questKey + ".options.share-progress-level")); } + if (config.contains("quests." + questKey + ".options.require-same-quest")) { + opts.setRequireSameQuest(config.getBoolean("quests." + questKey + ".options.require-same-quest")); + } } private void skipQuestProcess(String[] msgs) throws SkipQuest { diff --git a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index dfc1329ae..1eb98948e 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -1,4 +1,5 @@ /******************************************************************************************************* + * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -209,14 +210,14 @@ public class PlayerListener implements Listener { if (quester.containsObjective(quest, "useBlock")) { quester.useBlock(quest, blockItemStack); hasObjective = true; + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "useBlock", (Quester q) -> { + q.useBlock(quest, blockItemStack); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("useBlock", (Quester q, Quest quest) -> { - q.useBlock(quest, blockItemStack); - return null; - }); } if (!hasObjective) { if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(evt.getPlayer().getUniqueId())) { @@ -365,14 +366,14 @@ public class PlayerListener implements Listener { } if (quester.containsObjective(quest, "password")) { quester.sayPassword(quest, evt); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "password", (Quester q) -> { + q.sayPassword(quest, evt); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("password", (Quester q, Quest quest) -> { - q.sayPassword(quest, evt); - return null; - }); } } } @@ -423,14 +424,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "damageBlock")) { quester.damageBlock(quest, blockItemStack); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> { + q.placeBlock(quest, blockItemStack); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("placeBlock", (Quester q, Quest quest) -> { - q.placeBlock(quest, blockItemStack); - return null; - }); } } @@ -445,15 +446,15 @@ public class PlayerListener implements Listener { if (quester.containsObjective(quest, "placeBlock")) { if (evt.isCancelled() == false) { quester.placeBlock(quest, blockItemStack); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> { + q.placeBlock(quest, blockItemStack); + return null; + }); } } } - - // Multiplayer - quester.dispatchMultiplayerEverything("placeBlock", (Quester q, Quest quest) -> { - q.placeBlock(quest, blockItemStack); - return null; - }); } } @@ -469,6 +470,14 @@ public class PlayerListener implements Listener { if (quester.containsObjective(quest, "breakBlock")) { if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) { quester.breakBlock(quest, blockItemStack); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "breakBlock", (Quester q) -> { + if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) { + q.breakBlock(quest, blockItemStack); + } + return null; + }); } } if (quester.containsObjective(quest, "placeBlock")) { @@ -477,40 +486,36 @@ public class PlayerListener implements Listener { int index = quester.getQuestData(quest).blocksPlaced.indexOf(is); is.setAmount(is.getAmount() - 1); quester.getQuestData(quest).blocksPlaced.set(index, is); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> { + for (ItemStack is2 : q.getQuestData(quest).blocksPlaced) { + if (evt.getBlock().getType().equals(is2.getType()) && is2.getAmount() > 0) { + int index2 = q.getQuestData(quest).blocksPlaced.indexOf(is2); + is2.setAmount(is2.getAmount() - 1); + q.getQuestData(quest).blocksPlaced.set(index2, is2); + } + } + return null; + }); } } } if (quester.containsObjective(quest, "cutBlock")) { if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) { quester.cutBlock(quest, blockItemStack); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "cutBlock", (Quester q) -> { + if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) { + q.cutBlock(quest, blockItemStack); + } + return null; + }); } } } } - - // Multiplayer - quester.dispatchMultiplayerEverything("breakBlock", (Quester q, Quest quest) -> { - if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) { - q.breakBlock(quest, blockItemStack); - } - return null; - }); - quester.dispatchMultiplayerEverything("placeBlock", (Quester q, Quest quest) -> { - for (ItemStack is : q.getQuestData(quest).blocksPlaced) { - if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) { - int index = q.getQuestData(quest).blocksPlaced.indexOf(is); - is.setAmount(is.getAmount() - 1); - q.getQuestData(quest).blocksPlaced.set(index, is); - } - } - return null; - }); - quester.dispatchMultiplayerEverything("cutBlock", (Quester q, Quest quest) -> { - if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) { - q.cutBlock(quest, blockItemStack); - } - return null; - }); } } @@ -523,14 +528,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "shearSheep")) { quester.shearSheep(quest, sheep.getColor()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "shearSheep", (Quester q) -> { + q.shearSheep(quest, sheep.getColor()); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("shearSheep", (Quester q, Quest quest) -> { - q.shearSheep(quest, sheep.getColor()); - return null; - }); } } } @@ -544,14 +549,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "tameMob")) { quester.tameMob(quest, evt.getEntityType()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "tameMob", (Quester q) -> { + q.tameMob(quest, evt.getEntityType()); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("tameMob", (Quester q, Quest quest) -> { - q.tameMob(quest, evt.getEntityType()); - return null; - }); } } } @@ -567,14 +572,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "craftItem")) { quester.craftItem(quest, craftedItem); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "craftItem", (Quester q) -> { + q.craftItem(quest, craftedItem); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("craftItem", (Quester q, Quest quest) -> { - q.craftItem(quest, craftedItem); - return null; - }); } } } @@ -611,14 +616,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "smeltItem")) { quester.smeltItem(quest, evt.getCurrentItem()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "smeltItem", (Quester q) -> { + q.smeltItem(quest, evt.getCurrentItem()); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("smeltItem", (Quester q, Quest quest) -> { - q.smeltItem(quest, evt.getCurrentItem()); - return null; - }); } } else if (evt.getInventory().getType() == InventoryType.BREWING) { if (evt.getSlotType() == SlotType.CRAFTING) { @@ -626,14 +631,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "brewItem")) { quester.brewItem(quest, evt.getCurrentItem()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "brewItem", (Quester q) -> { + q.brewItem(quest, evt.getCurrentItem()); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("brewItem", (Quester q, Quest quest) -> { - q.brewItem(quest, evt.getCurrentItem()); - return null; - }); } } } @@ -647,17 +652,15 @@ public class PlayerListener implements Listener { if (quester.containsObjective(quest, "enchantItem")) { for (Enchantment e : evt.getEnchantsToAdd().keySet()) { quester.enchantItem(quest, e, evt.getItem().getType()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "enchantItem", (Quester q) -> { + q.enchantItem(quest, e, evt.getItem().getType()); + return null; + }); } } } - - // Multiplayer - quester.dispatchMultiplayerEverything("enchantItem", (Quester q, Quest quest) -> { - for (Enchantment e : evt.getEnchantsToAdd().keySet()) { - q.enchantItem(quest, e, evt.getItem().getType()); - } - return null; - }); } } @@ -712,14 +715,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "killNPC")) { quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target)); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "killNPC", (Quester q) -> { + q.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target)); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("killNPC", (Quester q, Quest quest) -> { - q.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target)); - return null; - }); return; } } @@ -727,14 +730,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "killMob")) { quester.killMob(quest, target.getLocation(), target.getType()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "killMob", (Quester q) -> { + q.killMob(quest, target.getLocation(), target.getType()); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("killMob", (Quester q, Quest quest) -> { - q.killMob(quest, target.getLocation(), target.getType()); - return null; - }); } } @@ -822,14 +825,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "killPlayer")) { quester.killPlayer(quest, (Player)target); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "killPlayer", (Quester q) -> { + q.killPlayer(quest, (Player)target); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("killPlayer", (Quester q, Quest quest) -> { - q.killPlayer(quest, (Player)target); - return null; - }); } } @@ -841,14 +844,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) { quester.catchFish(quest); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "catchFish", (Quester q) -> { + q.catchFish(quest); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("catchFish", (Quester q, Quest quest) -> { - q.catchFish(quest); - return null; - }); } } @@ -973,14 +976,14 @@ public class PlayerListener implements Listener { for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.containsObjective(quest, "reachLocation")) { quester.reachLocation(quest, evt.getTo()); + + // Multiplayer + quester.dispatchMultiplayerEverything(quest, "reachLocation", (Quester q) -> { + q.reachLocation(quest, evt.getTo()); + return null; + }); } } - - // Multiplayer - quester.dispatchMultiplayerEverything("reachLocation", (Quester q, Quest quest) -> { - q.reachLocation(quest, evt.getTo()); - return null; - }); } } } diff --git a/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java index 179f30d86..37713ed9a 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java @@ -339,7 +339,7 @@ public class OptionsPrompt extends NumericPrompt { public class MultiplayerPrompt extends NumericPrompt { - private final int size = 4; + private final int size = 5; public int getSize() { return size; @@ -358,6 +358,8 @@ public class OptionsPrompt extends NumericPrompt { case 3: return ChatColor.BLUE; case 4: + return ChatColor.BLUE; + case 5: return ChatColor.GREEN; default: return null; @@ -397,6 +399,16 @@ public class OptionsPrompt extends NumericPrompt { + ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")"; } case 4: + if (context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST) == null) { + boolean defaultOpt = new Options().getRequireSameQuest(); + return ChatColor.YELLOW + Lang.get("optRequireSameQuest") + " (" + + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")"; + } else { + boolean requireOpt = (Boolean) context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST); + return ChatColor.YELLOW + Lang.get("optRequireSameQuest") + " (" + + (requireOpt ? ChatColor.GREEN + String.valueOf(requireOpt) : ChatColor.RED + String.valueOf(requireOpt)) + ChatColor.YELLOW + ")"; + } + case 5: return ChatColor.YELLOW + Lang.get("done"); default: return null; @@ -431,6 +443,10 @@ public class OptionsPrompt extends NumericPrompt { tempPrompt = new MultiplayerPrompt(); return new LevelPrompt(); case 4: + tempKey = CK.OPT_REQUIRE_SAME_QUEST; + tempPrompt = new MultiplayerPrompt(); + return new TrueFalsePrompt(); + case 5: tempKey = null; tempPrompt = null; try { diff --git a/main/src/main/java/me/blackvein/quests/util/CK.java b/main/src/main/java/me/blackvein/quests/util/CK.java index 0f050ffe9..ab409d82f 100644 --- a/main/src/main/java/me/blackvein/quests/util/CK.java +++ b/main/src/main/java/me/blackvein/quests/util/CK.java @@ -137,6 +137,7 @@ public class CK { public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt"; public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt"; public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt"; + public static final String OPT_REQUIRE_SAME_QUEST = "requireSameQuestOpt"; // Events public static final String E_OLD_EVENT = "oldEvent"; public static final String E_NAME = "evtName"; diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml index 2c2465877..42bf1a833 100644 --- a/main/src/main/resources/strings.yml +++ b/main/src/main/resources/strings.yml @@ -475,6 +475,7 @@ optCommandsDenied: "You cannot use commands during ." optUseDungeonsXLPlugin: "Use DungeonsXL plugin" optUsePartiesPlugin: "Use Parties plugin" optShareProgressLevel: "Level of progress sharing" +optRequireSameQuest: "Require same quest" rewSetMoney: "Set money reward" rewSetQuestPoints: "Set Quest Points reward" rewSetItems: "Set item rewards"