Fixed bug where quest progress could revert
This commit is contained in:
@@ -95,6 +95,21 @@ public final class QuestRepository {
|
|||||||
* @param stage The stage.
|
* @param stage The stage.
|
||||||
*/
|
*/
|
||||||
public void setStage(Quest quest, int stage) {
|
public void setStage(Quest quest, int stage) {
|
||||||
|
int oldStage = getStage(quest);
|
||||||
|
if(oldStage < stage) {
|
||||||
|
quests.put(quest.getIndex(), stage);
|
||||||
|
} else {
|
||||||
|
SystemLogger.logWarn(String.format("Nonmonotonic QuestRepository.setStage call for player \"%s\", quest \"%s\", old stage %d, new stage %d", player.getName(), quest.getName(), oldStage, stage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the stage of a quest, permitting non-monotonic updates.
|
||||||
|
*
|
||||||
|
* @param quest The quest.
|
||||||
|
* @param stage The stage.
|
||||||
|
*/
|
||||||
|
public void setStageNonmonotonic(Quest quest, int stage) {
|
||||||
quests.put(quest.getIndex(), stage);
|
quests.put(quest.getIndex(), stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class QuestCommandSet : CommandSet(Command.Privilege.ADMIN){
|
|||||||
}
|
}
|
||||||
val quest = args[1].toIntOrNull() ?: reject(player,"INVALID QUEST")
|
val quest = args[1].toIntOrNull() ?: reject(player,"INVALID QUEST")
|
||||||
val stage = args[2].toIntOrNull() ?: reject(player,"INVALID STAGE")
|
val stage = args[2].toIntOrNull() ?: reject(player,"INVALID STAGE")
|
||||||
player.questRepository.setStage(player.questRepository.forIndex(quest as Int), stage as Int)
|
player.questRepository.setStageNonmonotonic(player.questRepository.forIndex(quest as Int), stage as Int)
|
||||||
notify(player, "<col=209dff>Setting " + player.questRepository.forIndex(quest).name + " to stage $stage</col>")
|
notify(player, "<col=209dff>Setting " + player.questRepository.forIndex(quest).name + " to stage $stage</col>")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user