Make fail requirements message optional and list reqs instead by default

This commit is contained in:
PikaMug 2020-01-24 04:30:03 -05:00
parent 26a822d0d3
commit f0df8db84d
10 changed files with 287 additions and 172 deletions

View File

@ -364,6 +364,19 @@ public class Quest {
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()) {
final SkillType st = Quests.getMcMMOSkill(s);
final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s));
@ -383,19 +396,6 @@ public class Quest {
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()) {
Player p = (Player)player;
PlayerInventory inventory = p.getInventory();

View File

@ -611,9 +611,6 @@ public class QuestFactory implements ConversationAbandonedListener {
if (reqs.getHeroesSecondaryClass() != null) {
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) {
LinkedList<String> list = new LinkedList<String>();
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_DATA, datamapList);
}
if (reqs.getFailRequirements() != null) {
cc.setSessionData(CK.REQ_FAIL_MESSAGE, reqs.getFailRequirements());
}
Rewards rews = q.getRewards();
if (rews.getMoney() != 0) {
cc.setSessionData(CK.REW_MONEY, rews.getMoney());
@ -929,15 +929,15 @@ public class QuestFactory implements ConversationAbandonedListener {
if (stage.script != null) {
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) {
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.completeMessage);
}
if (stage.startMessage != null) {
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);
customReqsData = (LinkedList<Map<String, Object>>) cc.getSessionData(CK.REQ_CUSTOM_DATA);
}
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
failMessage = (String) cc.getSessionData(CK.Q_FAIL_MESSAGE);
if (cc.getSessionData(CK.REQ_FAIL_MESSAGE) != null) {
failMessage = (String) cc.getSessionData(CK.REQ_FAIL_MESSAGE);
}
if (cc.getSessionData(CK.Q_INITIAL_EVENT) != null) {
initialEvent = (String) cc.getSessionData(CK.Q_INITIAL_EVENT);

View File

@ -44,10 +44,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta;
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 me.blackvein.quests.events.quest.QuestTakeEvent;
@ -405,9 +408,9 @@ public class Quester {
* Start a quest for this Quester
*
* @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) {
return;
}
@ -487,7 +490,7 @@ public class Quester {
}
}
}
if (q.testRequirements(player) == true || override) {
if (q.testRequirements(player) == true || ignoreReqs) {
addEmptiesFor(q, 0);
try {
currentQuests.put(q, 0);
@ -496,8 +499,8 @@ public class Quester {
+ ". Consider resetting player data or report on Github");
}
Stage stage = q.getStage(0);
Requirements reqs = q.getRequirements();
if (!override) {
if (!ignoreReqs) {
Requirements reqs = q.getRequirements();
if (reqs.getMoney() > 0) {
if (plugin.getDependencies().getVaultEconomy() != null) {
plugin.getDependencies().getVaultEconomy().withdrawPlayer(getOfflinePlayer(), reqs.getMoney());
@ -556,7 +559,10 @@ public class Quester {
saveData();
} else {
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()) {
@ -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 ignoreOverrides Whether to ignore objective-overrides
* @return List of detailed objectives
*/
@SuppressWarnings("deprecation")
public LinkedList<String> getObjectives(Quest quest, boolean ignoreOverrides) {
public LinkedList<String> getCurrentObjectives(Quest quest, boolean ignoreOverrides) {
if (!ignoreOverrides) {
if (getCurrentStage(quest) != null) {
if (getCurrentStage(quest).objectiveOverride != null) {
@ -993,22 +1125,17 @@ public class Quester {
objectives.addAll(finishedObjectives);
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,
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, milkCow, catchFish,
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
* shearSheep, password, reachLocation
*
* @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
* @deprecated Use {@link #getCurrentObjectives(Quest, boolean)}
* @param quest The quest to get objectives of
* @param ignoreOverrides Whether to ignore objective-overrides
* @return List of detailed objectives
*/
public boolean hasObjective(Quest quest, String s) {
return containsObjective(quest, s);
public LinkedList<String> getObjectives(Quest quest, boolean ignoreOverrides) {
return getCurrentObjectives(quest, ignoreOverrides);
}
/**
@ -1019,57 +1146,13 @@ public class Quester {
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
* shearSheep, password, reachLocation
*
* @deprecated Use {@link Stage#containsObjective(String)}
* @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 containsObjective(Quest quest, String s) {
if (getCurrentStage(quest) == null) {
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;
}
return getCurrentStage(quest).containsObjective(s);
}
public boolean hasCustomObjective(Quest quest, String s) {

View File

@ -1694,10 +1694,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
String questKey) throws QuestFormatException {
Requirements reqs = quest.getRequirements();
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));
} else {
skipQuestProcess("Requirement fail-requirement-message is missing", questKey);
}
if (config.contains("quests." + questKey + ".requirements.items")) {
List<ItemStack> temp = reqs.getItems(); // TODO - should maybe be = new LinkedList<ItemStack>() ?

View File

@ -538,4 +538,61 @@ public class Stage {
if (customObjectives.isEmpty() == false) { return true; }
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;
}
}
}

View File

@ -64,7 +64,7 @@ public class NpcListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
boolean delivery = false;
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();
int currentIndex = -1;
LinkedList<Integer> matches = new LinkedList<Integer>();
@ -184,7 +184,7 @@ public class NpcListener implements Listener {
if (plugin.getQuestNpcs().contains(evt.getNPC()) && delivery == false) {
boolean hasObjective = false;
for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "talkToNPC")) {
if (quester.getCurrentStage(quest).containsObjective("talkToNPC")) {
if (quester.getQuestData(quest) != null
&& quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId())
&& quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) {
@ -319,7 +319,7 @@ public class NpcListener implements Listener {
if (okay) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "killNPC")) {
if (quester.getCurrentStage(quest).containsObjective("killNPC")) {
quester.killNPC(quest, evt.getNPC());
}
}
@ -336,7 +336,7 @@ public class NpcListener implements Listener {
Player player = (Player) damager;
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "killNPC")) {
if (quester.getCurrentStage(quest).containsObjective("killNPC")) {
quester.killNPC(quest, evt.getNPC());
}
}

View File

@ -221,7 +221,7 @@ public class PlayerListener implements Listener {
.getClickedBlock().getState().getData().toItemStack().getDurability());
for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "useBlock")) {
&& quester.getCurrentStage(quest).containsObjective("useBlock")) {
quester.useBlock(quest, blockItemStack);
hasObjective = true;
}
@ -398,7 +398,7 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
Quester quester = plugin.getQuester(player.getUniqueId());
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);
}
@ -441,7 +441,7 @@ public class PlayerListener implements Listener {
}
}
}
if (quester.containsObjective(quest, "password")) {
if (quester.getCurrentStage(quest).containsObjective("password")) {
quester.sayPassword(quest, evt);
}
}
@ -502,7 +502,7 @@ public class PlayerListener implements Listener {
.getData().toItemStack().getDurability());
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
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);
}
@ -524,7 +524,7 @@ public class PlayerListener implements Listener {
for (Quest quest : plugin.getQuests()) {
if (evt.isCancelled() == false) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "placeBlock")) {
&& quester.getCurrentStage(quest).containsObjective("placeBlock")) {
quester.placeBlock(quest, blockItemStack);
}
@ -547,7 +547,7 @@ public class PlayerListener implements Listener {
for (Quest quest : plugin.getQuests()) {
if (evt.isCancelled() == false) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "breakBlock")) {
&& quester.getCurrentStage(quest).containsObjective("breakBlock")) {
if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
quester.breakBlock(quest, blockItemStack);
}
@ -559,7 +559,7 @@ public class PlayerListener implements Listener {
return null;
});
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "placeBlock")) {
&& quester.getCurrentStage(quest).containsObjective("placeBlock")) {
for (ItemStack is : quester.getQuestData(quest).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
@ -578,7 +578,7 @@ public class PlayerListener implements Listener {
}
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)) {
quester.cutBlock(quest, blockItemStack);
}
@ -602,7 +602,7 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "shearSheep")) {
&& quester.getCurrentStage(quest).containsObjective("shearSheep")) {
quester.shearSheep(quest, sheep.getColor());
}
@ -622,7 +622,7 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(p.getUniqueId())) {
Quester quester = plugin.getQuester(p.getUniqueId());
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());
}
@ -645,7 +645,7 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "craftItem")) {
&& quester.getCurrentStage(quest).containsObjective("craftItem")) {
quester.craftItem(quest, craftedItem);
}
@ -691,7 +691,7 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "smeltItem")) {
&& quester.getCurrentStage(quest).containsObjective("smeltItem")) {
quester.smeltItem(quest, evt.getCurrentItem());
}
@ -706,7 +706,7 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "brewItem")) {
&& quester.getCurrentStage(quest).containsObjective("brewItem")) {
quester.brewItem(quest, evt.getCurrentItem());
}
@ -725,7 +725,7 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
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()) {
quester.enchantItem(quest, e, evt.getItem().getType());
}
@ -789,7 +789,7 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(damager.getUniqueId());
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
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));
}
@ -800,7 +800,7 @@ public class PlayerListener implements Listener {
}
} else {
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());
}
@ -896,7 +896,7 @@ public class PlayerListener implements Listener {
}
Quester quester = plugin.getQuester(damager.getUniqueId());
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);
}
@ -914,7 +914,7 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
Quester quester = plugin.getQuester(player.getUniqueId());
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)) {
quester.catchFish(quest);
}
@ -1061,7 +1061,7 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(uuid);
for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.containsObjective(quest, "reachLocation")) {
&& quester.getCurrentStage(quest).containsObjective("reachLocation")) {
quester.reachLocation(quest, location);
}

View File

@ -45,6 +45,7 @@ public class RequirementsPrompt extends NumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
private boolean hasRequirement = false;
private final int size = 11;
public RequirementsPrompt(Quests plugin, QuestFactory qf) {
@ -84,19 +85,8 @@ public class RequirementsPrompt extends NumericPrompt {
case 9:
return ChatColor.BLUE;
case 10:
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null
&& 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) {
if (!hasRequirement) {
return ChatColor.GRAY;
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
return ChatColor.RED;
} else {
return ChatColor.BLUE;
}
@ -128,19 +118,8 @@ public class RequirementsPrompt extends NumericPrompt {
case 9:
return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom");
case 10:
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null
&& 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) {
if (!hasRequirement) {
return ChatColor.GRAY + Lang.get("reqSetFail");
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
return ChatColor.RED + Lang.get("reqSetFail");
} else {
return ChatColor.YELLOW + Lang.get("reqSetFail");
}
@ -266,22 +245,15 @@ public class RequirementsPrompt extends NumericPrompt {
return text;
}
case 10:
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null
&& 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("reqNone") + ")";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
return ChatColor.RED + "(" + Lang.get("questRequiredNoneSet") + ")";
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) == null) {
if (!hasRequirement) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE)
+ "\"" + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.REQ_FAIL_MESSAGE)
+ "\"" + ChatColor.GRAY + ")";
}
case 11:
case 12:
@ -340,27 +312,33 @@ public class RequirementsPrompt extends NumericPrompt {
case 9:
return new CustomRequirementsPrompt();
case 10:
return new FailMessagePrompt();
case 11:
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) {
if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage"));
return new RequirementsPrompt(plugin, factory);
}
if (hasRequirement) {
return new FailMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new RequirementsPrompt(plugin, factory);
}
case 11:
return factory.returnToMenu();
default:
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 {
@ -1189,7 +1167,7 @@ public class RequirementsPrompt extends NumericPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
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);
}

View File

@ -24,7 +24,6 @@ public class CK {
public static final String Q_FINISH_MESSAGE = "finishMessage";
public static final String Q_START_NPC = "npcStart";
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_REGION = "region";
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_DESCRIPTIONS = "customReqDataDesc";
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
public static final String REQ_FAIL_MESSAGE = "failMessage";
// Stages
public static final String S_BREAK_NAMES = "breakNames";
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_COMPLETE_MESSAGE = "completeMessage";
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_PHRASES = "passwordPhrases";
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_DESCRIPTIONS = "customObjectiveDataDescriptions";
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
// Rewards
public static final String REW_MONEY = "moneyRew";
public static final String REW_QUEST_POINTS = "questPointsRew";

View File

@ -448,7 +448,6 @@ reqHeroesPrimaryCleared: "Heroes Primary Class requirement cleared."
reqHeroesNotSecondary: "The <class> class is not secondary!"
reqHeroesSecondaryCleared: "Heroes Secondary Class requirement cleared."
reqHeroesClassNotFound: "Class not found!"
reqNone: "No requirements set"
reqNotANumber: "<input> is not a number!"
reqMustAddItem: "You must add at least one item first!"
reqNoMessage: "You must set a fail requirements message!"