diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 819e6314a..943dfd84c 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -3063,62 +3063,25 @@ public class Quester { /** * Check if quest is available and, if so, ask Quester if they would like to start it

* - * @param quest The quest to check an then offer - * @param giveReason Whether to inform player of unavailability + * @param quest The quest to check and then offer + * @param giveReason Whether to inform Quester of unavailability * @return true if successful */ public boolean offerQuest(Quest quest, boolean giveReason) { if (quest == null) { return false; } - Player player = this.getPlayer(); QuestTakeEvent event = new QuestTakeEvent(quest, this); plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } - if (getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() && plugin.getSettings().getMaxQuests() > 0) { - if (giveReason) { - String msg = Lang.get(player, "questMaxAllowed"); - msg = msg.replace("", String.valueOf(plugin.getSettings().getMaxQuests())); - player.sendMessage(ChatColor.YELLOW + msg); - } - } else if (getCurrentQuests().containsKey(quest)) { - if (giveReason) { - String msg = Lang.get(player, "questAlreadyOn"); - player.sendMessage(ChatColor.YELLOW + msg); - } - } else if (getCompletedQuests().contains(quest.getName()) && quest.getPlanner().getCooldown() < 0) { - if (giveReason) { - String msg = Lang.get(player, "questAlreadyCompleted"); - msg = msg.replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); - player.sendMessage(ChatColor.YELLOW + msg); - } - } else if (quest.getNpcStart() != null && plugin.getSettings().canAllowCommandsForNpcQuests() == false) { - if (giveReason) { - String msg = Lang.get(player, "mustSpeakTo"); - msg = msg.replace("", ChatColor.DARK_PURPLE + quest.getNpcStart().getName() + ChatColor.YELLOW); - player.sendMessage(ChatColor.YELLOW + msg); - } - } else if (quest.getBlockStart() != null) { - if (giveReason) { - String msg = Lang.get(player, "noCommandStart"); - msg = msg.replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); - player.sendMessage(ChatColor.YELLOW + msg); - } - } else if (getCompletedQuests().contains(quest.getName()) && getCooldownDifference(quest) > 0) { - if (giveReason) { - String msg = Lang.get(player, "questTooEarly"); - msg = msg.replace("", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); - msg = msg.replace("

+ * + * @param quest The quest to check + * @param giveReason Whether to inform Quester of unavailability + * @return true if available + */ + public boolean canAcceptOffer(Quest quest, boolean giveReason) { + if (getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() && plugin.getSettings().getMaxQuests() > 0) { + if (giveReason) { + String msg = Lang.get(getPlayer(), "questMaxAllowed"); + msg = msg.replace("", String.valueOf(plugin.getSettings().getMaxQuests())); + getPlayer().sendMessage(ChatColor.YELLOW + msg); + } + return false; + } else if (getCurrentQuests().containsKey(quest)) { + if (giveReason) { + String msg = Lang.get(getPlayer(), "questAlreadyOn"); + getPlayer().sendMessage(ChatColor.YELLOW + msg); + } + return false; + } else if (getCompletedQuests().contains(quest.getName()) && quest.getPlanner().getCooldown() < 0) { + if (giveReason) { + String msg = Lang.get(getPlayer(), "questAlreadyCompleted"); + msg = msg.replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); + getPlayer().sendMessage(ChatColor.YELLOW + msg); + } + return false; + } else if (quest.getNpcStart() != null && plugin.getSettings().canAllowCommandsForNpcQuests() == false) { + if (giveReason) { + String msg = Lang.get(getPlayer(), "mustSpeakTo"); + msg = msg.replace("", ChatColor.DARK_PURPLE + quest.getNpcStart().getName() + ChatColor.YELLOW); + getPlayer().sendMessage(ChatColor.YELLOW + msg); + } + return false; + } else if (quest.getBlockStart() != null) { + if (giveReason) { + String msg = Lang.get(getPlayer(), "noCommandStart"); + msg = msg.replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); + getPlayer().sendMessage(ChatColor.YELLOW + msg); + } + return false; + } else if (getCompletedQuests().contains(quest.getName()) && getCooldownDifference(quest) > 0) { + if (giveReason) { + String msg = Lang.get(getPlayer(), "questTooEarly"); + msg = msg.replace("", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); + msg = msg.replace("