Descriptive exception for invalid mobs killed, fixes #1858

This commit is contained in:
PikaMug 2022-01-14 15:21:11 -05:00
parent 40b23bcb96
commit 108ecb9952
3 changed files with 21 additions and 5 deletions

View File

@ -271,6 +271,12 @@ public class Quest implements Comparable<Quest> {
final String title = Lang.get(p, "objectives").replace("<quest>", name);
quester.sendMessage(ChatColor.GOLD + title);
plugin.showObjectives(this, quester, false);
if (quester.getCurrentStage(this) == null) {
quester.sendMessage(ChatColor.RED + "itemCreateCriticalError");
plugin.getLogger().severe("Could not set stage for quest ID " + getId()
+ " because the current stage for player " + quester.getLastKnownName() + " was null");
return;
}
final String stageStartMessage = quester.getCurrentStage(this).startMessage;
if (stageStartMessage != null) {
p.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this, p));

View File

@ -2450,6 +2450,16 @@ public class Quester implements Comparable<Quester> {
if (index == -1) {
return;
}
if (index >= questData.mobNumKilled.size()) {
plugin.getLogger().warning(getLastKnownName() + " has invalid num of mobs killed for quest ID "
+ quest.getId());
return;
}
if (index >= currentStage.mobNumToKill.size()) {
plugin.getLogger().warning(getLastKnownName() + " has invalid num of mobs to kill for quest ID "
+ quest.getId());
return;
}
final int mobsKilled = questData.mobNumKilled.get(index);
final int mobsToKill = currentStage.mobNumToKill.get(index);
if (!currentStage.locationsToKillWithin.isEmpty()) {

View File

@ -3392,11 +3392,11 @@ public class Quests extends JavaPlugin {
}
}
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) {
if (config.getLong("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999) != -999) {
oStage.delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay")
* 1000L;
} else {
throw new StageFormatException("delay is not a number", quest, stageNum);
final int delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999);
if (delay > 0) {
oStage.delay = delay * 1000L;
} else if (delay != -999) {
throw new StageFormatException("delay is not a positive number", quest, stageNum);
}
}
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay-message")) {