mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-13 11:01:35 +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);
|
plugin.questers.put(evt.getPlayer().getUniqueId(), quester);
|
||||||
|
|
||||||
|
if (Quests.getInstance().useCompass) {
|
||||||
|
quester.resetCompass();
|
||||||
|
}
|
||||||
|
|
||||||
for (String s : quester.completedQuests) {
|
for (String s : quester.completedQuests) {
|
||||||
|
|
||||||
Quest q = plugin.getQuest(s);
|
Quest q = plugin.getQuest(s);
|
||||||
|
@ -89,7 +89,10 @@ public class Quest {
|
|||||||
if (stageCompleteMessage != null) {
|
if (stageCompleteMessage != null) {
|
||||||
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, this));
|
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, this));
|
||||||
}
|
}
|
||||||
resetCompass(q);
|
if (Quests.getInstance().useCompass) {
|
||||||
|
q.resetCompass();
|
||||||
|
q.findCompassTarget();
|
||||||
|
}
|
||||||
|
|
||||||
if (q.getCurrentStage(this).delay < 0) {
|
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;
|
Location targetLocation = null;
|
||||||
if (nextStage == null) {
|
if (nextStage == null) {
|
||||||
resetCompass(quester);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0)
|
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0)
|
||||||
{
|
{
|
||||||
@ -194,21 +196,9 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
if (targetLocation != null) {
|
if (targetLocation != null) {
|
||||||
quester.getPlayer().setCompassTarget(targetLocation);
|
quester.getPlayer().setCompassTarget(targetLocation);
|
||||||
} else {
|
|
||||||
resetCompass(quester);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void resetCompass(Quester q) {
|
return targetLocation != null;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -3467,4 +3467,26 @@ 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