Catch missing Citizens for kill IDs

This commit is contained in:
PikaMug 2022-12-18 05:18:01 -05:00
parent e0bbbe7e90
commit 354c72ba4a
2 changed files with 19 additions and 17 deletions

View File

@ -3084,20 +3084,25 @@ public class Quests extends JavaPlugin implements QuestsAPI {
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".npc-kill-amounts");
for (final int i : npcIdsToKill) {
final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
if (npc != null) {
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
final UUID npcUuid = npc.getUniqueId();
oStage.addNpcToKill(npcUuid);
oStage.addNpcNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
questNpcUuids.add(npcUuid);
if (getDependencies().getCitizens() != null) {
final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
if (npc != null) {
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
final UUID npcUuid = npc.getUniqueId();
oStage.addNpcToKill(npcUuid);
oStage.addNpcNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
questNpcUuids.add(npcUuid);
} else {
throw new StageFormatException("npc-kill-amounts is not a positive number",
quest, stageNum);
}
} else {
throw new StageFormatException("npc-kill-amounts is not a positive number",
quest, stageNum);
throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest,
stageNum);
}
} else {
throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest,
stageNum);
throw new StageFormatException(
"Citizens not found for npc-ids-to-kill", quest, stageNum);
}
}
} else {

View File

@ -34,10 +34,10 @@ public class ZnpcsListener implements Listener {
@EventHandler
public void onNPCInteract(final NPCInteractEvent event) {
if (plugin.getDependencies().getZnpcs() == null) {
return;
}
if (event.isLeftClick()) {
if (plugin.getDependencies().getZnpcs() == null) {
return;
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) {
if (event.getNpc() == null) {
plugin.getLogger().severe("ZNPC was null while selecting by left-click");
@ -49,9 +49,6 @@ public class ZnpcsListener implements Listener {
+ "to fix this at https://github.com/gonalez/znpc-servers/issues/36");
}
} else if (event.isRightClick()) {
if (plugin.getDependencies().getCitizens() == null) {
return;
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) {
if (event.getNpc() == null) {
plugin.getLogger().severe("ZNPC was null while selecting by right-click");