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

View File

@ -158,69 +158,67 @@ public class Quest {
/** /**
* 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
* @deprecated Use nextStage(Quester, boolean)
*/ */
public void nextStage(Quester q, boolean enableShareProgress) { public void nextStage(Quester quester) {
Stage currentStage = q.getCurrentStage(this); nextStage(quester, false);
}
/**
* Force player to proceed to the next ordered stage
*
* @param quester Player to force
* @param allowSharedProgress Whether to distribute progress to fellow questers
*/
public void nextStage(Quester quester, boolean allowSharedProgress) {
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.script != null) {
plugin.getDenizenTrigger().runDenizenScript(currentStage.script, q);
}
if (currentStage.finishEvent != null) { if (currentStage.finishEvent != null) {
currentStage.finishEvent.fire(q, this); currentStage.finishEvent.fire(quester, 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);
}
} }
if (quester.currentQuests.get(this) == (orderedStages.size() - 1)) {
if (currentStage.script != null) {
plugin.getDenizenTrigger().runDenizenScript(currentStage.script, quester);
} }
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();
} }
}
if (quester.getQuestData(this) != null) {
quester.getQuestData(this).delayStartTime = 0;
quester.getQuestData(this).delayTimeLeft = -1;
}
// Multiplayer // Multiplayer
if (enableShareProgress && opts.getShareProgressLevel() == 3) { if (opts.getShareProgressLevel() == 3) {
List<Quester> mq = q.getMultiplayerQuestersByQuest(this); List<Quester> mq = quester.getMultiplayerQuestersByQuest(this);
for (Quester qq : mq) { for (Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(this))) { if (currentStage.equals(qq.getCurrentStage(this))) {
nextStage(qq, false); 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();
} }
/** /**