Fixed an issue with quest bossbar

This commit is contained in:
Indyuce 2022-04-03 01:58:06 +02:00
parent d2022ca2e3
commit 227023cc37

View File

@ -99,10 +99,10 @@ public class PlayerQuests implements Closable {
playerData.log(Level.WARNING, "Couldn't load current quest progress (ID '" + cur.get("id").getAsString() + "')");
}
}
if (jo.has("finished")) {
if (jo.has("finished"))
for (Entry<String, JsonElement> entry : jo.getAsJsonObject("finished").entrySet())
finished.put(entry.getKey(), entry.getValue().getAsLong());
}
for (Entry<String, Long> entry : finished.entrySet())
MMOCore.log("Finished: (" + entry.getKey() + ") - at: " + entry.getValue());
@ -144,13 +144,21 @@ public class PlayerQuests implements Closable {
public void start(Quest quest) {
// Close current objective progress if quest is active
close();
closeCurrentQuest();
// Apply newest quest
current = quest == null ? null : quest.generateNewProgress(playerData);
updateBossBar();
}
public void closeCurrentQuest() {
if (current == null)
return;
current.getProgress().close();
current = null;
}
@Override
public void close() {
@ -158,8 +166,7 @@ public class PlayerQuests implements Closable {
bossbar.removeAll();
// Close current objective progress
if (current != null)
current.getProgress().close();
closeCurrentQuest();
}
public boolean checkCooldownAvailability(Quest quest) {