Add option for fellow party members to receive progress outside quest

This commit is contained in:
PikaMug 2019-09-13 11:13:01 -04:00
parent cfb7be4272
commit cad906965a
9 changed files with 214 additions and 136 deletions

View File

@ -18,6 +18,7 @@ public class Options {
private boolean useDungeonsXLPlugin = false; private boolean useDungeonsXLPlugin = false;
private boolean usePartiesPlugin = true; private boolean usePartiesPlugin = true;
private int shareProgressLevel = 1; private int shareProgressLevel = 1;
private boolean requireSameQuest = true;
public boolean getAllowCommands() { public boolean getAllowCommands() {
return allowCommands; return allowCommands;
@ -58,4 +59,12 @@ public class Options {
public void setShareProgressLevel(int shareProgressLevel) { public void setShareProgressLevel(int shareProgressLevel) {
this.shareProgressLevel = shareProgressLevel; this.shareProgressLevel = shareProgressLevel;
} }
public boolean getRequireSameQuest() {
return requireSameQuest;
}
public void setRequireSameQuest(boolean requireSameQuest) {
this.requireSameQuest = requireSameQuest;
}
} }

View File

@ -208,7 +208,7 @@ public class Quest {
// Multiplayer // Multiplayer
if (opts.getShareProgressLevel() == 3) { if (opts.getShareProgressLevel() == 3) {
List<Quester> mq = quester.getMultiplayerQuestersByQuest(this); List<Quester> mq = quester.getMultiplayerQuesters(this);
for (Quester qq : mq) { for (Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(this))) { if (currentStage.equals(qq.getCurrentStage(this))) {
nextStage(qq, allowSharedProgress); nextStage(qq, allowSharedProgress);
@ -694,7 +694,7 @@ public class Quest {
// Multiplayer // Multiplayer
if (opts.getShareProgressLevel() == 4) { if (opts.getShareProgressLevel() == 4) {
List<Quester> mq = q.getMultiplayerQuestersByQuest(this); List<Quester> mq = q.getMultiplayerQuesters(this);
for (Quester qq : mq) { for (Quester qq : mq) {
completeQuest(qq); completeQuest(qq);
} }

View File

@ -999,6 +999,7 @@ public class QuestFactory implements ConversationAbandonedListener {
boolean useDungeonsXLPluginOpt = false; boolean useDungeonsXLPluginOpt = false;
boolean usePartiesPluginOpt = true; boolean usePartiesPluginOpt = true;
Integer shareProgressLevelOpt = 1; Integer shareProgressLevelOpt = 1;
boolean requireSameQuestOpt = true;
if (cc.getSessionData(CK.Q_START_NPC) != null) { if (cc.getSessionData(CK.Q_START_NPC) != null) {
npcStart = (Integer) cc.getSessionData(CK.Q_START_NPC); 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) { if (cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null) {
shareProgressLevelOpt = (Integer) cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL); 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("name", name);
cs.set("npc-giver-id", npcStart); cs.set("npc-giver-id", npcStart);
cs.set("block-start", blockStart); cs.set("block-start", blockStart);
@ -1593,6 +1597,7 @@ public class QuestFactory implements ConversationAbandonedListener {
sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt); sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt);
sch.set("use-parties-plugin", usePartiesPluginOpt); sch.set("use-parties-plugin", usePartiesPluginOpt);
sch.set("share-progress-level", shareProgressLevelOpt); sch.set("share-progress-level", shareProgressLevelOpt);
sch.set("require-same-quest", requireSameQuestOpt);
} }
@SuppressWarnings("deprecation") @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_DUNGEONSXL_PLUGIN, opt.getUseDungeonsXLPlugin());
cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin()); cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin());
cc.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel()); cc.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel());
cc.setSessionData(CK.OPT_REQUIRE_SAME_QUEST, opt.getRequireSameQuest());
// Stages (Objectives) // Stages (Objectives)
int index = 1; int index = 1;
for (Stage stage : q.getStages()) { for (Stage stage : q.getStages()) {

View File

@ -26,7 +26,6 @@ import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import java.util.function.Function; import java.util.function.Function;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -3278,16 +3277,14 @@ public class Quester {
* @param objectiveType The type of objective to progress * @param objectiveType The type of objective to progress
* @param fun The function to execute, the event call * @param fun The function to execute, the event call
*/ */
public void dispatchMultiplayerEverything(String objectiveType, BiFunction<Quester, Quest, Void> fun) { public void dispatchMultiplayerEverything(Quest quest, String objectiveType, Function<Quester, Void> fun) {
Map<Quester, MultiplayerType> mq = getMultiplayerQuesters(); if (quest.getOptions().getShareProgressLevel() == 1) {
for (Entry<Quester, MultiplayerType> q : mq.entrySet()) { List<Quester> mq = getMultiplayerQuesters(quest);
for (Quest quest : q.getKey().getCurrentQuests().keySet()) { for (Quester q : mq) {
if (q.getKey().containsObjective(quest, objectiveType) if (q.containsObjective(quest, objectiveType) || !quest.getOptions().getRequireSameQuest()) {
&& quest.getOptions().getShareProgressLevel() == 1 fun.apply(q);
&& ((quest.getOptions().getUsePartiesPlugin() && q.getValue().parties)
|| (quest.getOptions().getUseDungeonsXLPlugin() && q.getValue().dungeonxl))) {
fun.apply(q.getKey(), quest);
} }
} }
} }
} }
@ -3301,9 +3298,10 @@ public class Quester {
*/ */
public void dispatchMultiplayerObjectives(Quest quest, Stage currentStage, Function<Quester, Void> fun) { public void dispatchMultiplayerObjectives(Quest quest, Stage currentStage, Function<Quester, Void> fun) {
if (quest.getOptions().getShareProgressLevel() == 2) { if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest); List<Quester> mq = getMultiplayerQuesters(quest);
for (Quester q : mq) { 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); fun.apply(q);
} }
} }
@ -3315,7 +3313,7 @@ public class Quester {
* *
* @return empty if no linked plugins, or party/group is null * @return empty if no linked plugins, or party/group is null
*/ */
public Map<Quester, MultiplayerType> getMultiplayerQuesters() { /*public Map<Quester, MultiplayerType> getMultiplayerQuesters() {
Map<Quester, MultiplayerType> ret = new LinkedHashMap<>(); Map<Quester, MultiplayerType> ret = new LinkedHashMap<>();
if (plugin.getDependencies().getPartiesApi() != null) { if (plugin.getDependencies().getPartiesApi() != null) {
Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID()).getPartyName()); Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID()).getPartyName());
@ -3342,7 +3340,7 @@ public class Quester {
} }
} }
return ret; return ret;
} }*/
/** /**
* Get a map of fellow Questers in a party or group * Get a map of fellow Questers in a party or group
@ -3351,7 +3349,7 @@ public class Quester {
* @param quest the quest to check * @param quest the quest to check
* @return empty if no linked plugins, or party/group is null * @return empty if no linked plugins, or party/group is null
*/ */
public List<Quester> getMultiplayerQuestersByQuest(Quest quest) { /*public List<Quester> getMultiplayerQuestersByQuest(Quest quest) {
List<Quester> ret = new LinkedList<>(); List<Quester> ret = new LinkedList<>();
Map<Quester, MultiplayerType> mq = getMultiplayerQuesters(); Map<Quester, MultiplayerType> mq = getMultiplayerQuesters();
for (Entry<Quester, MultiplayerType> q : mq.entrySet()) { for (Entry<Quester, MultiplayerType> q : mq.entrySet()) {
@ -3364,9 +3362,9 @@ public class Quester {
} }
return ret; return ret;
} }*/
public class MultiplayerType { /*public class MultiplayerType {
public boolean parties; public boolean parties;
public boolean dungeonxl; public boolean dungeonxl;
@ -3374,6 +3372,47 @@ public class Quester {
this.parties = parties; this.parties = parties;
this.dungeonxl = dungeonxl; 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<Quester> 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<Quester> mq = new LinkedList<Quester>();
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<Quester> mq = new LinkedList<Quester>();
for (UUID id : group.getPlayers()) {
if (!id.equals(getUUID())) {
mq.add(plugin.getQuester(id));
}
}
return mq;
}
}
}
return null;
} }
/** /**

View File

@ -1946,6 +1946,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questKey + ".options.share-progress-level")) { if (config.contains("quests." + questKey + ".options.share-progress-level")) {
opts.setShareProgressLevel(config.getInt("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 { private void skipQuestProcess(String[] msgs) throws SkipQuest {

View File

@ -1,4 +1,5 @@
/******************************************************************************************************* /*******************************************************************************************************
* Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved. * 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 * 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")) { if (quester.containsObjective(quest, "useBlock")) {
quester.useBlock(quest, blockItemStack); quester.useBlock(quest, blockItemStack);
hasObjective = true; 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 (!hasObjective) {
if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(evt.getPlayer().getUniqueId())) { if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(evt.getPlayer().getUniqueId())) {
@ -365,14 +366,14 @@ public class PlayerListener implements Listener {
} }
if (quester.containsObjective(quest, "password")) { if (quester.containsObjective(quest, "password")) {
quester.sayPassword(quest, evt); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "damageBlock")) { if (quester.containsObjective(quest, "damageBlock")) {
quester.damageBlock(quest, blockItemStack); 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 (quester.containsObjective(quest, "placeBlock")) {
if (evt.isCancelled() == false) { if (evt.isCancelled() == false) {
quester.placeBlock(quest, blockItemStack); 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 (quester.containsObjective(quest, "breakBlock")) {
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) { if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) {
quester.breakBlock(quest, blockItemStack); 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")) { if (quester.containsObjective(quest, "placeBlock")) {
@ -477,40 +486,36 @@ public class PlayerListener implements Listener {
int index = quester.getQuestData(quest).blocksPlaced.indexOf(is); int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
is.setAmount(is.getAmount() - 1); is.setAmount(is.getAmount() - 1);
quester.getQuestData(quest).blocksPlaced.set(index, is); 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 (quester.containsObjective(quest, "cutBlock")) {
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) { if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) {
quester.cutBlock(quest, blockItemStack); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "shearSheep")) { if (quester.containsObjective(quest, "shearSheep")) {
quester.shearSheep(quest, sheep.getColor()); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "tameMob")) { if (quester.containsObjective(quest, "tameMob")) {
quester.tameMob(quest, evt.getEntityType()); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "craftItem")) { if (quester.containsObjective(quest, "craftItem")) {
quester.craftItem(quest, craftedItem); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "smeltItem")) { if (quester.containsObjective(quest, "smeltItem")) {
quester.smeltItem(quest, evt.getCurrentItem()); 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) { } else if (evt.getInventory().getType() == InventoryType.BREWING) {
if (evt.getSlotType() == SlotType.CRAFTING) { if (evt.getSlotType() == SlotType.CRAFTING) {
@ -626,14 +631,14 @@ public class PlayerListener implements Listener {
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "brewItem")) { if (quester.containsObjective(quest, "brewItem")) {
quester.brewItem(quest, evt.getCurrentItem()); 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")) { if (quester.containsObjective(quest, "enchantItem")) {
for (Enchantment e : evt.getEnchantsToAdd().keySet()) { for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
quester.enchantItem(quest, e, evt.getItem().getType()); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "killNPC")) { if (quester.containsObjective(quest, "killNPC")) {
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target)); 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; return;
} }
} }
@ -727,14 +730,14 @@ public class PlayerListener implements Listener {
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "killMob")) { if (quester.containsObjective(quest, "killMob")) {
quester.killMob(quest, target.getLocation(), target.getType()); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "killPlayer")) { if (quester.containsObjective(quest, "killPlayer")) {
quester.killPlayer(quest, (Player)target); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) { if (quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
quester.catchFish(quest); 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()) { for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "reachLocation")) { if (quester.containsObjective(quest, "reachLocation")) {
quester.reachLocation(quest, evt.getTo()); 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;
});
} }
} }
} }

View File

@ -339,7 +339,7 @@ public class OptionsPrompt extends NumericPrompt {
public class MultiplayerPrompt extends NumericPrompt { public class MultiplayerPrompt extends NumericPrompt {
private final int size = 4; private final int size = 5;
public int getSize() { public int getSize() {
return size; return size;
@ -358,6 +358,8 @@ public class OptionsPrompt extends NumericPrompt {
case 3: case 3:
return ChatColor.BLUE; return ChatColor.BLUE;
case 4: case 4:
return ChatColor.BLUE;
case 5:
return ChatColor.GREEN; return ChatColor.GREEN;
default: default:
return null; return null;
@ -397,6 +399,16 @@ public class OptionsPrompt extends NumericPrompt {
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")"; + ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")";
} }
case 4: 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"); return ChatColor.YELLOW + Lang.get("done");
default: default:
return null; return null;
@ -431,6 +443,10 @@ public class OptionsPrompt extends NumericPrompt {
tempPrompt = new MultiplayerPrompt(); tempPrompt = new MultiplayerPrompt();
return new LevelPrompt(); return new LevelPrompt();
case 4: case 4:
tempKey = CK.OPT_REQUIRE_SAME_QUEST;
tempPrompt = new MultiplayerPrompt();
return new TrueFalsePrompt();
case 5:
tempKey = null; tempKey = null;
tempPrompt = null; tempPrompt = null;
try { try {

View File

@ -137,6 +137,7 @@ public class CK {
public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt"; public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt"; public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt"; public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt";
public static final String OPT_REQUIRE_SAME_QUEST = "requireSameQuestOpt";
// Events // Events
public static final String E_OLD_EVENT = "oldEvent"; public static final String E_OLD_EVENT = "oldEvent";
public static final String E_NAME = "evtName"; public static final String E_NAME = "evtName";

View File

@ -475,6 +475,7 @@ optCommandsDenied: "You cannot use commands during <quest>."
optUseDungeonsXLPlugin: "Use DungeonsXL plugin" optUseDungeonsXLPlugin: "Use DungeonsXL plugin"
optUsePartiesPlugin: "Use Parties plugin" optUsePartiesPlugin: "Use Parties plugin"
optShareProgressLevel: "Level of progress sharing" optShareProgressLevel: "Level of progress sharing"
optRequireSameQuest: "Require same quest"
rewSetMoney: "Set money reward" rewSetMoney: "Set money reward"
rewSetQuestPoints: "Set Quest Points reward" rewSetQuestPoints: "Set Quest Points reward"
rewSetItems: "Set item rewards" rewSetItems: "Set item rewards"