Skip to content

Commit

Permalink
Move autostart check to start method (closes #390)
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBishop committed May 10, 2022
1 parent 0f428e2 commit 075419c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Expand Up @@ -229,7 +229,6 @@ public boolean handleClick(InventoryClickEvent event, MenuController controller)
QuestMenuElement questMenuElement = (QuestMenuElement) menuElement;
Quest quest = questMenuElement.getQuest();
if (event.getClick() == startClickType) {
if (config.getBoolean("options.quest-autostart") || quest.isAutoStartEnabled()) return false;
if (owner.startQuest(quest) == QuestStartResult.QUEST_SUCCESS) {
event.getWhoClicked().closeInventory(); //TODO Option to keep the menu open
}
Expand Down
Expand Up @@ -158,9 +158,6 @@ public QuestStartResult canPlayerStartQuest(QPlayer qPlayer, Quest quest) {
if (!qPlayer.getQuestProgressFile().hasMetRequirements(quest)) {
return QuestStartResult.QUEST_LOCKED;
}
if (questProgress.isStarted()) {
return QuestStartResult.QUEST_ALREADY_STARTED;
}
if (quest.isPermissionRequired()) {
if (p != null) {
if (!p.hasPermission("quests.quest." + quest.getId())) {
Expand All @@ -180,6 +177,9 @@ public QuestStartResult canPlayerStartQuest(QPlayer qPlayer, Quest quest) {
return QuestStartResult.NO_PERMISSION_FOR_CATEGORY;
}
}
if (questProgress.isStarted() || quest.isAutoStartEnabled() || config.getBoolean("options.quest-autostart")) {
return QuestStartResult.QUEST_ALREADY_STARTED;
}
if (!config.getBoolean("options.quest-autostart")) {
Set<Quest> startedQuests = getStartedQuestsForPlayer(qPlayer);
int questLimitCount = 0;
Expand Down Expand Up @@ -277,7 +277,7 @@ public boolean cancelQuestForPlayer(QPlayer qPlayer, Quest quest) {
}
return false;
}
if (!quest.isCancellable()) {
if (!quest.isCancellable() || quest.isAutoStartEnabled() || config.getBoolean("options.quest-autostart")) {
Messages.QUEST_CANCEL_NOTCANCELLABLE.send(player);
return false;
}
Expand Down

0 comments on commit 075419c

Please sign in to comment.