Configurable progress sharing level for multiplayer quests, fixes #679

This commit is contained in:
PikaMug 2019-07-02 15:35:30 -04:00
parent 9015571680
commit ed0beae1ec
16 changed files with 220 additions and 167 deletions

View File

@ -17,6 +17,7 @@ public class Options {
private boolean allowQuitting = true; private boolean allowQuitting = true;
private boolean useDungeonsXLPlugin = false; private boolean useDungeonsXLPlugin = false;
private boolean usePartiesPlugin = true; private boolean usePartiesPlugin = true;
private int shareProgressLevel = 1;
public boolean getAllowCommands() { public boolean getAllowCommands() {
return allowCommands; return allowCommands;
@ -49,4 +50,12 @@ public class Options {
public void setUsePartiesPlugin(boolean usePartiesPlugin) { public void setUsePartiesPlugin(boolean usePartiesPlugin) {
this.usePartiesPlugin = usePartiesPlugin; this.usePartiesPlugin = usePartiesPlugin;
} }
public int getShareProgressLevel() {
return shareProgressLevel;
}
public void setShareProgressLevel(int shareProgressLevel) {
this.shareProgressLevel = shareProgressLevel;
}
} }

View File

@ -14,9 +14,9 @@ package me.blackvein.quests;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -27,7 +27,6 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import com.alessiodp.parties.api.interfaces.Party;
import com.codisimus.plugins.phatloots.PhatLootsAPI; import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.codisimus.plugins.phatloots.loot.CommandLoot; import com.codisimus.plugins.phatloots.loot.CommandLoot;
import com.codisimus.plugins.phatloots.loot.LootBundle; import com.codisimus.plugins.phatloots.loot.LootBundle;
@ -37,7 +36,6 @@ import com.herocraftonline.heroes.characters.Hero;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import de.erethon.dungeonsxl.player.DGroup;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.Action;
import me.blackvein.quests.events.quester.QuesterPostChangeStageEvent; import me.blackvein.quests.events.quester.QuesterPostChangeStageEvent;
import me.blackvein.quests.events.quester.QuesterPostCompleteQuestEvent; import me.blackvein.quests.events.quester.QuesterPostCompleteQuestEvent;
@ -185,36 +183,6 @@ public class Quest {
if (q.getCurrentStage(this).finishEvent != null) { if (q.getCurrentStage(this).finishEvent != null) {
q.getCurrentStage(this).finishEvent.fire(q, this); q.getCurrentStage(this).finishEvent.fire(q, this);
} }
if (plugin.getDependencies().getPartiesApi() != null) {
if (opts.getUsePartiesPlugin()) {
Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(q.getUUID()).getPartyName());
if (party != null) {
for (UUID id : party.getMembers()) {
if (!id.equals(q.getUUID())) {
if (plugin.getQuester(id).getCurrentQuests().containsKey(this)) {
completeQuest(plugin.getQuester(id));
}
}
}
plugin.getLogger().info("Quest \'" + name + "\' was completed by party " + party.getName() + " (" + party.getMembers().size() + " members)");
}
}
}
if (plugin.getDependencies().getDungeonsApi() != null) {
if (opts.getUseDungeonsXLPlugin()) {
DGroup group = DGroup.getByPlayer(q.getPlayer());
if (group != null) {
for (UUID id : group.getPlayers().getUniqueIds()) {
if (!id.equals(q.getUUID())) {
if (plugin.getQuester(id).getCurrentQuests().containsKey(this)) {
completeQuest(plugin.getQuester(id));
}
}
}
plugin.getLogger().info("Quest \'" + name + "\' was completed by group " + group.getName() + " (" + group.getPlayers().size() + " players)");
}
}
}
completeQuest(q); completeQuest(q);
} else { } else {
try { try {
@ -225,6 +193,22 @@ public class Quest {
} catch (InvalidStageException e) { } catch (InvalidStageException e) {
e.printStackTrace(); e.printStackTrace();
} }
// Multiplayer
try {
if (opts.getShareProgressLevel() == 3) {
List<Quester> mq = q.getMultiplayerQuesters(this);
if (mq != null) {
for (Quester qq : mq) {
if (qq.getCurrentQuests().containsKey(this)) {
setStage(qq, qq.currentQuests.get(this) + 1);
}
}
}
}
} catch (InvalidStageException e) {
e.printStackTrace();
}
} }
if (q.getQuestData(this) != null) { if (q.getQuestData(this) != null) {
q.getQuestData(this).delayStartTime = 0; q.getQuestData(this).delayStartTime = 0;
@ -692,6 +676,18 @@ public class Quest {
q.findCompassTarget(); q.findCompassTarget();
QuesterPostCompleteQuestEvent postEvent = new QuesterPostCompleteQuestEvent(q, this); QuesterPostCompleteQuestEvent postEvent = new QuesterPostCompleteQuestEvent(q, this);
plugin.getServer().getPluginManager().callEvent(postEvent); plugin.getServer().getPluginManager().callEvent(postEvent);
// Multiplayer
if (opts.getShareProgressLevel() == 4) {
List<Quester> mq = q.getMultiplayerQuesters(this);
if (mq != null) {
for (Quester qq : mq) {
if (qq.getCurrentQuests().containsKey(this)) {
completeQuest(qq);
}
}
}
}
} }
/** /**

View File

@ -387,8 +387,7 @@ public class QuestFactory implements ConversationAbandonedListener {
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new SetNpcStartPrompt(); return new SetNpcStartPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -816,6 +815,7 @@ public class QuestFactory implements ConversationAbandonedListener {
boolean allowQuittingOpt = true; boolean allowQuittingOpt = true;
boolean useDungeonsXLPluginOpt = false; boolean useDungeonsXLPluginOpt = false;
boolean usePartiesPluginOpt = true; boolean usePartiesPluginOpt = true;
Integer shareProgressLevelOpt = 1;
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);
} }
@ -942,6 +942,9 @@ public class QuestFactory implements ConversationAbandonedListener {
if (cc.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null) { if (cc.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null) {
usePartiesPluginOpt = (Boolean) cc.getSessionData(CK.OPT_USE_PARTIES_PLUGIN); usePartiesPluginOpt = (Boolean) cc.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
} }
if (cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null) {
shareProgressLevelOpt = (Integer) cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
}
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);
@ -1408,6 +1411,7 @@ public class QuestFactory implements ConversationAbandonedListener {
sch.set("allow-quitting", allowQuittingOpt); sch.set("allow-quitting", allowQuittingOpt);
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);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -1524,6 +1528,7 @@ public class QuestFactory implements ConversationAbandonedListener {
cc.setSessionData(CK.OPT_ALLOW_QUITTING, opt.getAllowQuitting()); cc.setSessionData(CK.OPT_ALLOW_QUITTING, opt.getAllowQuitting());
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());
// Stages (Objectives) // Stages (Objectives)
int index = 1; int index = 1;
for (Stage stage : q.getStages()) { for (Stage stage : q.getStages()) {

View File

@ -46,6 +46,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import com.alessiodp.parties.api.interfaces.Party;
import de.erethon.dungeonsxl.player.DGroup;
import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent; import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent; import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
import me.blackvein.quests.timers.StageTimer; import me.blackvein.quests.timers.StageTimer;
@ -1050,6 +1053,18 @@ public class Quester {
} }
} }
} }
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 1) {
List<Quester> mq = getMultiplayerQuesters(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.breakBlock(quest, m);
}
}
}
}
} }
/** /**
@ -1740,19 +1755,11 @@ public class Quester {
EntityType mob, String extra, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { EntityType mob, String extra, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) {
Player p = getPlayer(); Player p = getPlayer();
if (getCurrentStage(quest).objectiveOverride != null) { if (getCurrentStage(quest).objectiveOverride != null) {
if (testComplete(quest)) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + getCurrentStage(quest).objectiveOverride;
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + getCurrentStage(quest).objectiveOverride; p.sendMessage(message);
p.sendMessage(message); } else if (objective.equalsIgnoreCase("password")) {
quest.nextStage(this);
}
return;
}
if (objective.equalsIgnoreCase("password")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + pass; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + pass;
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("breakBlock")) { } else if (objective.equalsIgnoreCase("breakBlock")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "break") + " <item>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "break") + " <item>";
message = message + " " + goal.getAmount() + "/" + goal.getAmount(); message = message + " " + goal.getAmount() + "/" + goal.getAmount();
@ -1761,9 +1768,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); p.sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("damageBlock")) { } else if (objective.equalsIgnoreCase("damageBlock")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "damage") + " <item>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "damage") + " <item>";
message = message + " " + goal.getAmount() + "/" + goal.getAmount(); message = message + " " + goal.getAmount() + "/" + goal.getAmount();
@ -1772,9 +1776,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); p.sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("placeBlock")) { } else if (objective.equalsIgnoreCase("placeBlock")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "place") + " <item>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "place") + " <item>";
message = message + " " + goal.getAmount() + "/" + goal.getAmount(); message = message + " " + goal.getAmount() + "/" + goal.getAmount();
@ -1783,9 +1784,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); p.sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("useBlock")) { } else if (objective.equalsIgnoreCase("useBlock")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "use") + " <item>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "use") + " <item>";
message = message + " " + goal.getAmount() + "/" + goal.getAmount(); message = message + " " + goal.getAmount() + "/" + goal.getAmount();
@ -1794,9 +1792,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); p.sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("cutBlock")) { } else if (objective.equalsIgnoreCase("cutBlock")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "cut") + " <item>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "cut") + " <item>";
message = message + " " + goal.getAmount() + "/" + goal.getAmount(); message = message + " " + goal.getAmount() + "/" + goal.getAmount();
@ -1805,9 +1800,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); p.sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("craftItem")) { } else if (objective.equalsIgnoreCase("craftItem")) {
ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal)); ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal));
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "craft") + " <item> " String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "craft") + " <item> "
@ -1817,9 +1809,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("smeltItem")) { } else if (objective.equalsIgnoreCase("smeltItem")) {
ItemStack is = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(goal)); ItemStack is = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(goal));
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "smelt") + " <item> " String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "smelt") + " <item> "
@ -1829,9 +1818,6 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("enchantItem")) { } else if (objective.equalsIgnoreCase("enchantItem")) {
String obj = Lang.get(p, "enchantItem"); String obj = Lang.get(p, "enchantItem");
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
@ -1849,9 +1835,6 @@ public class Quester {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment)) p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))
.replace("<enchantment>", enchantment.getName())); .replace("<enchantment>", enchantment.getName()));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("deliverItem")) { } else if (objective.equalsIgnoreCase("deliverItem")) {
String obj = Lang.get(p, "deliver"); String obj = Lang.get(p, "deliver");
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal)))); obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal))));
@ -1862,16 +1845,10 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("catchFish")) { } else if (objective.equalsIgnoreCase("catchFish")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " "; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " ";
message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch; message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch;
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("killMob")) { } else if (objective.equalsIgnoreCase("killMob")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " <mob>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " <mob>";
message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)); message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob));
@ -1880,31 +1857,19 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(mob))); p.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(mob)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("killPlayer")) { } else if (objective.equalsIgnoreCase("killPlayer")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "killPlayer"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "killPlayer");
message = message + " " + getCurrentStage(quest).playersToKill + "/" + getCurrentStage(quest).playersToKill; message = message + " " + getCurrentStage(quest).playersToKill + "/" + getCurrentStage(quest).playersToKill;
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("talkToNPC")) { } else if (objective.equalsIgnoreCase("talkToNPC")) {
String obj = Lang.get(p, "talkTo"); String obj = Lang.get(p, "talkTo");
obj = obj.replace("<npc>", plugin.getNPCName(npc.getId())); obj = obj.replace("<npc>", plugin.getNPCName(npc.getId()));
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("killNPC")) { } else if (objective.equalsIgnoreCase("killNPC")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " " + npc.getName(); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " " + npc.getName();
message = message + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())) + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())); message = message + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())) + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId()));
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("tameMob")) { } else if (objective.equalsIgnoreCase("tameMob")) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame") + " <mob>"; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame") + " <mob>";
message = message + " " + getCurrentStage(quest).mobsToTame.get(mob) + "/" + getCurrentStage(quest).mobsToTame.get(mob); message = message + " " + getCurrentStage(quest).mobsToTame.get(mob) + "/" + getCurrentStage(quest).mobsToTame.get(mob);
@ -1913,26 +1878,17 @@ public class Quester {
} else { } else {
p.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(mob))); p.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(mob)));
} }
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("shearSheep")) { } else if (objective.equalsIgnoreCase("shearSheep")) {
String obj = Lang.get(p, "shearSheep"); String obj = Lang.get(p, "shearSheep");
obj = obj.replace("<color>", color.name().toLowerCase()); obj = obj.replace("<color>", color.name().toLowerCase());
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
message = message + " " + getCurrentStage(quest).sheepToShear.get(color) + "/" + getCurrentStage(quest).sheepToShear.get(color); message = message + " " + getCurrentStage(quest).sheepToShear.get(color) + "/" + getCurrentStage(quest).sheepToShear.get(color);
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("reachLocation")) { } else if (objective.equalsIgnoreCase("reachLocation")) {
String obj = Lang.get(p, "goTo"); String obj = Lang.get(p, "goTo");
obj = obj.replace("<location>", getCurrentStage(quest).locationNames.get(getCurrentStage(quest).locationsToReach.indexOf(location))); obj = obj.replace("<location>", getCurrentStage(quest).locationNames.get(getCurrentStage(quest).locationsToReach.indexOf(location)));
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) {
quest.nextStage(this);
}
} else if (co != null) { } else if (co != null) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + co.getDisplay(); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + co.getDisplay();
int index = -1; int index = -1;
@ -1954,17 +1910,29 @@ public class Quester {
message = message.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); message = message.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
} }
p.sendMessage(message); p.sendMessage(message);
if (testComplete(quest)) { }
quest.nextStage(this); if (testComplete(quest)) {
quest.nextStage(this);
}
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuesters(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
quest.nextStage(q);
}
}
} }
} }
} }
/** /**
* Check whether a quest has been marked as complete * Check whether this Quester has completed all objectives for their current stage
* *
* @param quest The quest being checked * @param quest The quest with the current stage being checked
* @return true if marked complete * @return true if all stage objectives are marked complete
*/ */
public boolean testComplete(Quest quest) { public boolean testComplete(Quest quest) {
for (String s : getObjectives(quest, true)) { for (String s : getObjectives(quest, true)) {
@ -3029,6 +2997,47 @@ public class Quester {
return playerAmount >= is.getAmount(); return playerAmount >= is.getAmount();
} }
/**
* 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;
}
// I'm not sure why these methods are here. They've been in the class for a long time but aren't used anywhere? // I'm not sure why these methods are here. They've been in the class for a long time but aren't used anywhere?
/*public static String checkPlacement(Inventory inv, int rawSlot) { /*public static String checkPlacement(Inventory inv, int rawSlot) {

View File

@ -1814,6 +1814,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questKey + ".options.use-parties-plugin")) { if (config.contains("quests." + questKey + ".options.use-parties-plugin")) {
opts.setUsePartiesPlugin(config.getBoolean("quests." + questKey + ".options.use-parties-plugin")); opts.setUsePartiesPlugin(config.getBoolean("quests." + questKey + ".options.use-parties-plugin"));
} }
if (config.contains("quests." + questKey + ".options.share-progress-level")) {
opts.setShareProgressLevel(config.getInt("quests." + questKey + ".options.share-progress-level"));
}
} }
private void skipQuestProcess(String[] msgs) throws SkipQuest { private void skipQuestProcess(String[] msgs) throws SkipQuest {

View File

@ -1651,7 +1651,7 @@ public class ActionFactory implements ConversationAbandonedListener {
try { try {
inp = Integer.parseInt(input); inp = Integer.parseInt(input);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNotANumber")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new MobPrompt(); return new MobPrompt();
} }
if (inp == types.size() + 1) { if (inp == types.size() + 1) {
@ -1889,7 +1889,7 @@ public class ActionFactory implements ConversationAbandonedListener {
questMob.setSpawnAmounts(i); questMob.setSpawnAmounts(i);
return new QuestMobPrompt(mobIndex, questMob); return new QuestMobPrompt(mobIndex, questMob);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new MobAmountPrompt(mobIndex, questMob); return new MobAmountPrompt(mobIndex, questMob);
} }
} }
@ -2174,7 +2174,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} }
effDurations.add(l / 50L); effDurations.add(l / 50L);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", s));
return new PotionDurationsPrompt(); return new PotionDurationsPrompt();
} }
} }
@ -2205,7 +2205,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} }
magAmounts.add(i); magAmounts.add(i);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", s));
return new PotionMagnitudesPrompt(); return new PotionMagnitudesPrompt();
} }
} }
@ -2234,8 +2234,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_HUNGER, (Integer) i); context.setSessionData(CK.E_HUNGER, (Integer) i);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new HungerPrompt(); return new HungerPrompt();
} }
} else { } else {
@ -2264,8 +2263,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_SATURATION, (Integer) i); context.setSessionData(CK.E_SATURATION, (Integer) i);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new SaturationPrompt(); return new SaturationPrompt();
} }
} else { } else {
@ -2294,8 +2292,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_HEALTH, (Integer) i); context.setSessionData(CK.E_HEALTH, (Integer) i);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new HealthPrompt(); return new HealthPrompt();
} }
} else { } else {

View File

@ -82,7 +82,7 @@ public class CmdExecutor implements CommandExecutor {
if (cmd.getName().equalsIgnoreCase("quest")) { if (cmd.getName().equalsIgnoreCase("quest")) {
return questCommandHandler(cs, args); return questCommandHandler(cs, args);
} else if (cmd.getName().equalsIgnoreCase("quests")) { } else if (cmd.getName().equalsIgnoreCase("quests")) {
return questActionsCommandHandler(cs, args); return questsCommandHandler(cs, args);
} else if (cmd.getName().equalsIgnoreCase("questadmin")) { } else if (cmd.getName().equalsIgnoreCase("questadmin")) {
return questAdminCommandHandler(cs, args); return questAdminCommandHandler(cs, args);
} }
@ -196,7 +196,7 @@ public class CmdExecutor implements CommandExecutor {
showQuestDetails(cs, args); showQuestDetails(cs, args);
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return true; return true;
} }
} else { } else {
@ -206,7 +206,7 @@ public class CmdExecutor implements CommandExecutor {
return true; return true;
} }
private boolean questActionsCommandHandler(final CommandSender cs, String[] args) { private boolean questsCommandHandler(final CommandSender cs, String[] args) {
if (cs instanceof Player) { if (cs instanceof Player) {
if (args.length == 0) { if (args.length == 0) {
questsHelp(cs); questsHelp(cs);
@ -419,7 +419,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound")); cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -443,7 +443,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor")); cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
return true; return true;
} }
@ -457,7 +457,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor")); cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
return true; return true;
} }
@ -649,7 +649,7 @@ public class CmdExecutor implements CommandExecutor {
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "noActiveQuest")); player.sendMessage(ChatColor.YELLOW + Lang.get(player, "noActiveQuest"));
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get(player, "NoPermission")); player.sendMessage(ChatColor.RED + Lang.get(player, "noPermission"));
} }
} }
@ -742,7 +742,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get(player, "NoPermission")); player.sendMessage(ChatColor.RED + Lang.get(player, "noPermission"));
} }
} else { } else {
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questTakeDisabled")); player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questTakeDisabled"));
@ -768,7 +768,7 @@ public class CmdExecutor implements CommandExecutor {
plugin.listQuests((Player) cs, page); plugin.listQuests((Player) cs, page);
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -777,7 +777,7 @@ public class CmdExecutor implements CommandExecutor {
Player p = (Player) cs; Player p = (Player) cs;
printHelp(p); printHelp(p);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -839,7 +839,7 @@ public class CmdExecutor implements CommandExecutor {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) { if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) {
printAdminHelp(cs); printAdminHelp(cs);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -851,7 +851,7 @@ public class CmdExecutor implements CommandExecutor {
msg = msg.replace("<number>", ChatColor.DARK_PURPLE + String.valueOf(plugin.getQuests().size()) + ChatColor.GOLD); msg = msg.replace("<number>", ChatColor.DARK_PURPLE + String.valueOf(plugin.getQuests().size()) + ChatColor.GOLD);
cs.sendMessage(ChatColor.GOLD + msg); cs.sendMessage(ChatColor.GOLD + msg);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -887,7 +887,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.RED + Lang.get("unknownError")); cs.sendMessage(ChatColor.RED + Lang.get("unknownError"));
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -922,7 +922,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -958,7 +958,7 @@ public class CmdExecutor implements CommandExecutor {
quester.saveData(); quester.saveData();
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -994,7 +994,7 @@ public class CmdExecutor implements CommandExecutor {
quester.saveData(); quester.saveData();
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1051,7 +1051,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1126,7 +1126,7 @@ public class CmdExecutor implements CommandExecutor {
} }
thread.start(); thread.start();
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1166,7 +1166,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1224,7 +1224,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1264,7 +1264,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1306,7 +1306,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
npe.printStackTrace(); npe.printStackTrace();
@ -1353,7 +1353,7 @@ public class CmdExecutor implements CommandExecutor {
temp2.add(quester); temp2.add(quester);
plugin.setQuesters(temp2); plugin.setQuesters(temp2);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1361,7 +1361,7 @@ public class CmdExecutor implements CommandExecutor {
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) { if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) {
questsStats(cs, args); questsStats(cs, args);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }
@ -1390,7 +1390,7 @@ public class CmdExecutor implements CommandExecutor {
quester.saveData(); quester.saveData();
quester.updateJournal(); quester.updateJournal();
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("NoPermission")); cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
} }
} }

View File

@ -462,8 +462,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_PLAYER_KILL, i); context.setSessionData(pref + CK.S_PLAYER_KILL, i);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new KillPlayerPrompt(); return new KillPlayerPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -652,7 +651,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
} }
radii.add(i); radii.add(i);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new ReachRadiiPrompt(); return new ReachRadiiPrompt();
} }
} }
@ -1133,7 +1132,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
int i = Integer.parseInt(input); int i = Integer.parseInt(input);
stageDelay = i * 1000; stageDelay = i * 1000;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new DelayPrompt(); return new DelayPrompt();
} }
if (stageDelay < 1000) { if (stageDelay < 1000) {
@ -1405,7 +1404,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
return new CreateStagePrompt(plugin, stageNum, questFactory); return new CreateStagePrompt(plugin, stageNum, questFactory);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new CustomObjectiveCountPrompt(); return new CustomObjectiveCountPrompt();
} }
} }

View File

@ -435,7 +435,7 @@ public class ItemStackPrompt extends FixedSetPrompt {
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNotNumber")); cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new LevelPrompt(enchantment); return new LevelPrompt(enchantment);
} }
} }

View File

@ -370,7 +370,7 @@ public class MobsPrompt extends FixedSetPrompt {
} }
mobAmounts.add(i); mobAmounts.add(i);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new MobAmountsPrompt(); return new MobAmountsPrompt();
} }
} }
@ -490,8 +490,7 @@ public class MobsPrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_FISH, i); context.setSessionData(pref + CK.S_FISH, i);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new FishPrompt(); return new FishPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -648,7 +647,7 @@ public class MobsPrompt extends FixedSetPrompt {
} }
mobAmounts.add(i); mobAmounts.add(i);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new TameAmountsPrompt(); return new TameAmountsPrompt();
} }
} }
@ -798,7 +797,7 @@ public class MobsPrompt extends FixedSetPrompt {
} }
shearAmounts.add(i); shearAmounts.add(i);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new ShearAmountsPrompt(); return new ShearAmountsPrompt();
} }
} }

View File

@ -92,6 +92,35 @@ public class OptionsPrompt extends FixedSetPrompt {
} }
} }
private class NumberPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = Lang.get("optNumberPrompt");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("everything");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("objectives");;
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("stageEditorStages");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("quests");
return ChatColor.YELLOW + text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
try {
int i = Integer.parseInt(input);
context.setSessionData(tempKey, i);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(tempKey, null);
return tempPrompt;
}
return tempPrompt;
}
}
private class GeneralPrompt extends StringPrompt { private class GeneralPrompt extends StringPrompt {
@Override @Override
@ -166,7 +195,16 @@ public class OptionsPrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " (" text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " ("
+ (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")\n"; + (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")\n";
} }
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) {
int defaultOpt = new Options().getShareProgressLevel();
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " ("
+ ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")\n";
} else {
int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " ("
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
return text; return text;
} }
@ -181,6 +219,10 @@ public class OptionsPrompt extends FixedSetPrompt {
tempPrompt = new MultiplayerPrompt(); tempPrompt = new MultiplayerPrompt();
return new TrueFalsePrompt(); return new TrueFalsePrompt();
} else if (input.equalsIgnoreCase("3")) { } else if (input.equalsIgnoreCase("3")) {
tempKey = CK.OPT_SHARE_PROGRESS_LEVEL;
tempPrompt = new MultiplayerPrompt();
return new NumberPrompt();
} else if (input.equalsIgnoreCase("4")) {
tempKey = null; tempKey = null;
tempPrompt = null; tempPrompt = null;
try { try {

View File

@ -130,8 +130,7 @@ public class PlannerPrompt extends FixedSetPrompt {
context.setSessionData(CK.PLN_REPEAT_CYCLE, delay); context.setSessionData(CK.PLN_REPEAT_CYCLE, delay);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new RepeatPrompt(); return new RepeatPrompt();
} }
return new PlannerPrompt(plugin, factory); return new PlannerPrompt(plugin, factory);
@ -164,8 +163,7 @@ public class PlannerPrompt extends FixedSetPrompt {
context.setSessionData(CK.PLN_COOLDOWN, delay); context.setSessionData(CK.PLN_COOLDOWN, delay);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new CooldownPrompt(); return new CooldownPrompt();
} }
return new PlannerPrompt(plugin, factory); return new PlannerPrompt(plugin, factory);

View File

@ -211,8 +211,7 @@ public class RequirementsPrompt extends FixedSetPrompt {
return new MoneyPrompt(); return new MoneyPrompt();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new MoneyPrompt(); return new MoneyPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -242,8 +241,7 @@ public class RequirementsPrompt extends FixedSetPrompt {
return new QuestPointsPrompt(); return new QuestPointsPrompt();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new QuestPointsPrompt(); return new QuestPointsPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {

View File

@ -210,8 +210,7 @@ public class RewardsPrompt extends FixedSetPrompt {
return new MoneyPrompt(); return new MoneyPrompt();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new MoneyPrompt(); return new MoneyPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -241,8 +240,7 @@ public class RewardsPrompt extends FixedSetPrompt {
return new ExperiencePrompt(); return new ExperiencePrompt();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new ExperiencePrompt(); return new ExperiencePrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -272,8 +270,7 @@ public class RewardsPrompt extends FixedSetPrompt {
return new QuestPointsPrompt(); return new QuestPointsPrompt();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
+ Lang.get("stageEditorInvalidNumber"));
return new QuestPointsPrompt(); return new QuestPointsPrompt();
} }
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {

View File

@ -134,6 +134,7 @@ public class CK {
public static final String OPT_ALLOW_QUITTING = "allowQuittingOpt"; public static final String OPT_ALLOW_QUITTING = "allowQuittingOpt";
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";
// 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

@ -255,7 +255,6 @@ stageEditorInvalidEnchantment: "is not a valid enchantment name!"
stageEditorInvalidNPC: "is not a valid NPC ID!" stageEditorInvalidNPC: "is not a valid NPC ID!"
stageEditorInvalidMob: "is not a valid mob name!" stageEditorInvalidMob: "is not a valid mob name!"
stageEditorInvalidItemName: "is not a valid item name!" stageEditorInvalidItemName: "is not a valid item name!"
stageEditorInvalidNumber: "is not a number!"
stageEditorInvalidDye: "is not a valid dye color!" stageEditorInvalidDye: "is not a valid dye color!"
stageEditorInvalidEvent: "is not a valid action name!" stageEditorInvalidEvent: "is not a valid action name!"
stageEditorDuplicateEvent: "Action is already in the list!" stageEditorDuplicateEvent: "Action is already in the list!"
@ -351,7 +350,6 @@ eventEditorSetItemAmounts: "Set item amounts"
eventEditorNoNames: "No names set" eventEditorNoNames: "No names set"
eventEditorMustSetNames: "You must set item names first!" eventEditorMustSetNames: "You must set item names first!"
eventEditorInvalidName: "is not a valid item name!" eventEditorInvalidName: "is not a valid item name!"
eventEditorNotANumber: "is not a number!"
eventEditorStorm: "Action Storm" eventEditorStorm: "Action Storm"
eventEditorSetWorld: "Set world" eventEditorSetWorld: "Set world"
eventEditorSetDuration: "Set duration" eventEditorSetDuration: "Set duration"
@ -485,11 +483,13 @@ plnTooLate: "<quest> was last active <time> ago."
optGeneral: "General" optGeneral: "General"
optMultiplayer: "Multiplayer" optMultiplayer: "Multiplayer"
optBooleanPrompt: "Enter '<true>' or '<false>', <clear>, <cancel>" optBooleanPrompt: "Enter '<true>' or '<false>', <clear>, <cancel>"
optNumberPrompt: "Enter a level (number) for tracking progress, <clear>, <cancel>"
optAllowCommands: "Allow commands during quest" optAllowCommands: "Allow commands during quest"
optAllowQuitting: "Allow quitting during quest" optAllowQuitting: "Allow quitting during quest"
optCommandsDenied: "You cannot use commands during <quest>." 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"
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"
@ -552,7 +552,6 @@ itemCreateInvalidName: "Invalid item name!"
itemCreateInvalidDurab: "Invalid item durability!" itemCreateInvalidDurab: "Invalid item durability!"
itemCreateInvalidEnch: "Invalid enchantment name!" itemCreateInvalidEnch: "Invalid enchantment name!"
itemCreateInvalidInput: "Invalid input!" itemCreateInvalidInput: "Invalid input!"
itemCreateNotNumber: "Input was not a number!"
itemCreateNoNameAmount: "You must set a name and amount first!" itemCreateNoNameAmount: "You must set a name and amount first!"
itemCreateCriticalError: "A critical error has occurred." itemCreateCriticalError: "A critical error has occurred."
dateCreateEnterDay: "Enter a day (max. 31), <cancel>" dateCreateEnterDay: "Enter a day (max. 31), <cancel>"
@ -717,7 +716,6 @@ disableNPCGUI: "<npc> will no longer provide a GUI Quest Display."
invalidMinimum: "Input must be at least <number>!" invalidMinimum: "Input must be at least <number>!"
invalidRange: "Input must be between <least> and <greatest>!" invalidRange: "Input must be between <least> and <greatest>!"
invalidOption: "Invalid option!" invalidOption: "Invalid option!"
invalidNumber: "Invalid number."
invalidStageNum: "Invalid stage number for Quest <quest>" invalidStageNum: "Invalid stage number for Quest <quest>"
noCurrentQuest: "<player> does not currently have any active Quests." noCurrentQuest: "<player> does not currently have any active Quests."
playerNotFound: "Player not found." playerNotFound: "Player not found."
@ -835,6 +833,8 @@ questPoints: "Quest Points"
accepted: "Accepted" accepted: "Accepted"
complete: "Complete" complete: "Complete"
redoable: "Redoable" redoable: "Redoable"
objectives: "Objectives"
everything: "Everything"
usage: "Usage" usage: "Usage"
redoableEvery: "Redoable every <time>." redoableEvery: "Redoable every <time>."
requirements: "Requirements" requirements: "Requirements"