mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-02 13:41:30 +01:00
Improve compass resetting behavior with multiple active quests
This commit is contained in:
parent
d9b0acd73f
commit
8ca0e797a4
@ -875,6 +875,10 @@ public class PlayerListener implements Listener, ColorUtil {
|
||||
|
||||
plugin.questers.put(evt.getPlayer().getUniqueId(), quester);
|
||||
|
||||
if (Quests.getInstance().useCompass) {
|
||||
quester.resetCompass();
|
||||
}
|
||||
|
||||
for (String s : quester.completedQuests) {
|
||||
|
||||
Quest q = plugin.getQuest(s);
|
||||
|
@ -89,7 +89,10 @@ public class Quest {
|
||||
if (stageCompleteMessage != null) {
|
||||
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, this));
|
||||
}
|
||||
resetCompass(q);
|
||||
if (Quests.getInstance().useCompass) {
|
||||
q.resetCompass();
|
||||
q.findCompassTarget();
|
||||
}
|
||||
|
||||
if (q.getCurrentStage(this).delay < 0) {
|
||||
|
||||
@ -171,14 +174,13 @@ public class Quest {
|
||||
|
||||
}
|
||||
|
||||
public void updateCompass(Quester quester, Stage nextStage)
|
||||
public boolean updateCompass(Quester quester, Stage nextStage)
|
||||
{
|
||||
if (!Quests.getInstance().useCompass) return;
|
||||
if (!Quests.getInstance().useCompass) return false;
|
||||
|
||||
Location targetLocation = null;
|
||||
if (nextStage == null) {
|
||||
resetCompass(quester);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0)
|
||||
{
|
||||
@ -194,21 +196,9 @@ public class Quest {
|
||||
}
|
||||
if (targetLocation != null) {
|
||||
quester.getPlayer().setCompassTarget(targetLocation);
|
||||
} else {
|
||||
resetCompass(quester);
|
||||
}
|
||||
}
|
||||
|
||||
protected void resetCompass(Quester q) {
|
||||
if (!Quests.getInstance().useCompass) return;
|
||||
Player player = q.getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
Location defaultLocation = player.getBedSpawnLocation();
|
||||
if (defaultLocation == null) {
|
||||
defaultLocation = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
player.setCompassTarget(defaultLocation);
|
||||
|
||||
return targetLocation != null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -3466,5 +3466,27 @@ if (quest != null) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void resetCompass() {
|
||||
if (!Quests.getInstance().useCompass) return;
|
||||
Player player = getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
Location defaultLocation = player.getBedSpawnLocation();
|
||||
if (defaultLocation == null) {
|
||||
defaultLocation = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
player.setCompassTarget(defaultLocation);
|
||||
}
|
||||
|
||||
public void findCompassTarget() {
|
||||
if (!Quests.getInstance().useCompass) return;
|
||||
Player player = getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
for (Quest quest : currentQuests.keySet()) {
|
||||
Stage stage = getCurrentStage(quest);
|
||||
if (stage != null && quest.updateCompass(this, stage)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user