API – Get player quest status - SkytAsul/BeautyQuests GitHub Wiki
Prerequisite
First, you have to get a fr.skytasul.quests.players.PlayerAccount
instance for the player you want to get the status from. For this, use fr.skytasul.quests.players.PlayersManager#getPlayerAccount(Player player)
.
Now, you will need to get the fr.skytasul.quests.structure.Quest
instance of the quest you want to get the status of.
- If you know the ID of the quest, you can use
fr.skytasul.quests.api.QuestsAPI#getQuestFromID(int id)
. - If you want a list of all available quests, use
QuestsAPI#getQuests()
. - If you want a list of quests from a single Citizens NPC, use
QuestsAPI#getQuestsAssigneds(NPC npc)
. - You can use
QuestsAPI#getQuestsStarteds(PlayerAccount account)
,QuestsAPI#getQuestsUnstarted(PlayerAccount account)
andQuestsAPI#getQuestsFinished(PlayerAccount account)
if you want lists of quests specific for a player.
Getting status
Now you have the PlayerAccount
and Quest
instances, let's head to the real part of the problem.
There are three cases:
The quest is in progress
This means that Quest#hasStarted(PlayerAccount)
returns true
.
To get the description of the quests, use quest.getBranchesManager().getPlayerBranch(account).getDescriptionLine(account, Source.SCOREBOARD)
. (you can replace Source.SCOREBOARD
by whichever source you'd like among: SCOREBOARD, MENU, PLACEHOLDER, FORCESPLIT, FORCELINE
)
WARNING: Quest#hasFinished(PlayerAccount)
may return true
as some quests can be done multiple times.
The quest is finished
This means that Quest#hasStarted(PlayerAccount)
returns false
.
The quest has never started
This means that Quest#hasStarted(PlayerAccount)
and Quest#hasFinished(PlayerAccount)
returns false
.