mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-29 11:41:39 +01:00
Make fail requirements message optional and list reqs instead by default
This commit is contained in:
parent
26a822d0d3
commit
f0df8db84d
@ -364,6 +364,19 @@ public class Quest {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (quester.questPoints < reqs.getQuestPoints()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (quester.completedQuests.containsAll(reqs.getNeededQuests()) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (String q : reqs.getBlockQuests()) {
|
||||||
|
Quest questObject = new Quest();
|
||||||
|
questObject.name = q;
|
||||||
|
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (String s : reqs.getMcmmoSkills()) {
|
for (String s : reqs.getMcmmoSkills()) {
|
||||||
final SkillType st = Quests.getMcMMOSkill(s);
|
final SkillType st = Quests.getMcMMOSkill(s);
|
||||||
final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s));
|
final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s));
|
||||||
@ -383,19 +396,6 @@ public class Quest {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quester.questPoints < reqs.getQuestPoints()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (quester.completedQuests.containsAll(reqs.getNeededQuests()) == false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (String q : reqs.getBlockQuests()) {
|
|
||||||
Quest questObject = new Quest();
|
|
||||||
questObject.name = q;
|
|
||||||
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
Player p = (Player)player;
|
Player p = (Player)player;
|
||||||
PlayerInventory inventory = p.getInventory();
|
PlayerInventory inventory = p.getInventory();
|
||||||
|
@ -611,9 +611,6 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
if (reqs.getHeroesSecondaryClass() != null) {
|
if (reqs.getHeroesSecondaryClass() != null) {
|
||||||
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
|
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
|
||||||
}
|
}
|
||||||
if (reqs.getFailRequirements() != null) {
|
|
||||||
cc.setSessionData(CK.Q_FAIL_MESSAGE, reqs.getFailRequirements());
|
|
||||||
}
|
|
||||||
if (reqs.getCustomRequirements().isEmpty() == false) {
|
if (reqs.getCustomRequirements().isEmpty() == false) {
|
||||||
LinkedList<String> list = new LinkedList<String>();
|
LinkedList<String> list = new LinkedList<String>();
|
||||||
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
||||||
@ -624,6 +621,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
cc.setSessionData(CK.REQ_CUSTOM, list);
|
cc.setSessionData(CK.REQ_CUSTOM, list);
|
||||||
cc.setSessionData(CK.REQ_CUSTOM_DATA, datamapList);
|
cc.setSessionData(CK.REQ_CUSTOM_DATA, datamapList);
|
||||||
}
|
}
|
||||||
|
if (reqs.getFailRequirements() != null) {
|
||||||
|
cc.setSessionData(CK.REQ_FAIL_MESSAGE, reqs.getFailRequirements());
|
||||||
|
}
|
||||||
Rewards rews = q.getRewards();
|
Rewards rews = q.getRewards();
|
||||||
if (rews.getMoney() != 0) {
|
if (rews.getMoney() != 0) {
|
||||||
cc.setSessionData(CK.REW_MONEY, rews.getMoney());
|
cc.setSessionData(CK.REW_MONEY, rews.getMoney());
|
||||||
@ -929,15 +929,15 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
if (stage.script != null) {
|
if (stage.script != null) {
|
||||||
cc.setSessionData(pref + CK.S_DENIZEN, stage.script);
|
cc.setSessionData(pref + CK.S_DENIZEN, stage.script);
|
||||||
}
|
}
|
||||||
if (stage.objectiveOverride != null) {
|
|
||||||
cc.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.objectiveOverride);
|
|
||||||
}
|
|
||||||
if (stage.completeMessage != null) {
|
if (stage.completeMessage != null) {
|
||||||
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.completeMessage);
|
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.completeMessage);
|
||||||
}
|
}
|
||||||
if (stage.startMessage != null) {
|
if (stage.startMessage != null) {
|
||||||
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
|
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
|
||||||
}
|
}
|
||||||
|
if (stage.objectiveOverride != null) {
|
||||||
|
cc.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.objectiveOverride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1570,8 +1570,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
customReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_CUSTOM);
|
customReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_CUSTOM);
|
||||||
customReqsData = (LinkedList<Map<String, Object>>) cc.getSessionData(CK.REQ_CUSTOM_DATA);
|
customReqsData = (LinkedList<Map<String, Object>>) cc.getSessionData(CK.REQ_CUSTOM_DATA);
|
||||||
}
|
}
|
||||||
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
|
if (cc.getSessionData(CK.REQ_FAIL_MESSAGE) != null) {
|
||||||
failMessage = (String) cc.getSessionData(CK.Q_FAIL_MESSAGE);
|
failMessage = (String) cc.getSessionData(CK.REQ_FAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
if (cc.getSessionData(CK.Q_INITIAL_EVENT) != null) {
|
if (cc.getSessionData(CK.Q_INITIAL_EVENT) != null) {
|
||||||
initialEvent = (String) cc.getSessionData(CK.Q_INITIAL_EVENT);
|
initialEvent = (String) cc.getSessionData(CK.Q_INITIAL_EVENT);
|
||||||
|
@ -44,10 +44,13 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
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 com.alessiodp.parties.api.interfaces.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import de.erethon.dungeonsxl.player.DGroup;
|
import de.erethon.dungeonsxl.player.DGroup;
|
||||||
import me.blackvein.quests.events.quest.QuestTakeEvent;
|
import me.blackvein.quests.events.quest.QuestTakeEvent;
|
||||||
@ -405,9 +408,9 @@ public class Quester {
|
|||||||
* Start a quest for this Quester
|
* Start a quest for this Quester
|
||||||
*
|
*
|
||||||
* @param q The quest to start
|
* @param q The quest to start
|
||||||
* @param override Whether to ignore Requirements
|
* @param ignoreReqs Whether to ignore Requirements
|
||||||
*/
|
*/
|
||||||
public void takeQuest(Quest q, boolean override) {
|
public void takeQuest(Quest q, boolean ignoreReqs) {
|
||||||
if (q == null) {
|
if (q == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -487,7 +490,7 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.testRequirements(player) == true || override) {
|
if (q.testRequirements(player) == true || ignoreReqs) {
|
||||||
addEmptiesFor(q, 0);
|
addEmptiesFor(q, 0);
|
||||||
try {
|
try {
|
||||||
currentQuests.put(q, 0);
|
currentQuests.put(q, 0);
|
||||||
@ -496,8 +499,8 @@ public class Quester {
|
|||||||
+ ". Consider resetting player data or report on Github");
|
+ ". Consider resetting player data or report on Github");
|
||||||
}
|
}
|
||||||
Stage stage = q.getStage(0);
|
Stage stage = q.getStage(0);
|
||||||
Requirements reqs = q.getRequirements();
|
if (!ignoreReqs) {
|
||||||
if (!override) {
|
Requirements reqs = q.getRequirements();
|
||||||
if (reqs.getMoney() > 0) {
|
if (reqs.getMoney() > 0) {
|
||||||
if (plugin.getDependencies().getVaultEconomy() != null) {
|
if (plugin.getDependencies().getVaultEconomy() != null) {
|
||||||
plugin.getDependencies().getVaultEconomy().withdrawPlayer(getOfflinePlayer(), reqs.getMoney());
|
plugin.getDependencies().getVaultEconomy().withdrawPlayer(getOfflinePlayer(), reqs.getMoney());
|
||||||
@ -556,7 +559,10 @@ public class Quester {
|
|||||||
saveData();
|
saveData();
|
||||||
} else {
|
} else {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
((Player)player).sendMessage(q.getRequirements().getFailRequirements());
|
((Player)player).sendMessage(ChatColor.DARK_AQUA + Lang.get("requirements"));
|
||||||
|
for (String s : getCurrentRequirements(q, false)) {
|
||||||
|
((Player)player).sendMessage(ChatColor.GRAY + "- " + s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
@ -565,15 +571,141 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedList<String> getCurrentRequirements(Quest quest, boolean ignoreOverrides) {
|
||||||
|
if (quest == null) {
|
||||||
|
return new LinkedList<String>();
|
||||||
|
}
|
||||||
|
Requirements reqs = quest.getRequirements();
|
||||||
|
if (!ignoreOverrides) {
|
||||||
|
if (reqs.getFailRequirements() != null) {
|
||||||
|
LinkedList<String> requirements = new LinkedList<String>();
|
||||||
|
String message = ChatColor.RED + ConfigUtil.parseString(
|
||||||
|
ChatColor.translateAlternateColorCodes('&', reqs.getFailRequirements()),
|
||||||
|
quest, getPlayer());
|
||||||
|
if (plugin.getDependencies().getPlaceholderApi() != null) {
|
||||||
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
|
}
|
||||||
|
requirements.add(message);
|
||||||
|
return requirements;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LinkedList<String> unfinishedRequirements = new LinkedList<String>();
|
||||||
|
LinkedList<String> finishedRequirements = new LinkedList<String>();
|
||||||
|
LinkedList<String> requirements = new LinkedList<String>();
|
||||||
|
OfflinePlayer player = getPlayer();
|
||||||
|
if (reqs.getMoney() > 0) {
|
||||||
|
if (plugin.getDependencies().getVaultEconomy() != null
|
||||||
|
&& plugin.getDependencies().getVaultEconomy().getBalance(player) >= reqs.getMoney()) {
|
||||||
|
unfinishedRequirements.add(ChatColor.GREEN + "" + reqs.getMoney() + " " + Lang.get("money"));
|
||||||
|
} else {
|
||||||
|
finishedRequirements.add(ChatColor.GRAY + "" + reqs.getMoney() + " " + Lang.get("money"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reqs.getQuestPoints() > 0) {
|
||||||
|
if (getQuestPoints() >= reqs.getQuestPoints()) {
|
||||||
|
unfinishedRequirements.add(ChatColor.GREEN + "" + reqs.getQuestPoints() + " "
|
||||||
|
+ Lang.get("questPoints"));
|
||||||
|
} else {
|
||||||
|
finishedRequirements.add(ChatColor.GRAY + "" + reqs.getQuestPoints() + " " + Lang.get("questPoints"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String name : reqs.getNeededQuests()) {
|
||||||
|
if (getCompletedQuests().contains(name)) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + name);
|
||||||
|
} else {
|
||||||
|
unfinishedRequirements.add(ChatColor.GRAY + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String name : reqs.getBlockQuests()) {
|
||||||
|
Quest questObject = new Quest();
|
||||||
|
questObject.setName(name);
|
||||||
|
if (completedQuests.contains(name) || currentQuests.containsKey(questObject)) {
|
||||||
|
requirements.add(ChatColor.RED + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String s : reqs.getMcmmoSkills()) {
|
||||||
|
final SkillType st = Quests.getMcMMOSkill(s);
|
||||||
|
final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s));
|
||||||
|
if (UserManager.getOfflinePlayer(player).getProfile().getSkillLevel(st) >= lvl) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + "" + lvl + " " + s);
|
||||||
|
} else {
|
||||||
|
unfinishedRequirements.add(ChatColor.GRAY + "" + lvl + " " + s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reqs.getHeroesPrimaryClass() != null) {
|
||||||
|
if (plugin.getDependencies()
|
||||||
|
.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + Lang.get("reqHeroesPrimaryDisplay") + " "
|
||||||
|
+ reqs.getHeroesPrimaryClass());
|
||||||
|
} else {
|
||||||
|
unfinishedRequirements.add(ChatColor.GRAY + Lang.get("reqHeroesPrimaryDisplay") + " "
|
||||||
|
+ reqs.getHeroesPrimaryClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reqs.getHeroesSecondaryClass() != null) {
|
||||||
|
if (plugin.getDependencies()
|
||||||
|
.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + Lang.get("reqHeroesSecondaryDisplay") + " "
|
||||||
|
+ reqs.getHeroesSecondaryClass());
|
||||||
|
} else {
|
||||||
|
finishedRequirements.add(ChatColor.GRAY + Lang.get("reqHeroesSecondaryDisplay") + " "
|
||||||
|
+ reqs.getHeroesSecondaryClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (player.isOnline()) {
|
||||||
|
PlayerInventory inventory = getPlayer().getInventory();
|
||||||
|
int num = 0;
|
||||||
|
for (ItemStack is : reqs.getItems()) {
|
||||||
|
for (ItemStack stack : inventory.getContents()) {
|
||||||
|
if (stack != null) {
|
||||||
|
if (ItemUtil.compareItems(is, stack, true) == 0) {
|
||||||
|
num += stack.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (num >= is.getAmount()) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + "" + is.getAmount() + " " + ItemUtil.getName(is));
|
||||||
|
} else {
|
||||||
|
unfinishedRequirements.add(ChatColor.GRAY + "" + is.getAmount() + " " + ItemUtil.getName(is));
|
||||||
|
}
|
||||||
|
num = 0;
|
||||||
|
}
|
||||||
|
for (String perm :reqs.getPermissions()) {
|
||||||
|
if (getPlayer().hasPermission(perm)) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm);
|
||||||
|
} else {
|
||||||
|
unfinishedRequirements.add(ChatColor.GRAY + Lang.get("permissionDisplay") + " " + perm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
for (Entry<String, Map<String, Object>> m : reqs.getCustomRequirements().entrySet()) {
|
||||||
|
for (CustomRequirement cr : plugin.getCustomRequirements()) {
|
||||||
|
if (cr.getName().equalsIgnoreCase(m.getKey())) {
|
||||||
|
if (cr != null) {
|
||||||
|
if (cr.testRequirement(getPlayer(), m.getValue())) {
|
||||||
|
finishedRequirements.add(ChatColor.GREEN + "" + m.getKey());
|
||||||
|
} else {
|
||||||
|
unfinishedRequirements.add(ChatColor.GRAY + "" + m.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requirements.addAll(unfinishedRequirements);
|
||||||
|
requirements.addAll(finishedRequirements);
|
||||||
|
return requirements;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all objectives for a quest
|
* Get current objectives for a quest, both finished and unfinished
|
||||||
*
|
*
|
||||||
* @param quest The quest to get objectives of
|
* @param quest The quest to get objectives of
|
||||||
* @param ignoreOverrides Whether to ignore objective-overrides
|
* @param ignoreOverrides Whether to ignore objective-overrides
|
||||||
* @return List of detailed objectives
|
* @return List of detailed objectives
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public LinkedList<String> getObjectives(Quest quest, boolean ignoreOverrides) {
|
public LinkedList<String> getCurrentObjectives(Quest quest, boolean ignoreOverrides) {
|
||||||
if (!ignoreOverrides) {
|
if (!ignoreOverrides) {
|
||||||
if (getCurrentStage(quest) != null) {
|
if (getCurrentStage(quest) != null) {
|
||||||
if (getCurrentStage(quest).objectiveOverride != null) {
|
if (getCurrentStage(quest).objectiveOverride != null) {
|
||||||
@ -993,22 +1125,17 @@ public class Quester {
|
|||||||
objectives.addAll(finishedObjectives);
|
objectives.addAll(finishedObjectives);
|
||||||
return objectives;
|
return objectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if player's current stage has the specified objective<p>
|
* Get current objectives for a quest, both finished and unfinished
|
||||||
*
|
*
|
||||||
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
* @deprecated Use {@link #getCurrentObjectives(Quest, boolean)}
|
||||||
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, milkCow, catchFish,
|
* @param quest The quest to get objectives of
|
||||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
* @param ignoreOverrides Whether to ignore objective-overrides
|
||||||
* shearSheep, password, reachLocation
|
* @return List of detailed objectives
|
||||||
*
|
|
||||||
* @deprecated Use containsObjective() instead
|
|
||||||
* @param quest The quest to check objectives of
|
|
||||||
* @param s The type of objective to check for
|
|
||||||
* @return true if quest contains specified objective
|
|
||||||
*/
|
*/
|
||||||
public boolean hasObjective(Quest quest, String s) {
|
public LinkedList<String> getObjectives(Quest quest, boolean ignoreOverrides) {
|
||||||
return containsObjective(quest, s);
|
return getCurrentObjectives(quest, ignoreOverrides);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1019,57 +1146,13 @@ public class Quester {
|
|||||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
||||||
* shearSheep, password, reachLocation
|
* shearSheep, password, reachLocation
|
||||||
*
|
*
|
||||||
|
* @deprecated Use {@link Stage#containsObjective(String)}
|
||||||
* @param quest The quest to check objectives of
|
* @param quest The quest to check objectives of
|
||||||
* @param s The type of objective to check for
|
* @param s The type of objective to check for
|
||||||
* @return true if quest contains specified objective
|
* @return true if quest contains specified objective
|
||||||
*/
|
*/
|
||||||
public boolean containsObjective(Quest quest, String s) {
|
public boolean containsObjective(Quest quest, String s) {
|
||||||
if (getCurrentStage(quest) == null) {
|
return getCurrentStage(quest).containsObjective(s);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (s.equalsIgnoreCase("breakBlock")) {
|
|
||||||
return !getCurrentStage(quest).blocksToBreak.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("damageBlock")) {
|
|
||||||
return !getCurrentStage(quest).blocksToDamage.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("placeBlock")) {
|
|
||||||
return !getCurrentStage(quest).blocksToPlace.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("useBlock")) {
|
|
||||||
return !getCurrentStage(quest).blocksToUse.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("cutBlock")) {
|
|
||||||
return !getCurrentStage(quest).blocksToCut.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("craftItem")) {
|
|
||||||
return !getCurrentStage(quest).itemsToCraft.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("smeltItem")) {
|
|
||||||
return !getCurrentStage(quest).itemsToSmelt.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("enchantItem")) {
|
|
||||||
return !getCurrentStage(quest).itemsToEnchant.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("brewItem")) {
|
|
||||||
return !getCurrentStage(quest).itemsToBrew.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("milkCow")) {
|
|
||||||
return getCurrentStage(quest).cowsToMilk != null;
|
|
||||||
} else if (s.equalsIgnoreCase("catchFish")) {
|
|
||||||
return getCurrentStage(quest).fishToCatch != null;
|
|
||||||
} else if (s.equalsIgnoreCase("killMob")) {
|
|
||||||
return !getCurrentStage(quest).mobsToKill.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("deliverItem")) {
|
|
||||||
return !getCurrentStage(quest).itemsToDeliver.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("killPlayer")) {
|
|
||||||
return getCurrentStage(quest).playersToKill != null;
|
|
||||||
} else if (s.equalsIgnoreCase("talkToNPC")) {
|
|
||||||
return !getCurrentStage(quest).citizensToInteract.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("killNPC")) {
|
|
||||||
return !getCurrentStage(quest).citizensToKill.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("tameMob")) {
|
|
||||||
return !getCurrentStage(quest).mobsToTame.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("shearSheep")) {
|
|
||||||
return !getCurrentStage(quest).sheepToShear.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("password")) {
|
|
||||||
return !getCurrentStage(quest).passwordPhrases.isEmpty();
|
|
||||||
} else if (s.equalsIgnoreCase("reachLocation")) {
|
|
||||||
return !getCurrentStage(quest).locationsToReach.isEmpty();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCustomObjective(Quest quest, String s) {
|
public boolean hasCustomObjective(Quest quest, String s) {
|
||||||
|
@ -1694,10 +1694,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
String questKey) throws QuestFormatException {
|
String questKey) throws QuestFormatException {
|
||||||
Requirements reqs = quest.getRequirements();
|
Requirements reqs = quest.getRequirements();
|
||||||
if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) {
|
if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) {
|
||||||
reqs.setFailRequirements(parseString(config.getString("quests." + questKey
|
reqs.setFailRequirements(ConfigUtil.parseString(config.getString("quests." + questKey
|
||||||
+ ".requirements.fail-requirement-message"), quest));
|
+ ".requirements.fail-requirement-message"), quest));
|
||||||
} else {
|
|
||||||
skipQuestProcess("Requirement fail-requirement-message is missing", questKey);
|
|
||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".requirements.items")) {
|
if (config.contains("quests." + questKey + ".requirements.items")) {
|
||||||
List<ItemStack> temp = reqs.getItems(); // TODO - should maybe be = new LinkedList<ItemStack>() ?
|
List<ItemStack> temp = reqs.getItems(); // TODO - should maybe be = new LinkedList<ItemStack>() ?
|
||||||
|
@ -538,4 +538,61 @@ public class Stage {
|
|||||||
if (customObjectives.isEmpty() == false) { return true; }
|
if (customObjectives.isEmpty() == false) { return true; }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if stage has the specified objective<p>
|
||||||
|
*
|
||||||
|
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
||||||
|
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, milkCow, catchFish,
|
||||||
|
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
||||||
|
* shearSheep, password, reachLocation
|
||||||
|
*
|
||||||
|
* @param type The type of objective to check for
|
||||||
|
* @return true if stage contains specified objective
|
||||||
|
*/
|
||||||
|
public boolean containsObjective(String type) {
|
||||||
|
if (type.equalsIgnoreCase("breakBlock")) {
|
||||||
|
return !blocksToBreak.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("damageBlock")) {
|
||||||
|
return !blocksToDamage.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("placeBlock")) {
|
||||||
|
return !blocksToPlace.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("useBlock")) {
|
||||||
|
return !blocksToUse.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("cutBlock")) {
|
||||||
|
return !blocksToCut.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("craftItem")) {
|
||||||
|
return !itemsToCraft.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("smeltItem")) {
|
||||||
|
return !itemsToSmelt.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("enchantItem")) {
|
||||||
|
return !itemsToEnchant.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("brewItem")) {
|
||||||
|
return !itemsToBrew.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("milkCow")) {
|
||||||
|
return cowsToMilk != null;
|
||||||
|
} else if (type.equalsIgnoreCase("catchFish")) {
|
||||||
|
return fishToCatch != null;
|
||||||
|
} else if (type.equalsIgnoreCase("killMob")) {
|
||||||
|
return !mobsToKill.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("deliverItem")) {
|
||||||
|
return !itemsToDeliver.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("killPlayer")) {
|
||||||
|
return playersToKill != null;
|
||||||
|
} else if (type.equalsIgnoreCase("talkToNPC")) {
|
||||||
|
return !citizensToInteract.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("killNPC")) {
|
||||||
|
return !citizensToKill.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("tameMob")) {
|
||||||
|
return !mobsToTame.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("shearSheep")) {
|
||||||
|
return !sheepToShear.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("password")) {
|
||||||
|
return !passwordPhrases.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("reachLocation")) {
|
||||||
|
return !locationsToReach.isEmpty();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class NpcListener implements Listener {
|
|||||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
boolean delivery = false;
|
boolean delivery = false;
|
||||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||||
if (quester.containsObjective(quest, "deliverItem") && player.getItemInHand() != null) {
|
if (quester.getCurrentStage(quest).containsObjective("deliverItem") && player.getItemInHand() != null) {
|
||||||
ItemStack hand = player.getItemInHand();
|
ItemStack hand = player.getItemInHand();
|
||||||
int currentIndex = -1;
|
int currentIndex = -1;
|
||||||
LinkedList<Integer> matches = new LinkedList<Integer>();
|
LinkedList<Integer> matches = new LinkedList<Integer>();
|
||||||
@ -184,7 +184,7 @@ public class NpcListener implements Listener {
|
|||||||
if (plugin.getQuestNpcs().contains(evt.getNPC()) && delivery == false) {
|
if (plugin.getQuestNpcs().contains(evt.getNPC()) && delivery == false) {
|
||||||
boolean hasObjective = false;
|
boolean hasObjective = false;
|
||||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||||
if (quester.containsObjective(quest, "talkToNPC")) {
|
if (quester.getCurrentStage(quest).containsObjective("talkToNPC")) {
|
||||||
if (quester.getQuestData(quest) != null
|
if (quester.getQuestData(quest) != null
|
||||||
&& quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId())
|
&& quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId())
|
||||||
&& quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) {
|
&& quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) {
|
||||||
@ -319,7 +319,7 @@ public class NpcListener implements Listener {
|
|||||||
if (okay) {
|
if (okay) {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||||
if (quester.containsObjective(quest, "killNPC")) {
|
if (quester.getCurrentStage(quest).containsObjective("killNPC")) {
|
||||||
quester.killNPC(quest, evt.getNPC());
|
quester.killNPC(quest, evt.getNPC());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ public class NpcListener implements Listener {
|
|||||||
Player player = (Player) damager;
|
Player player = (Player) damager;
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||||
if (quester.containsObjective(quest, "killNPC")) {
|
if (quester.getCurrentStage(quest).containsObjective("killNPC")) {
|
||||||
quester.killNPC(quest, evt.getNPC());
|
quester.killNPC(quest, evt.getNPC());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ public class PlayerListener implements Listener {
|
|||||||
.getClickedBlock().getState().getData().toItemStack().getDurability());
|
.getClickedBlock().getState().getData().toItemStack().getDurability());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "useBlock")) {
|
&& quester.getCurrentStage(quest).containsObjective("useBlock")) {
|
||||||
quester.useBlock(quest, blockItemStack);
|
quester.useBlock(quest, blockItemStack);
|
||||||
hasObjective = true;
|
hasObjective = true;
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.canUseQuests(player.getUniqueId())) {
|
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "milkCow")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("milkCow")) {
|
||||||
quester.milkCow(quest);
|
quester.milkCow(quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quester.containsObjective(quest, "password")) {
|
if (quester.getCurrentStage(quest).containsObjective("password")) {
|
||||||
quester.sayPassword(quest, evt);
|
quester.sayPassword(quest, evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,7 +502,7 @@ public class PlayerListener implements Listener {
|
|||||||
.getData().toItemStack().getDurability());
|
.getData().toItemStack().getDurability());
|
||||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "damageBlock")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("damageBlock")) {
|
||||||
quester.damageBlock(quest, blockItemStack);
|
quester.damageBlock(quest, blockItemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +524,7 @@ public class PlayerListener implements Listener {
|
|||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (evt.isCancelled() == false) {
|
if (evt.isCancelled() == false) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "placeBlock")) {
|
&& quester.getCurrentStage(quest).containsObjective("placeBlock")) {
|
||||||
quester.placeBlock(quest, blockItemStack);
|
quester.placeBlock(quest, blockItemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +547,7 @@ public class PlayerListener implements Listener {
|
|||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (evt.isCancelled() == false) {
|
if (evt.isCancelled() == false) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "breakBlock")) {
|
&& quester.getCurrentStage(quest).containsObjective("breakBlock")) {
|
||||||
if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
quester.breakBlock(quest, blockItemStack);
|
quester.breakBlock(quest, blockItemStack);
|
||||||
}
|
}
|
||||||
@ -559,7 +559,7 @@ public class PlayerListener implements Listener {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "placeBlock")) {
|
&& quester.getCurrentStage(quest).containsObjective("placeBlock")) {
|
||||||
for (ItemStack is : quester.getQuestData(quest).blocksPlaced) {
|
for (ItemStack is : quester.getQuestData(quest).blocksPlaced) {
|
||||||
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
|
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
|
||||||
int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
|
int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
|
||||||
@ -578,7 +578,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "cutBlock")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("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);
|
||||||
}
|
}
|
||||||
@ -602,7 +602,7 @@ public class PlayerListener implements Listener {
|
|||||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "shearSheep")) {
|
&& quester.getCurrentStage(quest).containsObjective("shearSheep")) {
|
||||||
quester.shearSheep(quest, sheep.getColor());
|
quester.shearSheep(quest, sheep.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,7 +622,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.canUseQuests(p.getUniqueId())) {
|
if (plugin.canUseQuests(p.getUniqueId())) {
|
||||||
Quester quester = plugin.getQuester(p.getUniqueId());
|
Quester quester = plugin.getQuester(p.getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "tameMob")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("tameMob")) {
|
||||||
quester.tameMob(quest, evt.getEntityType());
|
quester.tameMob(quest, evt.getEntityType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ public class PlayerListener implements Listener {
|
|||||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "craftItem")) {
|
&& quester.getCurrentStage(quest).containsObjective("craftItem")) {
|
||||||
quester.craftItem(quest, craftedItem);
|
quester.craftItem(quest, craftedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ public class PlayerListener implements Listener {
|
|||||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "smeltItem")) {
|
&& quester.getCurrentStage(quest).containsObjective("smeltItem")) {
|
||||||
quester.smeltItem(quest, evt.getCurrentItem());
|
quester.smeltItem(quest, evt.getCurrentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ public class PlayerListener implements Listener {
|
|||||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "brewItem")) {
|
&& quester.getCurrentStage(quest).containsObjective("brewItem")) {
|
||||||
quester.brewItem(quest, evt.getCurrentItem());
|
quester.brewItem(quest, evt.getCurrentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +725,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
|
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
|
||||||
Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
|
Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "enchantItem")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("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());
|
||||||
}
|
}
|
||||||
@ -789,7 +789,7 @@ public class PlayerListener implements Listener {
|
|||||||
Quester quester = plugin.getQuester(damager.getUniqueId());
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killNPC")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("killNPC")) {
|
||||||
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killMob")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("killMob")) {
|
||||||
quester.killMob(quest, target.getLocation(), target.getType());
|
quester.killMob(quest, target.getLocation(), target.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,7 +896,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
Quester quester = plugin.getQuester(damager.getUniqueId());
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killPlayer")) {
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("killPlayer")) {
|
||||||
quester.killPlayer(quest, (Player)target);
|
quester.killPlayer(quest, (Player)target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,7 +914,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.canUseQuests(player.getUniqueId())) {
|
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "catchFish")
|
if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective("catchFish")
|
||||||
&& evt.getState().equals(State.CAUGHT_FISH)) {
|
&& evt.getState().equals(State.CAUGHT_FISH)) {
|
||||||
quester.catchFish(quest);
|
quester.catchFish(quest);
|
||||||
}
|
}
|
||||||
@ -1061,7 +1061,7 @@ public class PlayerListener implements Listener {
|
|||||||
Quester quester = plugin.getQuester(uuid);
|
Quester quester = plugin.getQuester(uuid);
|
||||||
for (Quest quest : plugin.getQuests()) {
|
for (Quest quest : plugin.getQuests()) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
&& quester.containsObjective(quest, "reachLocation")) {
|
&& quester.getCurrentStage(quest).containsObjective("reachLocation")) {
|
||||||
quester.reachLocation(quest, location);
|
quester.reachLocation(quest, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ public class RequirementsPrompt extends NumericPrompt {
|
|||||||
|
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private final QuestFactory factory;
|
private final QuestFactory factory;
|
||||||
|
private boolean hasRequirement = false;
|
||||||
private final int size = 11;
|
private final int size = 11;
|
||||||
|
|
||||||
public RequirementsPrompt(Quests plugin, QuestFactory qf) {
|
public RequirementsPrompt(Quests plugin, QuestFactory qf) {
|
||||||
@ -84,19 +85,8 @@ public class RequirementsPrompt extends NumericPrompt {
|
|||||||
case 9:
|
case 9:
|
||||||
return ChatColor.BLUE;
|
return ChatColor.BLUE;
|
||||||
case 10:
|
case 10:
|
||||||
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null
|
if (!hasRequirement) {
|
||||||
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null
|
|
||||||
&& context.getSessionData(CK.REQ_ITEMS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_PERMISSION) == null
|
|
||||||
&& context.getSessionData(CK.REQ_QUEST) == null
|
|
||||||
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null
|
|
||||||
&& context.getSessionData(CK.REQ_MCMMO_SKILLS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_CUSTOM) == null) {
|
|
||||||
return ChatColor.GRAY;
|
return ChatColor.GRAY;
|
||||||
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
|
|
||||||
return ChatColor.RED;
|
|
||||||
} else {
|
} else {
|
||||||
return ChatColor.BLUE;
|
return ChatColor.BLUE;
|
||||||
}
|
}
|
||||||
@ -128,19 +118,8 @@ public class RequirementsPrompt extends NumericPrompt {
|
|||||||
case 9:
|
case 9:
|
||||||
return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom");
|
return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom");
|
||||||
case 10:
|
case 10:
|
||||||
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null
|
if (!hasRequirement) {
|
||||||
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null
|
|
||||||
&& context.getSessionData(CK.REQ_ITEMS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_PERMISSION) == null
|
|
||||||
&& context.getSessionData(CK.REQ_QUEST) == null
|
|
||||||
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null
|
|
||||||
&& context.getSessionData(CK.REQ_MCMMO_SKILLS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_CUSTOM) == null) {
|
|
||||||
return ChatColor.GRAY + Lang.get("reqSetFail");
|
return ChatColor.GRAY + Lang.get("reqSetFail");
|
||||||
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
|
|
||||||
return ChatColor.RED + Lang.get("reqSetFail");
|
|
||||||
} else {
|
} else {
|
||||||
return ChatColor.YELLOW + Lang.get("reqSetFail");
|
return ChatColor.YELLOW + Lang.get("reqSetFail");
|
||||||
}
|
}
|
||||||
@ -266,22 +245,15 @@ public class RequirementsPrompt extends NumericPrompt {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null
|
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) == null) {
|
||||||
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null
|
if (!hasRequirement) {
|
||||||
&& context.getSessionData(CK.REQ_ITEMS) == null
|
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
|
||||||
&& context.getSessionData(CK.REQ_PERMISSION) == null
|
} else {
|
||||||
&& context.getSessionData(CK.REQ_QUEST) == null
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null
|
}
|
||||||
&& context.getSessionData(CK.REQ_MCMMO_SKILLS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null
|
|
||||||
&& context.getSessionData(CK.REQ_CUSTOM) == null) {
|
|
||||||
return ChatColor.GRAY + "(" + Lang.get("reqNone") + ")";
|
|
||||||
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
|
|
||||||
return ChatColor.RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
|
||||||
} else {
|
} else {
|
||||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE)
|
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.REQ_FAIL_MESSAGE)
|
||||||
+ "\"" + ChatColor.GRAY + ")";
|
+ "\"" + ChatColor.GRAY + ")";
|
||||||
}
|
}
|
||||||
case 11:
|
case 11:
|
||||||
case 12:
|
case 12:
|
||||||
@ -340,27 +312,33 @@ public class RequirementsPrompt extends NumericPrompt {
|
|||||||
case 9:
|
case 9:
|
||||||
return new CustomRequirementsPrompt();
|
return new CustomRequirementsPrompt();
|
||||||
case 10:
|
case 10:
|
||||||
return new FailMessagePrompt();
|
if (hasRequirement) {
|
||||||
case 11:
|
return new FailMessagePrompt();
|
||||||
if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null
|
} else {
|
||||||
|| context.getSessionData(CK.REQ_ITEMS) != null
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
||||||
|| context.getSessionData(CK.REQ_PERMISSION) != null
|
return new RequirementsPrompt(plugin, factory);
|
||||||
|| context.getSessionData(CK.REQ_QUEST) != null
|
|
||||||
|| context.getSessionData(CK.REQ_QUEST_BLOCK) != null
|
|
||||||
|| context.getSessionData(CK.REQ_MCMMO_SKILLS) != null
|
|
||||||
|| context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null
|
|
||||||
|| context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null
|
|
||||||
|| context.getSessionData(CK.REQ_CUSTOM) != null) {
|
|
||||||
if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage"));
|
|
||||||
return new RequirementsPrompt(plugin, factory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case 11:
|
||||||
return factory.returnToMenu();
|
return factory.returnToMenu();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkRequirement(ConversationContext context) {
|
||||||
|
if (context.getSessionData(CK.REQ_MONEY) != null
|
||||||
|
|| context.getSessionData(CK.REQ_QUEST_POINTS) != null
|
||||||
|
|| context.getSessionData(CK.REQ_ITEMS) != null
|
||||||
|
|| context.getSessionData(CK.REQ_PERMISSION) != null
|
||||||
|
|| context.getSessionData(CK.REQ_QUEST) != null
|
||||||
|
|| context.getSessionData(CK.REQ_QUEST_BLOCK) != null
|
||||||
|
|| context.getSessionData(CK.REQ_MCMMO_SKILLS) != null
|
||||||
|
|| context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null
|
||||||
|
|| context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null
|
||||||
|
|| context.getSessionData(CK.REQ_CUSTOM) != null) {
|
||||||
|
hasRequirement = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class MoneyPrompt extends StringPrompt {
|
private class MoneyPrompt extends StringPrompt {
|
||||||
|
|
||||||
@ -1189,7 +1167,7 @@ public class RequirementsPrompt extends NumericPrompt {
|
|||||||
@Override
|
@Override
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
if (input.equalsIgnoreCase(Lang.get(Lang.get("cancel"))) == false) {
|
if (input.equalsIgnoreCase(Lang.get(Lang.get("cancel"))) == false) {
|
||||||
context.setSessionData(CK.Q_FAIL_MESSAGE, input);
|
context.setSessionData(CK.REQ_FAIL_MESSAGE, input);
|
||||||
}
|
}
|
||||||
return new RequirementsPrompt(plugin, factory);
|
return new RequirementsPrompt(plugin, factory);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ public class CK {
|
|||||||
public static final String Q_FINISH_MESSAGE = "finishMessage";
|
public static final String Q_FINISH_MESSAGE = "finishMessage";
|
||||||
public static final String Q_START_NPC = "npcStart";
|
public static final String Q_START_NPC = "npcStart";
|
||||||
public static final String Q_START_BLOCK = "blockStart";
|
public static final String Q_START_BLOCK = "blockStart";
|
||||||
public static final String Q_FAIL_MESSAGE = "failMessage";
|
|
||||||
public static final String Q_INITIAL_EVENT = "initialEvent";
|
public static final String Q_INITIAL_EVENT = "initialEvent";
|
||||||
public static final String Q_REGION = "region";
|
public static final String Q_REGION = "region";
|
||||||
public static final String Q_GUIDISPLAY = "guiDisplay";
|
public static final String Q_GUIDISPLAY = "guiDisplay";
|
||||||
@ -44,6 +43,7 @@ public class CK {
|
|||||||
public static final String REQ_CUSTOM_DATA = "customReqData";
|
public static final String REQ_CUSTOM_DATA = "customReqData";
|
||||||
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
||||||
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
||||||
|
public static final String REQ_FAIL_MESSAGE = "failMessage";
|
||||||
// Stages
|
// Stages
|
||||||
public static final String S_BREAK_NAMES = "breakNames";
|
public static final String S_BREAK_NAMES = "breakNames";
|
||||||
public static final String S_BREAK_AMOUNTS = "breakAmounts";
|
public static final String S_BREAK_AMOUNTS = "breakAmounts";
|
||||||
@ -102,7 +102,6 @@ public class CK {
|
|||||||
public static final String S_DENIZEN = "denizen"; // Legacy
|
public static final String S_DENIZEN = "denizen"; // Legacy
|
||||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||||
public static final String S_START_MESSAGE = "startMessage";
|
public static final String S_START_MESSAGE = "startMessage";
|
||||||
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
|
||||||
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
|
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
|
||||||
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
|
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
|
||||||
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
|
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
|
||||||
@ -110,6 +109,7 @@ public class CK {
|
|||||||
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";
|
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";
|
||||||
public static final String S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS = "customObjectiveDataDescriptions";
|
public static final String S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS = "customObjectiveDataDescriptions";
|
||||||
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
|
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
|
||||||
|
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
||||||
// Rewards
|
// Rewards
|
||||||
public static final String REW_MONEY = "moneyRew";
|
public static final String REW_MONEY = "moneyRew";
|
||||||
public static final String REW_QUEST_POINTS = "questPointsRew";
|
public static final String REW_QUEST_POINTS = "questPointsRew";
|
||||||
|
@ -448,7 +448,6 @@ reqHeroesPrimaryCleared: "Heroes Primary Class requirement cleared."
|
|||||||
reqHeroesNotSecondary: "The <class> class is not secondary!"
|
reqHeroesNotSecondary: "The <class> class is not secondary!"
|
||||||
reqHeroesSecondaryCleared: "Heroes Secondary Class requirement cleared."
|
reqHeroesSecondaryCleared: "Heroes Secondary Class requirement cleared."
|
||||||
reqHeroesClassNotFound: "Class not found!"
|
reqHeroesClassNotFound: "Class not found!"
|
||||||
reqNone: "No requirements set"
|
|
||||||
reqNotANumber: "<input> is not a number!"
|
reqNotANumber: "<input> is not a number!"
|
||||||
reqMustAddItem: "You must add at least one item first!"
|
reqMustAddItem: "You must add at least one item first!"
|
||||||
reqNoMessage: "You must set a fail requirements message!"
|
reqNoMessage: "You must set a fail requirements message!"
|
||||||
|
Loading…
Reference in New Issue
Block a user