This commit is contained in:
PikaMug 2019-09-11 00:58:36 -04:00
parent 5ef3e4a2b1
commit 8f147aed46

View File

@ -154,73 +154,71 @@ public class Quest {
public void setInitialAction(Action initialAction) { public void setInitialAction(Action initialAction) {
this.initialAction = initialAction; this.initialAction = initialAction;
} }
/**
* Force player to proceed to the next ordered stage
*
* @param quester Player to force
* @deprecated Use nextStage(Quester, boolean)
*/
public void nextStage(Quester quester) {
nextStage(quester, false);
}
/** /**
* Force player to proceed to the next ordered stage * Force player to proceed to the next ordered stage
* *
* @param q Player to force * @param quester Player to force
* @param allowSharedProgress Whether to distribute progress to fellow questers
*/ */
public void nextStage(Quester q, boolean enableShareProgress) { public void nextStage(Quester quester, boolean allowSharedProgress) {
Stage currentStage = q.getCurrentStage(this); Stage currentStage = quester.getCurrentStage(this);
if (currentStage == null) { if (currentStage == null) {
plugin.getLogger().severe("Current stage was null for quester " + q.getPlayer().getUniqueId()); plugin.getLogger().severe("Current stage was null for quester " + quester.getPlayer().getUniqueId());
return; return;
} }
String stageCompleteMessage = currentStage.completeMessage; String stageCompleteMessage = currentStage.completeMessage;
if (stageCompleteMessage != null) { if (stageCompleteMessage != null) {
q.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, this, q.getPlayer())); quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, this, quester.getPlayer()));
} }
if (plugin.getSettings().canUseCompass()) { if (plugin.getSettings().canUseCompass()) {
q.resetCompass(); quester.resetCompass();
q.findCompassTarget(); quester.findCompassTarget();
} }
if (currentStage.delay < 0) { if (currentStage.delay < 0) {
if (q.currentQuests.get(this) == (orderedStages.size() - 1)) { if (currentStage.finishEvent != null) {
currentStage.finishEvent.fire(quester, this);
}
if (quester.currentQuests.get(this) == (orderedStages.size() - 1)) {
if (currentStage.script != null) { if (currentStage.script != null) {
plugin.getDenizenTrigger().runDenizenScript(currentStage.script, q); plugin.getDenizenTrigger().runDenizenScript(currentStage.script, quester);
}
if (currentStage.finishEvent != null) {
currentStage.finishEvent.fire(q, this);
}
completeQuest(q);
// Multiplayer
if (enableShareProgress && opts.getShareProgressLevel() == 3) {
List<Quester> mq = q.getMultiplayerQuestersByQuest(this);
for (Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(this))) {
completeQuest(qq);
}
}
} }
completeQuest(quester);
} else { } else {
try { try {
if (currentStage.finishEvent != null) { setStage(quester, quester.currentQuests.get(this) + 1);
currentStage.finishEvent.fire(q, this);
}
setStage(q, q.currentQuests.get(this) + 1);
} catch (InvalidStageException e) { } catch (InvalidStageException e) {
e.printStackTrace(); e.printStackTrace();
} }
}
// Multiplayer if (quester.getQuestData(this) != null) {
if (enableShareProgress && opts.getShareProgressLevel() == 3) { quester.getQuestData(this).delayStartTime = 0;
List<Quester> mq = q.getMultiplayerQuestersByQuest(this); quester.getQuestData(this).delayTimeLeft = -1;
for (Quester qq : mq) { }
if (currentStage.equals(qq.getCurrentStage(this))) {
nextStage(qq, false); // Multiplayer
} if (opts.getShareProgressLevel() == 3) {
List<Quester> mq = quester.getMultiplayerQuestersByQuest(this);
for (Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(this))) {
nextStage(qq, allowSharedProgress);
} }
} }
} }
if (q.getQuestData(this) != null) {
q.getQuestData(this).delayStartTime = 0;
q.getQuestData(this).delayTimeLeft = -1;
}
} else { } else {
q.startStageTimer(this); quester.startStageTimer(this);
} }
q.updateJournal(); quester.updateJournal();
} }
/** /**