Track progress through int, part 6. See #2250

This commit is contained in:
PikaMug 2024-07-14 23:38:05 -04:00
parent 217620a4db
commit db83260706
14 changed files with 493 additions and 588 deletions

View File

@ -100,8 +100,13 @@ public interface Quester extends Comparable<Quester> {
Stage getCurrentStage(final Quest quest); Stage getCurrentStage(final Quest quest);
/**
* @deprecated Use {@link #getQuestProgressOrDefault(Quest)} instead
*/
QuestProgress getQuestDataOrDefault(final Quest quest); QuestProgress getQuestDataOrDefault(final Quest quest);
QuestProgress getQuestProgressOrDefault(final Quest quest);
boolean hasJournal(); boolean hasJournal();
ItemStack getJournal(); ItemStack getJournal();

View File

@ -701,6 +701,10 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
questLoader.init(); questLoader.init();
for (final Quester quester : questers) { for (final Quester quester : questers) {
final Quester loaded = getStorage().loadQuester(quester.getUUID()).get(); final Quester loaded = getStorage().loadQuester(quester.getUUID()).get();
if (loaded == null) {
getLogger().severe("Unable to load quester of UUID " + quester.getUUID());
continue;
}
for (final Quest quest : loaded.getCurrentQuests().keySet()) { for (final Quest quest : loaded.getCurrentQuests().keySet()) {
loaded.checkQuest(quest); loaded.checkQuest(quest);
} }

View File

@ -47,7 +47,7 @@ public class BukkitQuestCommandHandler {
for (final Quest q : quester.getCurrentQuests().keySet()) { for (final Quest q : quester.getCurrentQuests().keySet()) {
final Stage stage = quester.getCurrentStage(q); final Stage stage = quester.getCurrentStage(q);
q.updateCompass(quester, stage); q.updateCompass(quester, stage);
if (plugin.getQuester(player.getUniqueId()).getQuestDataOrDefault(q).getDelayStartTime() == 0 if (plugin.getQuester(player.getUniqueId()).getQuestProgressOrDefault(q).getDelayStartTime() == 0
|| plugin.getQuester(player.getUniqueId()).getStageTime(q) < 0L) { || plugin.getQuester(player.getUniqueId()).getStageTime(q) < 0L) {
final String msg = BukkitLang.get(player, "questObjectivesTitle") final String msg = BukkitLang.get(player, "questObjectivesTitle")
.replace("<quest>", q.getName()); .replace("<quest>", q.getName());

View File

@ -98,12 +98,12 @@ public class BukkitBlockListener implements Listener {
})); }));
} }
} }
final BukkitQuestProgress questData = (BukkitQuestProgress) quester.getQuestDataOrDefault(quest); final BukkitQuestProgress questProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(quest);
if (quest.getOptions().canIgnoreBlockReplace()) { if (quest.getOptions().canIgnoreBlockReplace()) {
// Ignore blocks broken once replaced (self) // Ignore blocks broken once replaced (self)
if (currentStage.containsObjective(placeType)) { if (currentStage.containsObjective(placeType)) {
for (int i = 0; i < questData.blocksPlaced.size(); i++) { for (int i = 0; i < questProgress.blocksPlaced.size(); i++) {
final int progress = questData.blocksPlaced.get(i) - 1; final int progress = questProgress.blocksPlaced.get(i) - 1;
if (progress < 0) { if (progress < 0) {
break; break;
} }
@ -121,7 +121,7 @@ public class BukkitBlockListener implements Listener {
new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount())); new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
questData.blocksPlaced.set(i, progress); questProgress.blocksPlaced.set(i, progress);
final BukkitQuesterPostUpdateObjectiveEvent postEvent final BukkitQuesterPostUpdateObjectiveEvent postEvent
= new BukkitQuesterPostUpdateObjectiveEvent(quester, quest, = new BukkitQuesterPostUpdateObjectiveEvent(quester, quest,
@ -134,9 +134,9 @@ public class BukkitBlockListener implements Listener {
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType, dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) { if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
final BukkitQuestProgress qQuestData = (BukkitQuestProgress) q.getQuestDataOrDefault(cq); final BukkitQuestProgress qQuestProgress = (BukkitQuestProgress) q.getQuestProgressOrDefault(cq);
for (int i = 0; i < qQuestData.blocksPlaced.size(); i++) { for (int i = 0; i < qQuestProgress.blocksPlaced.size(); i++) {
final int progress = qQuestData.blocksPlaced.get(i) - 1; final int progress = qQuestProgress.blocksPlaced.get(i) - 1;
if (progress < 0) { if (progress < 0) {
break; break;
} }
@ -154,7 +154,7 @@ public class BukkitBlockListener implements Listener {
new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount())); new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
qQuestData.blocksPlaced.set(i, progress); qQuestProgress.blocksPlaced.set(i, progress);
final BukkitQuesterPostUpdateObjectiveEvent postEvent final BukkitQuesterPostUpdateObjectiveEvent postEvent
= new BukkitQuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq, = new BukkitQuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq,
@ -250,12 +250,12 @@ public class BukkitBlockListener implements Listener {
quester.placeBlock(quest, blockItemStack); quester.placeBlock(quest, blockItemStack);
} }
final BukkitQuestProgress questData = (BukkitQuestProgress) quester.getQuestDataOrDefault(quest); final BukkitQuestProgress questProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(quest);
if (quest.getOptions().canIgnoreBlockReplace()) { if (quest.getOptions().canIgnoreBlockReplace()) {
// Ignore blocks replaced once broken (self) // Ignore blocks replaced once broken (self)
if (currentStage.containsObjective(breakType)) { if (currentStage.containsObjective(breakType)) {
for (int i = 0; i < questData.blocksBroken.size(); i++) { for (int i = 0; i < questProgress.blocksBroken.size(); i++) {
final int progress = questData.blocksBroken.get(i) - 1; final int progress = questProgress.blocksBroken.get(i) - 1;
if (progress < 0) { if (progress < 0) {
break; break;
} }
@ -273,7 +273,7 @@ public class BukkitBlockListener implements Listener {
new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount())); new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
questData.blocksBroken.set(i, progress); questProgress.blocksBroken.set(i, progress);
final BukkitQuesterPostUpdateObjectiveEvent postEvent final BukkitQuesterPostUpdateObjectiveEvent postEvent
= new BukkitQuesterPostUpdateObjectiveEvent(quester, quest, = new BukkitQuesterPostUpdateObjectiveEvent(quester, quest,
@ -286,9 +286,9 @@ public class BukkitBlockListener implements Listener {
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType, dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedBreakQuestIDs.contains(cq.getId())) { if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
final BukkitQuestProgress qQuestData = (BukkitQuestProgress) q.getQuestDataOrDefault(cq); final BukkitQuestProgress qQuestProgress = (BukkitQuestProgress) q.getQuestProgressOrDefault(cq);
for (final int i : new LinkedList<>(qQuestData.blocksBroken)) { for (final int i : new LinkedList<>(qQuestProgress.blocksBroken)) {
final int progress = qQuestData.blocksBroken.get(i) - 1; final int progress = qQuestProgress.blocksBroken.get(i) - 1;
if (progress < 0) { if (progress < 0) {
break; break;
} }
@ -306,7 +306,7 @@ public class BukkitBlockListener implements Listener {
new BukkitObjective(breakType, null, is.getAmount(), goal.getAmount())); new BukkitObjective(breakType, null, is.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
qQuestData.blocksBroken.set(i, progress); qQuestProgress.blocksBroken.set(i, progress);
final BukkitQuesterPostUpdateObjectiveEvent postEvent final BukkitQuesterPostUpdateObjectiveEvent postEvent
= new BukkitQuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq, = new BukkitQuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq,

View File

@ -199,9 +199,9 @@ public class BukkitCitizensListener implements Listener {
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNPC().getUniqueId())) { if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNPC().getUniqueId())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNPC() final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNPC()
.getUniqueId()); .getUniqueId());
if (quester.getQuestDataOrDefault(quest) != null && npcIndex > -1) { if (quester.getQuestProgressOrDefault(quest) != null && npcIndex > -1) {
final LinkedList<Boolean> interacted final LinkedList<Boolean> interacted
= ((BukkitQuestProgress) quester.getQuestDataOrDefault(quest)).npcsInteracted; = ((BukkitQuestProgress) quester.getQuestProgressOrDefault(quest)).npcsInteracted;
if (interacted.size() > npcIndex && !interacted.get(npcIndex)) { if (interacted.size() > npcIndex && !interacted.get(npcIndex)) {
hasObjective = true; hasObjective = true;
} }

View File

@ -195,8 +195,8 @@ public class BukkitZnpcsApiListener implements Listener {
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUuid())) { if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUuid())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc() final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc()
.getUuid()); .getUuid());
if (quester.getQuestDataOrDefault(quest) != null && npcIndex > -1 if (quester.getQuestProgressOrDefault(quest) != null && npcIndex > -1
&& !((BukkitQuestProgress) quester.getQuestDataOrDefault(quest)).npcsInteracted.get(npcIndex)) { && !((BukkitQuestProgress) quester.getQuestProgressOrDefault(quest)).npcsInteracted.get(npcIndex)) {
hasObjective = true; hasObjective = true;
} }
quester.interactWithNPC(quest, event.getNpc().getUuid()); quester.interactWithNPC(quest, event.getNpc().getUuid());

View File

@ -203,8 +203,8 @@ public class BukkitZnpcsListener implements Listener {
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUUID())) { if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUUID())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc() final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc()
.getUUID()); .getUUID());
if (quester.getQuestDataOrDefault(quest) != null && npcIndex > -1 if (quester.getQuestProgressOrDefault(quest) != null && npcIndex > -1
&& !((BukkitQuestProgress) quester.getQuestDataOrDefault(quest)).npcsInteracted.get(npcIndex)) { && !((BukkitQuestProgress) quester.getQuestProgressOrDefault(quest)).npcsInteracted.get(npcIndex)) {
hasObjective = true; hasObjective = true;
} }
quester.interactWithNPC(quest, event.getNpc().getUUID()); quester.interactWithNPC(quest, event.getNpc().getUUID());

View File

@ -222,8 +222,8 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
return; return;
} }
int index = -1; int index = -1;
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) quester.getQuestDataOrDefault(bukkitQuest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(bukkitQuest);
final LinkedList<Integer> customObjCounts = bukkitQuestData.customObjectiveCounts; final LinkedList<Integer> customObjCounts = bukkitQuestProgress.customObjectiveCounts;
for (final CustomObjective co : quester.getCurrentStage(bukkitQuest).getCustomObjectives()) { for (final CustomObjective co : quester.getCurrentStage(bukkitQuest).getCustomObjectives()) {
index++; index++;
if (co.getName().equals(this.getName())) { if (co.getName().equals(this.getName())) {
@ -233,7 +233,7 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
continue; continue;
} }
final int old = customObjCounts.get(index); final int old = customObjCounts.get(index);
bukkitQuestData.customObjectiveCounts.set(index, old + count); bukkitQuestProgress.customObjectiveCounts.set(index, old + count);
break; break;
} }
} }
@ -253,9 +253,9 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
// Multiplayer // Multiplayer
final int finalIndex = index; final int finalIndex = index;
quester.dispatchMultiplayerObjectives(bukkitQuest, quester.getCurrentStage(bukkitQuest), (final Quester q) -> { quester.dispatchMultiplayerObjectives(bukkitQuest, quester.getCurrentStage(bukkitQuest), (final Quester q) -> {
final BukkitQuestProgress qBukkitQuestData = (BukkitQuestProgress) q.getQuestDataOrDefault(bukkitQuest); final BukkitQuestProgress qBukkitQuestProgress = (BukkitQuestProgress) q.getQuestProgressOrDefault(bukkitQuest);
final int old = qBukkitQuestData.customObjectiveCounts.get(finalIndex); final int old = qBukkitQuestProgress.customObjectiveCounts.get(finalIndex);
qBukkitQuestData.customObjectiveCounts.set(finalIndex, old + count); qBukkitQuestProgress.customObjectiveCounts.set(finalIndex, old + count);
q.finishObjective(bukkitQuest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), q.finishObjective(bukkitQuest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, bukkitCustomObj); new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, bukkitCustomObj);
return null; return null;

View File

@ -422,6 +422,17 @@ public class BukkitQuester implements Quester {
return null; return null;
} }
/**
* Get quest progress for given quest, or default values if not found
*
* @deprecated Use {@link #getQuestProgressOrDefault(Quest)} instead
* @param quest The quest to check
* @return Existing or current progress, or default
*/
public QuestProgress getQuestDataOrDefault(final Quest quest) {
return getQuestProgressOrDefault(quest);
}
/** /**
* Get quest progress for given quest, or default values if not found * Get quest progress for given quest, or default values if not found
* *
@ -429,7 +440,7 @@ public class BukkitQuester implements Quester {
* @return Existing or current progress, or default * @return Existing or current progress, or default
*/ */
@Override @Override
public QuestProgress getQuestDataOrDefault(final Quest quest) { public QuestProgress getQuestProgressOrDefault(final Quest quest) {
if (questProgress.get(quest) != null) { if (questProgress.get(quest) != null) {
return questProgress.get(quest); return questProgress.get(quest);
} }
@ -1168,7 +1179,7 @@ public class BukkitQuester implements Quester {
plugin.getLogger().severe("Quest was null when getting objectives for " + getLastKnownName()); plugin.getLogger().severe("Quest was null when getting objectives for " + getLastKnownName());
return new LinkedList<>(); return new LinkedList<>();
} }
if (getQuestDataOrDefault(quest) == null) { if (getQuestProgressOrDefault(quest) == null) {
plugin.getLogger().warning("Quest data was null when getting objectives for " + quest.getName()); plugin.getLogger().warning("Quest data was null when getting objectives for " + quest.getName());
return new LinkedList<>(); return new LinkedList<>();
} }
@ -1190,7 +1201,7 @@ public class BukkitQuester implements Quester {
} }
return objectives; return objectives;
} }
final BukkitQuestProgress data = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress data = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final LinkedList<Objective> objectives = new LinkedList<>(); final LinkedList<Objective> objectives = new LinkedList<>();
for (int i = 0; i < data.getBlocksBroken().size(); i++) { for (int i = 0; i < data.getBlocksBroken().size(); i++) {
final int progress = data.getBlocksBroken().get(i); final int progress = data.getBlocksBroken().get(i);
@ -1683,7 +1694,7 @@ public class BukkitQuester implements Quester {
plugin.getLogger().severe("Quest was null when getting conditions for " + quester.getLastKnownName()); plugin.getLogger().severe("Quest was null when getting conditions for " + quester.getLastKnownName());
return; return;
} }
if (quester.getQuestDataOrDefault(quest) == null) { if (quester.getQuestProgressOrDefault(quest) == null) {
plugin.getLogger().warning("Quest data was null when showing conditions for " + quest.getName()); plugin.getLogger().warning("Quest data was null when showing conditions for " + quest.getName());
return; return;
} }
@ -1827,13 +1838,13 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, broken.getAmount(), goal.getAmount())); new BukkitObjective(type, null, broken.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final int breakIndex = getCurrentStage(quest).getBlocksToBreak().indexOf(goal); final int breakIndex = getCurrentStage(quest).getBlocksToBreak().indexOf(goal);
if (bukkitQuestData.blocksBroken.get(breakIndex) > goal.getAmount()) { if (bukkitQuestProgress.blocksBroken.get(breakIndex) > goal.getAmount()) {
return; return;
} }
final int progress = bukkitQuestData.blocksBroken.get(breakIndex) + 1; final int progress = bukkitQuestProgress.blocksBroken.get(breakIndex) + 1;
bukkitQuestData.blocksBroken.set(breakIndex, progress); bukkitQuestProgress.blocksBroken.set(breakIndex, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
@ -1841,7 +1852,7 @@ public class BukkitQuester implements Quester {
// Multiplayer // Multiplayer
final ItemStack finalGoal = goal; final ItemStack finalGoal = goal;
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).blocksBroken.set(breakIndex, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).blocksBroken.set(breakIndex, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -1897,13 +1908,13 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, damaged.getAmount(), goal.getAmount())); new BukkitObjective(type, null, damaged.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final int damageIndex = getCurrentStage(quest).getBlocksToDamage().indexOf(goal); final int damageIndex = getCurrentStage(quest).getBlocksToDamage().indexOf(goal);
if (bukkitQuestData.blocksDamaged.get(damageIndex) > goal.getAmount()) { if (bukkitQuestProgress.blocksDamaged.get(damageIndex) > goal.getAmount()) {
return; return;
} }
final int progress = bukkitQuestData.blocksDamaged.get(damageIndex) + 1; final int progress = bukkitQuestProgress.blocksDamaged.get(damageIndex) + 1;
bukkitQuestData.blocksDamaged.set(damageIndex, progress); bukkitQuestProgress.blocksDamaged.set(damageIndex, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
@ -1911,7 +1922,7 @@ public class BukkitQuester implements Quester {
// Multiplayer // Multiplayer
final ItemStack finalGoal = goal; final ItemStack finalGoal = goal;
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).blocksDamaged.set(damageIndex, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).blocksDamaged.set(damageIndex, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -1967,13 +1978,13 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, placed.getAmount(), goal.getAmount())); new BukkitObjective(type, null, placed.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final int placeIndex = getCurrentStage(quest).getBlocksToPlace().indexOf(goal); final int placeIndex = getCurrentStage(quest).getBlocksToPlace().indexOf(goal);
if (bukkitQuestData.blocksPlaced.get(placeIndex) > goal.getAmount()) { if (bukkitQuestProgress.blocksPlaced.get(placeIndex) > goal.getAmount()) {
return; return;
} }
final int progress = bukkitQuestData.blocksPlaced.get(placeIndex) + 1; final int progress = bukkitQuestProgress.blocksPlaced.get(placeIndex) + 1;
bukkitQuestData.blocksPlaced.set(placeIndex, progress); bukkitQuestProgress.blocksPlaced.set(placeIndex, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
@ -1981,7 +1992,7 @@ public class BukkitQuester implements Quester {
// Multiplayer // Multiplayer
final ItemStack finalGoal = goal; final ItemStack finalGoal = goal;
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).blocksPlaced.set(placeIndex, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).blocksPlaced.set(placeIndex, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2037,13 +2048,13 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, used.getAmount(), goal.getAmount())); new BukkitObjective(type, null, used.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final int useIndex = getCurrentStage(quest).getBlocksToUse().indexOf(goal); final int useIndex = getCurrentStage(quest).getBlocksToUse().indexOf(goal);
if (bukkitQuestData.blocksUsed.get(useIndex) > goal.getAmount()) { if (bukkitQuestProgress.blocksUsed.get(useIndex) > goal.getAmount()) {
return; return;
} }
final int progress = bukkitQuestData.blocksUsed.get(useIndex) + 1; final int progress = bukkitQuestProgress.blocksUsed.get(useIndex) + 1;
bukkitQuestData.blocksUsed.set(useIndex, progress); bukkitQuestProgress.blocksUsed.set(useIndex, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
@ -2051,7 +2062,7 @@ public class BukkitQuester implements Quester {
// Multiplayer // Multiplayer
final ItemStack finalGoal = goal; final ItemStack finalGoal = goal;
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).blocksUsed.set(useIndex, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).blocksUsed.set(useIndex, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2107,13 +2118,13 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, cut.getAmount(), goal.getAmount())); new BukkitObjective(type, null, cut.getAmount(), goal.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final int cutIndex = getCurrentStage(quest).getBlocksToCut().indexOf(goal); final int cutIndex = getCurrentStage(quest).getBlocksToCut().indexOf(goal);
if (bukkitQuestData.blocksCut.get(cutIndex) > goal.getAmount()) { if (bukkitQuestProgress.blocksCut.get(cutIndex) > goal.getAmount()) {
return; return;
} }
final int progress = bukkitQuestData.blocksCut.get(cutIndex) + 1; final int progress = bukkitQuestProgress.blocksCut.get(cutIndex) + 1;
bukkitQuestData.blocksCut.set(cutIndex, progress); bukkitQuestProgress.blocksCut.set(cutIndex, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
@ -2121,7 +2132,7 @@ public class BukkitQuester implements Quester {
// Multiplayer // Multiplayer
final ItemStack finalGoal = goal; final ItemStack finalGoal = goal;
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).blocksCut.set(cutIndex, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).blocksCut.set(cutIndex, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, finalGoal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2142,7 +2153,7 @@ public class BukkitQuester implements Quester {
public void craftItem(final Quest quest, final ItemStack crafted) { public void craftItem(final Quest quest, final ItemStack crafted) {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final ItemStack toCraft : ((BukkitStage) getCurrentStage(quest)).getItemsToCraft()) { for (final ItemStack toCraft : ((BukkitStage) getCurrentStage(quest)).getItemsToCraft()) {
currentIndex++; currentIndex++;
if (BukkitItemUtil.compareItems(crafted, toCraft, true) == 0) { if (BukkitItemUtil.compareItems(crafted, toCraft, true) == 0) {
@ -2153,7 +2164,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
for (final Integer match : matches) { for (final Integer match : matches) {
final int amount = bukkitQuestData.itemsCrafted.get(match); final int amount = bukkitQuestProgress.itemsCrafted.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToCraft().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToCraft().get(match);
final ObjectiveType type = ObjectiveType.CRAFT_ITEM; final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
@ -2162,14 +2173,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int progress = crafted.getAmount() + amount; final int progress = crafted.getAmount() + amount;
bukkitQuestData.itemsCrafted.set(match, progress); bukkitQuestProgress.itemsCrafted.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
null, null, null); null, null, null);
// Multiplayer // Multiplayer
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsCrafted.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsCrafted.set(match, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2191,7 +2202,7 @@ public class BukkitQuester implements Quester {
public void smeltItem(final Quest quest, final ItemStack smelted) { public void smeltItem(final Quest quest, final ItemStack smelted) {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final ItemStack toSmelt : ((BukkitStage) getCurrentStage(quest)).getItemsToSmelt()) { for (final ItemStack toSmelt : ((BukkitStage) getCurrentStage(quest)).getItemsToSmelt()) {
currentIndex++; currentIndex++;
if (BukkitItemUtil.compareItems(smelted, toSmelt, true) == 0) { if (BukkitItemUtil.compareItems(smelted, toSmelt, true) == 0) {
@ -2202,7 +2213,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
for (final Integer match : matches) { for (final Integer match : matches) {
final int amount = bukkitQuestData.itemsSmelted.get(match); final int amount = bukkitQuestProgress.itemsSmelted.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToSmelt().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToSmelt().get(match);
final ObjectiveType type = ObjectiveType.SMELT_ITEM; final ObjectiveType type = ObjectiveType.SMELT_ITEM;
@ -2211,14 +2222,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int progress = smelted.getAmount() + amount; final int progress = smelted.getAmount() + amount;
bukkitQuestData.itemsSmelted.set(match, progress); bukkitQuestProgress.itemsSmelted.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
null, null, null); null, null, null);
// Multiplayer // Multiplayer
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsSmelted.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsSmelted.set(match, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2241,7 +2252,7 @@ public class BukkitQuester implements Quester {
final Map<Enchantment, Integer> enchantsToAdd) { final Map<Enchantment, Integer> enchantsToAdd) {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final ItemStack toEnchant : ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant()) { for (final ItemStack toEnchant : ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant()) {
currentIndex++; currentIndex++;
if (toEnchant.getItemMeta() instanceof EnchantmentStorageMeta) { if (toEnchant.getItemMeta() instanceof EnchantmentStorageMeta) {
@ -2254,7 +2265,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
for (final Integer match : matches) { for (final Integer match : matches) {
final int amount = bukkitQuestData.itemsEnchanted.get(match); final int amount = bukkitQuestProgress.itemsEnchanted.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant().get(match);
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM; final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
@ -2263,14 +2274,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int progress = enchantedBook.getAmount() + amount; final int progress = enchantedBook.getAmount() + amount;
bukkitQuestData.itemsEnchanted.set(match, progress); bukkitQuestProgress.itemsEnchanted.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
null, null, null); null, null, null);
// Multiplayer // Multiplayer
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsEnchanted.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsEnchanted.set(match, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2292,7 +2303,7 @@ public class BukkitQuester implements Quester {
public void enchantItem(final Quest quest, final ItemStack enchanted) { public void enchantItem(final Quest quest, final ItemStack enchanted) {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (!enchanted.getType().equals(Material.BOOK)) { if (!enchanted.getType().equals(Material.BOOK)) {
for (final ItemStack toEnchant : ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant()) { for (final ItemStack toEnchant : ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant()) {
currentIndex++; currentIndex++;
@ -2311,7 +2322,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
for (final Integer match : matches) { for (final Integer match : matches) {
final int amount = bukkitQuestData.itemsEnchanted.get(match); final int amount = bukkitQuestProgress.itemsEnchanted.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant().get(match);
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM; final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
@ -2320,14 +2331,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int progress = enchanted.getAmount() + amount; final int progress = enchanted.getAmount() + amount;
bukkitQuestData.itemsEnchanted.set(match, progress); bukkitQuestProgress.itemsEnchanted.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
null, null, null); null, null, null);
// Multiplayer // Multiplayer
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsEnchanted.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsEnchanted.set(match, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2349,7 +2360,7 @@ public class BukkitQuester implements Quester {
public void brewItem(final Quest quest, final ItemStack brewed) { public void brewItem(final Quest quest, final ItemStack brewed) {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final ItemStack toBrew : ((BukkitStage) getCurrentStage(quest)).getItemsToBrew()) { for (final ItemStack toBrew : ((BukkitStage) getCurrentStage(quest)).getItemsToBrew()) {
currentIndex++; currentIndex++;
if (BukkitItemUtil.compareItems(brewed, toBrew, true) == 0) { if (BukkitItemUtil.compareItems(brewed, toBrew, true) == 0) {
@ -2360,7 +2371,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
for (final Integer match : matches) { for (final Integer match : matches) {
final int amount = bukkitQuestData.itemsBrewed.get(match); final int amount = bukkitQuestProgress.itemsBrewed.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToBrew().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToBrew().get(match);
final ObjectiveType type = ObjectiveType.BREW_ITEM; final ObjectiveType type = ObjectiveType.BREW_ITEM;
@ -2369,14 +2380,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int progress = brewed.getAmount() + amount; final int progress = brewed.getAmount() + amount;
bukkitQuestData.itemsBrewed.set(match, progress); bukkitQuestProgress.itemsBrewed.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
null, null, null); null, null, null);
// Multiplayer // Multiplayer
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsBrewed.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsBrewed.set(match, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2398,7 +2409,7 @@ public class BukkitQuester implements Quester {
public void consumeItem(final Quest quest, final ItemStack consumed) { public void consumeItem(final Quest quest, final ItemStack consumed) {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final ItemStack toConsume : ((BukkitStage) getCurrentStage(quest)).getItemsToConsume()) { for (final ItemStack toConsume : ((BukkitStage) getCurrentStage(quest)).getItemsToConsume()) {
currentIndex++; currentIndex++;
if (BukkitItemUtil.compareItems(consumed, toConsume, true) == 0) { if (BukkitItemUtil.compareItems(consumed, toConsume, true) == 0) {
@ -2409,7 +2420,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
for (final Integer match : matches) { for (final Integer match : matches) {
final int amount = bukkitQuestData.itemsConsumed.get(match); final int amount = bukkitQuestProgress.itemsConsumed.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToConsume().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToConsume().get(match);
final ObjectiveType type = ObjectiveType.CONSUME_ITEM; final ObjectiveType type = ObjectiveType.CONSUME_ITEM;
@ -2418,14 +2429,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int progress = consumed.getAmount() + amount; final int progress = consumed.getAmount() + amount;
bukkitQuestData.itemsConsumed.set(match, progress); bukkitQuestProgress.itemsConsumed.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null, finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
null, null, null); null, null, null);
// Multiplayer // Multiplayer
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsConsumed.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsConsumed.set(match, progress);
q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, q.finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
null, null, null, null); null, null, null, null);
return null; return null;
@ -2452,7 +2463,7 @@ public class BukkitQuester implements Quester {
int currentIndex = -1; int currentIndex = -1;
final LinkedList<Integer> matches = new LinkedList<>(); final LinkedList<Integer> matches = new LinkedList<>();
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final ItemStack toDeliver : ((BukkitStage) getCurrentStage(quest)).getItemsToDeliver()) { for (final ItemStack toDeliver : ((BukkitStage) getCurrentStage(quest)).getItemsToDeliver()) {
currentIndex++; currentIndex++;
if (BukkitItemUtil.compareItems(delivered, toDeliver, true) == 0) { if (BukkitItemUtil.compareItems(delivered, toDeliver, true) == 0) {
@ -2467,7 +2478,7 @@ public class BukkitQuester implements Quester {
if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc)) { if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc)) {
continue; continue;
} }
final int amount = bukkitQuestData.itemsDelivered.get(match); final int amount = bukkitQuestProgress.itemsDelivered.get(match);
final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToDeliver().get(match); final ItemStack goal = ((BukkitStage) getCurrentStage(quest)).getItemsToDeliver().get(match);
final ObjectiveType type = ObjectiveType.DELIVER_ITEM; final ObjectiveType type = ObjectiveType.DELIVER_ITEM;
@ -2482,7 +2493,7 @@ public class BukkitQuester implements Quester {
// Already delivered in previous loop // Already delivered in previous loop
return; return;
} }
bukkitQuestData.itemsDelivered.set(match, progress); bukkitQuestProgress.itemsDelivered.set(match, progress);
if (progress >= goal.getAmount()) { if (progress >= goal.getAmount()) {
if ((delivered.getAmount() + amount) >= goal.getAmount()) { if ((delivered.getAmount() + amount) >= goal.getAmount()) {
// Take away remaining amount to be delivered // Take away remaining amount to be delivered
@ -2508,7 +2519,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, ObjectiveType.DELIVER_ITEM, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, ObjectiveType.DELIVER_ITEM,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).itemsDelivered.set(match, progress); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).itemsDelivered.set(match, progress);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2534,8 +2545,8 @@ public class BukkitQuester implements Quester {
} }
final int index = getCurrentStage(quest).getNpcsToInteract().indexOf(npc); final int index = getCurrentStage(quest).getNpcsToInteract().indexOf(npc);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final boolean npcsInteracted = bukkitQuestData.npcsInteracted.get(index); final boolean npcsInteracted = bukkitQuestProgress.npcsInteracted.get(index);
final ObjectiveType type = ObjectiveType.TALK_TO_NPC; final ObjectiveType type = ObjectiveType.TALK_TO_NPC;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -2544,14 +2555,14 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
if (!npcsInteracted) { if (!npcsInteracted) {
bukkitQuestData.npcsInteracted.set(index, true); bukkitQuestProgress.npcsInteracted.set(index, true);
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, 1)), null, null, npc, null, null, null, null); new ItemStack(Material.AIR, 1)), null, null, npc, null, null, null, null);
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).npcsInteracted.set(index, true); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).npcsInteracted.set(index, true);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2577,8 +2588,8 @@ public class BukkitQuester implements Quester {
} }
final int index = getCurrentStage(quest).getNpcsToKill().indexOf(npc); final int index = getCurrentStage(quest).getNpcsToKill().indexOf(npc);
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
final int npcsKilled = bukkitQuestData.npcsNumKilled.get(index); final int npcsKilled = bukkitQuestProgress.npcsNumKilled.get(index);
final int npcsToKill = getCurrentStage(quest).getNpcNumToKill().get(index); final int npcsToKill = getCurrentStage(quest).getNpcNumToKill().get(index);
final ObjectiveType type = ObjectiveType.KILL_NPC; final ObjectiveType type = ObjectiveType.KILL_NPC;
@ -2587,9 +2598,9 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, npcsKilled, npcsToKill)); new BukkitObjective(type, null, npcsKilled, npcsToKill));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int newNpcsKilled = bukkitQuestData.npcsNumKilled.get(index) + 1; final int newNpcsKilled = bukkitQuestProgress.npcsNumKilled.get(index) + 1;
if (npcsKilled < npcsToKill) { if (npcsKilled < npcsToKill) {
bukkitQuestData.npcsNumKilled.set(index, newNpcsKilled); bukkitQuestProgress.npcsNumKilled.set(index, newNpcsKilled);
if (newNpcsKilled >= npcsToKill) { if (newNpcsKilled >= npcsToKill) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, npcsToKill)), null, null, npc, null, null, null, null); new ItemStack(Material.AIR, npcsToKill)), null, null, npc, null, null, null, null);
@ -2598,7 +2609,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).npcsNumKilled ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).npcsNumKilled
.set(index, newNpcsKilled); .set(index, newNpcsKilled);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
@ -2619,8 +2630,8 @@ public class BukkitQuester implements Quester {
* @param quest The quest for which the fish is being caught * @param quest The quest for which the fish is being caught
*/ */
public void milkCow(final Quest quest) { public void milkCow(final Quest quest) {
final BukkitQuestProgress questData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress questProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (questData == null) { if (questProgress == null) {
return; return;
} }
final Stage currentStage = getCurrentStage(quest); final Stage currentStage = getCurrentStage(quest);
@ -2631,7 +2642,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
final int cowsMilked = questData.getCowsMilked(); final int cowsMilked = questProgress.getCowsMilked();
final int cowsToMilk = currentStage.getCowsToMilk(); final int cowsToMilk = currentStage.getCowsToMilk();
final ObjectiveType type = ObjectiveType.MILK_COW; final ObjectiveType type = ObjectiveType.MILK_COW;
@ -2642,7 +2653,7 @@ public class BukkitQuester implements Quester {
final int newCowsMilked = cowsMilked + 1; final int newCowsMilked = cowsMilked + 1;
if (cowsMilked < cowsToMilk) { if (cowsMilked < cowsToMilk) {
questData.setCowsMilked(newCowsMilked); questProgress.setCowsMilked(newCowsMilked);
if (newCowsMilked >= cowsToMilk) { if (newCowsMilked >= cowsToMilk) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
@ -2652,7 +2663,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.getQuestDataOrDefault(quest).setCowsMilked(newCowsMilked); q.getQuestProgressOrDefault(quest).setCowsMilked(newCowsMilked);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2672,8 +2683,8 @@ public class BukkitQuester implements Quester {
* @param quest The quest for which the fish is being caught * @param quest The quest for which the fish is being caught
*/ */
public void catchFish(final Quest quest) { public void catchFish(final Quest quest) {
final BukkitQuestProgress questData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress questProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (questData == null) { if (questProgress == null) {
return; return;
} }
final Stage currentStage = getCurrentStage(quest); final Stage currentStage = getCurrentStage(quest);
@ -2684,7 +2695,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
final int fishCaught = questData.getFishCaught(); final int fishCaught = questProgress.getFishCaught();
final int fishToCatch = currentStage.getFishToCatch(); final int fishToCatch = currentStage.getFishToCatch();
final ObjectiveType type = ObjectiveType.CATCH_FISH; final ObjectiveType type = ObjectiveType.CATCH_FISH;
@ -2695,7 +2706,7 @@ public class BukkitQuester implements Quester {
final int newFishCaught = fishCaught + 1; final int newFishCaught = fishCaught + 1;
if (fishCaught < fishToCatch) { if (fishCaught < fishToCatch) {
questData.setFishCaught(newFishCaught); questProgress.setFishCaught(newFishCaught);
if (newFishCaught >= fishToCatch) { if (newFishCaught >= fishToCatch) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
@ -2705,7 +2716,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.getQuestDataOrDefault(quest).setFishCaught(newFishCaught); q.getQuestProgressOrDefault(quest).setFishCaught(newFishCaught);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2727,7 +2738,7 @@ public class BukkitQuester implements Quester {
* @param entityType The mob to be killed * @param entityType The mob to be killed
*/ */
public void killMob(final Quest quest, final Location killedLocation, final EntityType entityType) { public void killMob(final Quest quest, final Location killedLocation, final EntityType entityType) {
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (entityType == null) { if (entityType == null) {
return; return;
} }
@ -2739,7 +2750,7 @@ public class BukkitQuester implements Quester {
if (index == -1) { if (index == -1) {
return; return;
} }
final int mobsKilled = bukkitQuestData.mobNumKilled.get(index); final int mobsKilled = bukkitQuestProgress.mobNumKilled.get(index);
final int mobsToKill = currentStage.getMobNumToKill().get(index); final int mobsToKill = currentStage.getMobNumToKill().get(index);
if (!currentStage.getLocationsToKillWithin().isEmpty()) { if (!currentStage.getLocationsToKillWithin().isEmpty()) {
final Location locationToKillWithin = currentStage.getLocationsToKillWithin().get(index); final Location locationToKillWithin = currentStage.getLocationsToKillWithin().get(index);
@ -2771,7 +2782,7 @@ public class BukkitQuester implements Quester {
final int newMobsKilled = mobsKilled + 1; final int newMobsKilled = mobsKilled + 1;
if (mobsKilled < mobsToKill) { if (mobsKilled < mobsToKill) {
bukkitQuestData.mobNumKilled.set(index, newMobsKilled); bukkitQuestProgress.mobNumKilled.set(index, newMobsKilled);
if (newMobsKilled >= mobsToKill) { if (newMobsKilled >= mobsToKill) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, mobsToKill)), entityType, null, null, null, null, null, null); new ItemStack(Material.AIR, mobsToKill)), entityType, null, null, null, null, null, null);
@ -2784,8 +2795,8 @@ public class BukkitQuester implements Quester {
if (i == -1) { if (i == -1) {
return null; return null;
} }
final int kills = q.getQuestDataOrDefault(quest).getMobNumKilled().get(i); final int kills = q.getQuestProgressOrDefault(quest).getMobNumKilled().get(i);
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).mobNumKilled.set(index, kills + 1); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).mobNumKilled.set(index, kills + 1);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2806,8 +2817,8 @@ public class BukkitQuester implements Quester {
* @param player The player to be killed * @param player The player to be killed
*/ */
public void killPlayer(final Quest quest, final Player player) { public void killPlayer(final Quest quest, final Player player) {
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (bukkitQuestData == null) { if (bukkitQuestProgress == null) {
return; return;
} }
final Stage currentStage = getCurrentStage(quest); final Stage currentStage = getCurrentStage(quest);
@ -2818,7 +2829,7 @@ public class BukkitQuester implements Quester {
return; return;
} }
final int playersKilled = bukkitQuestData.getPlayersKilled(); final int playersKilled = bukkitQuestProgress.getPlayersKilled();
final int playersToKill = currentStage.getPlayersToKill(); final int playersToKill = currentStage.getPlayersToKill();
final ObjectiveType type = ObjectiveType.KILL_PLAYER; final ObjectiveType type = ObjectiveType.KILL_PLAYER;
@ -2829,7 +2840,7 @@ public class BukkitQuester implements Quester {
final int newPlayersKilled = playersKilled + 1; final int newPlayersKilled = playersKilled + 1;
if (playersKilled < playersToKill) { if (playersKilled < playersToKill) {
bukkitQuestData.setPlayersKilled(newPlayersKilled); bukkitQuestProgress.setPlayersKilled(newPlayersKilled);
if (newPlayersKilled >= playersToKill) { if (newPlayersKilled >= playersToKill) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null); new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null);
@ -2838,8 +2849,8 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
final int kills = q.getQuestDataOrDefault(quest).getPlayersKilled(); final int kills = q.getQuestProgressOrDefault(quest).getPlayersKilled();
q.getQuestDataOrDefault(quest).setPlayersKilled(kills + 1); q.getQuestProgressOrDefault(quest).setPlayersKilled(kills + 1);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2860,8 +2871,8 @@ public class BukkitQuester implements Quester {
* @param location The location being reached * @param location The location being reached
*/ */
public void reachLocation(final Quest quest, final Location location) { public void reachLocation(final Quest quest, final Location location) {
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (bukkitQuestData == null || bukkitQuestData.locationsReached == null || getCurrentStage(quest) == null if (bukkitQuestProgress == null || bukkitQuestProgress.locationsReached == null || getCurrentStage(quest) == null
|| getCurrentStage(quest).getLocationsToReach() == null) { || getCurrentStage(quest).getLocationsToReach() == null) {
return; return;
} }
@ -2876,9 +2887,9 @@ public class BukkitQuester implements Quester {
} }
final double radius = getCurrentStage(quest).getRadiiToReachWithin().get(i); final double radius = getCurrentStage(quest).getRadiiToReachWithin().get(i);
if (toReach.distanceSquared(location) <= radius * radius) { if (toReach.distanceSquared(location) <= radius * radius) {
if (!bukkitQuestData.locationsReached.get(i)) { if (!bukkitQuestProgress.locationsReached.get(i)) {
int progress = 0; int progress = 0;
for (final Boolean b : bukkitQuestData.locationsReached) { for (final Boolean b : bukkitQuestProgress.locationsReached) {
if (b) { if (b) {
progress++; progress++;
} }
@ -2890,7 +2901,7 @@ public class BukkitQuester implements Quester {
new BukkitObjective(type, null, progress, goal)); new BukkitObjective(type, null, progress, goal));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
bukkitQuestData.locationsReached.set(i, true); bukkitQuestProgress.locationsReached.set(i, true);
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, 1)), null, null, null, toReach, null, null, null); new ItemStack(Material.AIR, 1)), null, null, null, toReach, null, null, null);
@ -2898,7 +2909,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).locationsReached ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).locationsReached
.set(finalIndex, true); .set(finalIndex, true);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
@ -2925,7 +2936,7 @@ public class BukkitQuester implements Quester {
* @param entityType The type of mob being tamed * @param entityType The type of mob being tamed
*/ */
public void tameMob(final Quest quest, final EntityType entityType) { public void tameMob(final Quest quest, final EntityType entityType) {
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (entityType == null) { if (entityType == null) {
return; return;
} }
@ -2940,7 +2951,7 @@ public class BukkitQuester implements Quester {
} }
final int mobsToTame = currentStage.getMobNumToTame().get(index); final int mobsToTame = currentStage.getMobNumToTame().get(index);
final int mobsTamed = bukkitQuestData.mobsTamed.get(index); final int mobsTamed = bukkitQuestProgress.mobsTamed.get(index);
final ObjectiveType type = ObjectiveType.TAME_MOB; final ObjectiveType type = ObjectiveType.TAME_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -2950,7 +2961,7 @@ public class BukkitQuester implements Quester {
final int newMobsToTame = mobsTamed + 1; final int newMobsToTame = mobsTamed + 1;
if (mobsTamed < mobsToTame) { if (mobsTamed < mobsToTame) {
bukkitQuestData.mobsTamed.set(index, newMobsToTame); bukkitQuestProgress.mobsTamed.set(index, newMobsToTame);
if (newMobsToTame >= mobsToTame) { if (newMobsToTame >= mobsToTame) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, mobsToTame)), entityType, null, null, null, null, null, null); new ItemStack(Material.AIR, mobsToTame)), entityType, null, null, null, null, null, null);
@ -2959,7 +2970,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).mobsTamed.set(index, newMobsToTame); ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).mobsTamed.set(index, newMobsToTame);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
} }
@ -2980,7 +2991,7 @@ public class BukkitQuester implements Quester {
* @param color The wool color of the sheep being sheared * @param color The wool color of the sheep being sheared
*/ */
public void shearSheep(final Quest quest, final DyeColor color) { public void shearSheep(final Quest quest, final DyeColor color) {
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (color == null) { if (color == null) {
return; return;
} }
@ -2995,7 +3006,7 @@ public class BukkitQuester implements Quester {
} }
final int sheepToShear = getCurrentStage(quest).getSheepNumToShear().get(index); final int sheepToShear = getCurrentStage(quest).getSheepNumToShear().get(index);
final int sheepSheared = bukkitQuestData.sheepSheared.get(index); final int sheepSheared = bukkitQuestProgress.sheepSheared.get(index);
final ObjectiveType type = ObjectiveType.SHEAR_SHEEP; final ObjectiveType type = ObjectiveType.SHEAR_SHEEP;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -3005,7 +3016,7 @@ public class BukkitQuester implements Quester {
final int newSheepSheared = sheepSheared + 1; final int newSheepSheared = sheepSheared + 1;
if (sheepSheared < sheepToShear) { if (sheepSheared < sheepToShear) {
bukkitQuestData.sheepSheared.set(index, newSheepSheared); bukkitQuestProgress.sheepSheared.set(index, newSheepSheared);
if (newSheepSheared >= sheepToShear) { if (newSheepSheared >= sheepToShear) {
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, color, null, null); new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, color, null, null);
@ -3014,7 +3025,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).sheepSheared ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).sheepSheared
.set(index, newSheepSheared); .set(index, newSheepSheared);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
@ -3044,11 +3055,11 @@ public class BukkitQuester implements Quester {
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
int index = 0; int index = 0;
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
for (final String pass : getCurrentStage(quest).getPasswordPhrases()) { for (final String pass : getCurrentStage(quest).getPasswordPhrases()) {
if (pass.equalsIgnoreCase(evt.getMessage())) { if (pass.equalsIgnoreCase(evt.getMessage())) {
final String display = getCurrentStage(quest).getPasswordDisplays().get(index); final String display = getCurrentStage(quest).getPasswordDisplays().get(index);
bukkitQuestData.passwordsSaid.set(index, true); bukkitQuestProgress.passwordsSaid.set(index, true);
plugin.getServer().getScheduler().runTask(plugin, () -> finishObjective(quest, plugin.getServer().getScheduler().runTask(plugin, () -> finishObjective(quest,
new BukkitObjective(type, null, new ItemStack(Material.AIR, 1), new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
@ -3058,7 +3069,7 @@ public class BukkitQuester implements Quester {
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final Quester q, final Quest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).passwordsSaid ((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).passwordsSaid
.set(finalIndex, true); .set(finalIndex, true);
if (q.testComplete(quest)) { if (q.testComplete(quest)) {
quest.nextStage(q, false); quest.nextStage(q, false);
@ -3575,16 +3586,13 @@ public class BukkitQuester implements Quester {
public FileConfiguration getBaseData() { public FileConfiguration getBaseData() {
final FileConfiguration data = new YamlConfiguration(); final FileConfiguration data = new YamlConfiguration();
final ArrayList<String> currentQuestIds = new ArrayList<>();
final ArrayList<Integer> currentQuestStages = new ArrayList<>();
if (!currentQuests.isEmpty()) { if (!currentQuests.isEmpty()) {
final ArrayList<String> questIds = new ArrayList<>();
final ArrayList<Integer> questStages = new ArrayList<>();
for (final Quest quest : currentQuests.keySet()) { for (final Quest quest : currentQuests.keySet()) {
questIds.add(quest.getId()); currentQuestIds.add(quest.getId());
questStages.add(currentQuests.get(quest)); currentQuestStages.add(currentQuests.get(quest));
} }
data.set("currentQuests", questIds);
data.set("currentStages", questStages);
data.set("quest-points", questPoints);
final ConfigurationSection dataSec = data.createSection("questData"); final ConfigurationSection dataSec = data.createSection("questData");
for (final Quest quest : currentQuests.keySet()) { for (final Quest quest : currentQuests.keySet()) {
if (quest.getName() == null || quest.getName().isEmpty()) { if (quest.getName() == null || quest.getName().isEmpty()) {
@ -3592,91 +3600,88 @@ public class BukkitQuester implements Quester {
return null; return null;
} }
final ConfigurationSection questSec = dataSec.createSection(quest.getId()); final ConfigurationSection questSec = dataSec.createSection(quest.getId());
final BukkitQuestProgress questData = (BukkitQuestProgress) getQuestDataOrDefault(quest); final BukkitQuestProgress questProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
if (questData == null) { if (questProgress == null) {
continue; continue;
} }
if (!questData.blocksBroken.isEmpty()) { if (!questProgress.blocksBroken.isEmpty()) {
questSec.set("blocks-broken-amounts", questData.blocksBroken); questSec.set("blocks-broken-amounts", questProgress.blocksBroken);
} }
if (!questData.blocksDamaged.isEmpty()) { if (!questProgress.blocksDamaged.isEmpty()) {
questSec.set("blocks-damaged-amounts", questData.blocksDamaged); questSec.set("blocks-damaged-amounts", questProgress.blocksDamaged);
} }
if (!questData.blocksPlaced.isEmpty()) { if (!questProgress.blocksPlaced.isEmpty()) {
questSec.set("blocks-placed-amounts", questData.blocksPlaced); questSec.set("blocks-placed-amounts", questProgress.blocksPlaced);
} }
if (!questData.blocksUsed.isEmpty()) { if (!questProgress.blocksUsed.isEmpty()) {
questSec.set("blocks-used-amounts", questData.blocksUsed); questSec.set("blocks-used-amounts", questProgress.blocksUsed);
} }
if (!questData.blocksCut.isEmpty()) { if (!questProgress.blocksCut.isEmpty()) {
questSec.set("blocks-cut-amounts", questData.blocksCut); questSec.set("blocks-cut-amounts", questProgress.blocksCut);
} }
if (!questData.itemsCrafted.isEmpty()) { if (!questProgress.itemsCrafted.isEmpty()) {
questSec.set("item-craft-amounts", questData.itemsCrafted); questSec.set("item-craft-amounts", questProgress.itemsCrafted);
} }
if (!questData.itemsSmelted.isEmpty()) { if (!questProgress.itemsSmelted.isEmpty()) {
questSec.set("item-smelt-amounts", questData.itemsSmelted); questSec.set("item-smelt-amounts", questProgress.itemsSmelted);
} }
if (!questData.itemsEnchanted.isEmpty()) { if (!questProgress.itemsEnchanted.isEmpty()) {
questSec.set("item-enchant-amounts", questData.itemsEnchanted); questSec.set("item-enchant-amounts", questProgress.itemsEnchanted);
} }
if (!questData.itemsBrewed.isEmpty()) { if (!questProgress.itemsBrewed.isEmpty()) {
questSec.set("item-brew-amounts", questData.itemsBrewed); questSec.set("item-brew-amounts", questProgress.itemsBrewed);
} }
if (!questData.itemsConsumed.isEmpty()) { if (!questProgress.itemsConsumed.isEmpty()) {
questSec.set("item-consume-amounts", questData.itemsConsumed); questSec.set("item-consume-amounts", questProgress.itemsConsumed);
} }
if (!questData.itemsDelivered.isEmpty()) { if (!questProgress.itemsDelivered.isEmpty()) {
questSec.set("item-delivery-amounts", questData.itemsDelivered); questSec.set("item-delivery-amounts", questProgress.itemsDelivered);
} }
if (!questData.npcsInteracted.isEmpty()) { if (!questProgress.npcsInteracted.isEmpty()) {
questSec.set("has-talked-to", questData.npcsInteracted); questSec.set("has-talked-to", questProgress.npcsInteracted);
} }
if (!questData.npcsNumKilled.isEmpty()) { if (!questProgress.npcsNumKilled.isEmpty()) {
questSec.set("npc-killed-amounts", questData.npcsNumKilled); questSec.set("npc-killed-amounts", questProgress.npcsNumKilled);
} }
if (!questData.mobNumKilled.isEmpty()) { if (!questProgress.mobNumKilled.isEmpty()) {
questSec.set("mobs-killed-amounts", questData.mobNumKilled); questSec.set("mobs-killed-amounts", questProgress.mobNumKilled);
} }
if (!questData.mobsTamed.isEmpty()) { if (!questProgress.mobsTamed.isEmpty()) {
questSec.set("mob-tame-amounts", questData.mobsTamed); questSec.set("mob-tame-amounts", questProgress.mobsTamed);
} }
final Stage stage = getCurrentStage(quest); final Stage stage = getCurrentStage(quest);
if (stage != null) { if (stage != null) {
if (stage.getFishToCatch() != null) { if (stage.getFishToCatch() != null) {
questSec.set("fish-caught", questData.getFishCaught()); questSec.set("fish-caught", questProgress.getFishCaught());
} }
if (stage.getCowsToMilk() != null) { if (stage.getCowsToMilk() != null) {
questSec.set("cows-milked", questData.getCowsMilked()); questSec.set("cows-milked", questProgress.getCowsMilked());
} }
if (stage.getPlayersToKill() != null) { if (stage.getPlayersToKill() != null) {
questSec.set("players-killed", questData.getPlayersKilled()); questSec.set("players-killed", questProgress.getPlayersKilled());
} }
} }
if (!questData.sheepSheared.isEmpty()) { if (!questProgress.sheepSheared.isEmpty()) {
questSec.set("sheep-sheared", questData.sheepSheared); questSec.set("sheep-sheared", questProgress.sheepSheared);
} }
if (!questData.locationsReached.isEmpty()) { if (!questProgress.locationsReached.isEmpty()) {
questSec.set("has-reached-location", questData.locationsReached); questSec.set("has-reached-location", questProgress.locationsReached);
} }
if (!questData.passwordsSaid.isEmpty()) { if (!questProgress.passwordsSaid.isEmpty()) {
questSec.set("passwords-said", questData.passwordsSaid); questSec.set("passwords-said", questProgress.passwordsSaid);
} }
if (!questData.customObjectiveCounts.isEmpty()) { if (!questProgress.customObjectiveCounts.isEmpty()) {
questSec.set("custom-objective-counts", questData.customObjectiveCounts); questSec.set("custom-objective-counts", questProgress.customObjectiveCounts);
} }
if (questData.getDelayTimeLeft() > 0) { if (questProgress.getDelayTimeLeft() > 0) {
questSec.set("stage-delay", questData.getDelayTimeLeft()); questSec.set("stage-delay", questProgress.getDelayTimeLeft());
} }
} }
} else {
data.set("currentQuests", "none");
data.set("currentStages", "none");
data.set("quest-points", questPoints);
} }
if (completedQuests.isEmpty()) { data.set("currentQuests", currentQuestIds);
data.set("completed-Quests", "none"); data.set("currentStages", currentQuestStages);
} else { data.set("quest-points", questPoints);
if (!completedQuests.isEmpty()) {
final List<String> questIds = new LinkedList<>(); final List<String> questIds = new LinkedList<>();
for (final Quest quest : completedQuests) { for (final Quest quest : completedQuests) {
questIds.add(quest.getId()); questIds.add(quest.getId());
@ -3746,9 +3751,9 @@ public class BukkitQuester implements Quester {
* @param quest The quest of which the timer is for * @param quest The quest of which the timer is for
*/ */
public void startStageTimer(final Quest quest) { public void startStageTimer(final Quest quest) {
if (getQuestDataOrDefault(quest).getDelayTimeLeft() > -1) { if (getQuestProgressOrDefault(quest).getDelayTimeLeft() > -1) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new BukkitStageTimer(plugin, this, quest), plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new BukkitStageTimer(plugin, this, quest),
(long) (getQuestDataOrDefault(quest).getDelayTimeLeft() * 0.02)); (long) (getQuestProgressOrDefault(quest).getDelayTimeLeft() * 0.02));
} else { } else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new BukkitStageTimer(plugin, this, quest), plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new BukkitStageTimer(plugin, this, quest),
(long) (getCurrentStage(quest).getDelay() * 0.02)); (long) (getCurrentStage(quest).getDelay() * 0.02));
@ -3760,7 +3765,7 @@ public class BukkitQuester implements Quester {
} }
} }
} }
getQuestDataOrDefault(quest).setDelayStartTime(System.currentTimeMillis()); getQuestProgressOrDefault(quest).setDelayStartTime(System.currentTimeMillis());
} }
/** /**
@ -3768,12 +3773,12 @@ public class BukkitQuester implements Quester {
* @param quest The quest of which the timer is for * @param quest The quest of which the timer is for
*/ */
public void stopStageTimer(final Quest quest) { public void stopStageTimer(final Quest quest) {
if (getQuestDataOrDefault(quest).getDelayTimeLeft() > -1) { if (getQuestProgressOrDefault(quest).getDelayTimeLeft() > -1) {
getQuestDataOrDefault(quest).setDelayTimeLeft(getQuestDataOrDefault(quest).getDelayTimeLeft() getQuestProgressOrDefault(quest).setDelayTimeLeft(getQuestProgressOrDefault(quest).getDelayTimeLeft()
- (System.currentTimeMillis() - getQuestDataOrDefault(quest).getDelayStartTime())); - (System.currentTimeMillis() - getQuestProgressOrDefault(quest).getDelayStartTime()));
} else { } else {
getQuestDataOrDefault(quest).setDelayTimeLeft(getCurrentStage(quest).getDelay() - (System.currentTimeMillis() getQuestProgressOrDefault(quest).setDelayTimeLeft(getCurrentStage(quest).getDelay() - (System.currentTimeMillis()
- getQuestDataOrDefault(quest).getDelayStartTime())); - getQuestProgressOrDefault(quest).getDelayStartTime()));
} }
} }
@ -3783,12 +3788,12 @@ public class BukkitQuester implements Quester {
* @return Remaining time in milliseconds * @return Remaining time in milliseconds
*/ */
public long getStageTime(final Quest quest) { public long getStageTime(final Quest quest) {
if (getQuestDataOrDefault(quest).getDelayTimeLeft() > -1) { if (getQuestProgressOrDefault(quest).getDelayTimeLeft() > -1) {
return getQuestDataOrDefault(quest).getDelayTimeLeft() - (System.currentTimeMillis() return getQuestProgressOrDefault(quest).getDelayTimeLeft() - (System.currentTimeMillis()
- getQuestDataOrDefault(quest).getDelayStartTime()); - getQuestProgressOrDefault(quest).getDelayStartTime());
} else { } else {
return getCurrentStage(quest).getDelay() - (System.currentTimeMillis() return getCurrentStage(quest).getDelay() - (System.currentTimeMillis()
- getQuestDataOrDefault(quest).getDelayStartTime()); - getQuestProgressOrDefault(quest).getDelayStartTime());
} }
} }

View File

@ -306,9 +306,9 @@ public class BukkitQuest implements Quest {
} else { } else {
setStage(quester, quester.getCurrentQuests().get(this) + 1); setStage(quester, quester.getCurrentQuests().get(this) + 1);
} }
if (quester.getQuestDataOrDefault(this) != null) { if (quester.getQuestProgressOrDefault(this) != null) {
quester.getQuestDataOrDefault(this).setDelayStartTime(0); quester.getQuestProgressOrDefault(this).setDelayStartTime(0);
quester.getQuestDataOrDefault(this).setDelayTimeLeft(-1); quester.getQuestProgressOrDefault(this).setDelayTimeLeft(-1);
} }
// Multiplayer // Multiplayer
@ -1082,7 +1082,7 @@ public class BukkitQuest implements Quest {
if (allowMultiplayer && options.getShareProgressLevel() == 4) { if (allowMultiplayer && options.getShareProgressLevel() == 4) {
final List<Quester> mq = quester.getMultiplayerQuesters(this); final List<Quester> mq = quester.getMultiplayerQuesters(this);
for (final Quester qq : mq) { for (final Quester qq : mq) {
if (qq.getQuestDataOrDefault(this) != null) { if (qq.getQuestProgressOrDefault(this) != null) {
completeQuest(qq, false); completeQuest(qq, false);
} }
} }

View File

@ -146,6 +146,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (config == null) {
return null;
}
final BukkitQuest quest = new BukkitQuest(plugin); final BukkitQuest quest = new BukkitQuest(plugin);
final BukkitDependencies depends = plugin.getDependencies(); final BukkitDependencies depends = plugin.getDependencies();
quest.setId(questId); quest.setId(questId);
@ -328,7 +331,6 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
@SuppressWarnings({"unchecked"})
private void loadQuestRewards(final FileConfiguration config, final Quest quest, final String questKey) private void loadQuestRewards(final FileConfiguration config, final Quest quest, final String questKey)
throws QuestFormatException { throws QuestFormatException {
final BukkitRewards rewards = (BukkitRewards) quest.getRewards(); final BukkitRewards rewards = (BukkitRewards) quest.getRewards();
@ -507,7 +509,6 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
@SuppressWarnings({ "unchecked"})
private void loadQuestRequirements(final FileConfiguration config, final ConfigurationSection questsSection, private void loadQuestRequirements(final FileConfiguration config, final ConfigurationSection questsSection,
final Quest quest, final String questKey) throws QuestFormatException { final Quest quest, final String questKey) throws QuestFormatException {
final BukkitRequirements requires = (BukkitRequirements) quest.getRequirements(); final BukkitRequirements requires = (BukkitRequirements) quest.getRequirements();
@ -836,40 +837,38 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
final List<String> npcUuidsToKill; final List<String> npcUuidsToKill;
final List<Integer> npcIdsToKill; final List<Integer> npcIdsToKill;
final List<Integer> npcAmountsToKill; final List<Integer> npcAmountsToKill;
final ConfigurationSection ordered
= config.getConfigurationSection("quests." + questKey + ".stages.ordered." + stageNum);
if (ordered == null || ordered.getKeys(false).isEmpty()) {
throw new StageFormatException("Stage cannot be empty", quest, stageNum);
}
// Legacy Denizen script load // Legacy Denizen script load
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run")) { if (config.contains(ordered + ".script-to-run")) {
if (plugin.getDependencies().getDenizenApi().containsScript(config.getString("quests." + questKey if (plugin.getDependencies().getDenizenApi().containsScript(config.getString(ordered
+ ".stages.ordered." + stageNum + ".script-to-run"))) { + ".script-to-run"))) {
oStage.setScript(config.getString("quests." + questKey + ".stages.ordered." + stageNum oStage.setScript(config.getString(ordered + ".script-to-run"));
+ ".script-to-run"));
} else { } else {
throw new StageFormatException("'script-to-run' is not a valid Denizen script", quest, stageNum); throw new StageFormatException("'script-to-run' is not a valid Denizen script", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-names")) { if (config.contains(ordered + ".break-block-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".break-block-names"), String.class)) {
+ ".break-block-names"), String.class)) { breakNames = config.getStringList(ordered + ".break-block-names");
breakNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".break-block-names");
} else { } else {
throw new StageFormatException("'break-block-names' is not a list of strings", quest, stageNum); throw new StageFormatException("'break-block-names' is not a list of strings", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-amounts")) { if (config.contains(ordered + ".break-block-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".break-block-amounts"), Integer.class)) {
+ ".break-block-amounts"), Integer.class)) { breakAmounts = config.getIntegerList(ordered + ".break-block-amounts");
breakAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".break-block-amounts");
} else { } else {
throw new StageFormatException("'break-block-amounts' is not a list of numbers", quest, stageNum); throw new StageFormatException("'break-block-amounts' is not a list of numbers", quest, stageNum);
} }
} else { } else {
throw new StageFormatException("'break-block-amounts' is missing", quest, stageNum); throw new StageFormatException("'break-block-amounts' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-durability")) { if (config.contains(ordered + ".break-block-durability")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".break-block-durability"), Integer.class)) {
+ ".break-block-durability"), Integer.class)) { breakDurability = config.getShortList(ordered + ".break-block-durability");
breakDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
+ ".break-block-durability");
} else { } else {
throw new StageFormatException("'break-block-durability' is not a list of numbers", quest, throw new StageFormatException("'break-block-durability' is not a list of numbers", quest,
stageNum); stageNum);
@ -878,35 +877,30 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'break-block-durability' is missing", quest, stageNum); throw new StageFormatException("'break-block-durability' is missing", quest, stageNum);
} }
} }
int breakIndex = 0; for (int i = 0; i < breakNames.size(); i++) {
for (final String s : breakNames) { final String name = breakNames.get(i);
final ItemStack is; final ItemStack is;
if (breakIndex < breakDurability.size() && breakDurability.get(breakIndex) != -1) { if (i < breakDurability.size() && breakDurability.get(i) != -1) {
is = BukkitItemUtil.processItemStack(s, breakAmounts.get(breakIndex), breakDurability.get(breakIndex)); is = BukkitItemUtil.processItemStack(name, breakAmounts.get(i), breakDurability.get(i));
} else { } else {
// Legacy // Legacy
is = BukkitItemUtil.processItemStack(s, breakAmounts.get(breakIndex), (short) 0); is = BukkitItemUtil.processItemStack(name, breakAmounts.get(i), (short) 0);
} }
if (Material.matchMaterial(s) != null) { if (Material.matchMaterial(name) != null) {
oStage.addBlockToBreak(is); oStage.addBlockToBreak(is);
} else { } else {
throw new StageFormatException("'break-block-names' has invalid item name " + s, quest, stageNum); throw new StageFormatException("'break-block-names' has invalid item name " + name, quest, stageNum);
} }
breakIndex++;
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-names")) { if (config.contains(ordered + ".damage-block-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".damage-block-names"), String.class)) {
+ ".damage-block-names"), String.class)) { damageNames = config.getStringList(ordered + ".damage-block-names");
damageNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".damage-block-names");
} else { } else {
throw new StageFormatException("'damage-block-names' is not a list of strings", quest, stageNum); throw new StageFormatException("'damage-block-names' is not a list of strings", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-amounts")) { if (config.contains(ordered + ".damage-block-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".damage-block-amounts"), Integer.class)) {
+ ".damage-block-amounts"), Integer.class)) { damageAmounts = config.getIntegerList(ordered + ".damage-block-amounts");
damageAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".damage-block-amounts");
} else { } else {
throw new StageFormatException("'damage-block-amounts' is not a list of numbers", quest, throw new StageFormatException("'damage-block-amounts' is not a list of numbers", quest,
stageNum); stageNum);
@ -914,12 +908,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'damage-block-amounts' is missing", quest, stageNum); throw new StageFormatException("'damage-block-amounts' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum if (config.contains(ordered + ".damage-block-durability")) {
+ ".damage-block-durability")) { if (BukkitConfigUtil.checkList(config.getList(ordered + ".damage-block-durability"), Integer.class)) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum damageDurability = config.getShortList(ordered + ".damage-block-durability");
+ ".damage-block-durability"), Integer.class)) {
damageDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
+ ".damage-block-durability");
} else { } else {
throw new StageFormatException("'damage-block-durability' is not a list of numbers", quest, throw new StageFormatException("'damage-block-durability' is not a list of numbers", quest,
stageNum); stageNum);
@ -928,47 +919,40 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'damage-block-durability' is missing", quest, stageNum); throw new StageFormatException("'damage-block-durability' is missing", quest, stageNum);
} }
} }
int damageIndex = 0; for (int i = 0; i < damageNames.size(); i++) {
for (final String s : damageNames) { final String name = damageNames.get(i);
final ItemStack is; final ItemStack is;
if (damageIndex < damageDurability.size() && damageDurability.get(damageIndex) != -1) { if (i < damageDurability.size() && damageDurability.get(i) != -1) {
is = BukkitItemUtil.processItemStack(s, damageAmounts.get(damageIndex), is = BukkitItemUtil.processItemStack(name, damageAmounts.get(i),
damageDurability.get(damageIndex)); damageDurability.get(i));
} else { } else {
// Legacy // Legacy
is = BukkitItemUtil.processItemStack(s, damageAmounts.get(damageIndex), (short) 0); is = BukkitItemUtil.processItemStack(name, damageAmounts.get(i), (short) 0);
} }
if (Material.matchMaterial(s) != null) { if (Material.matchMaterial(name) != null) {
oStage.addBlockToDamage(is); oStage.addBlockToDamage(is);
} else { } else {
throw new StageFormatException("'damage-block-names' has invalid item name " + s, quest, stageNum); throw new StageFormatException("'damage-block-names' has invalid item name " + name, quest, stageNum);
} }
damageIndex++;
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-names")) { if (config.contains(ordered + ".place-block-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".place-block-names"), String.class)) {
+ ".place-block-names"), String.class)) { placeNames = config.getStringList(ordered + ".place-block-names");
placeNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".place-block-names");
} else { } else {
throw new StageFormatException("'place-block-names' is not a list of strings", quest, stageNum); throw new StageFormatException("'place-block-names' is not a list of strings", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-amounts")) { if (config.contains(ordered + ".place-block-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".place-block-amounts"), Integer.class)) {
+ ".place-block-amounts"), Integer.class)) { placeAmounts = config.getIntegerList(ordered + ".place-block-amounts");
placeAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".place-block-amounts");
} else { } else {
throw new StageFormatException("'place-block-amounts' is not a list of numbers", quest, stageNum); throw new StageFormatException("'place-block-amounts' is not a list of numbers", quest, stageNum);
} }
} else { } else {
throw new StageFormatException("'place-block-amounts' is missing", quest, stageNum); throw new StageFormatException("'place-block-amounts' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-durability")) { if (config.contains(ordered + ".place-block-durability")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".place-block-durability"), Integer.class)) {
+ ".place-block-durability"), Integer.class)) { placeDurability = config.getShortList(ordered + ".place-block-durability");
placeDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
+ ".place-block-durability");
} else { } else {
throw new StageFormatException("'place-block-durability' is not a list of numbers", quest, throw new StageFormatException("'place-block-durability' is not a list of numbers", quest,
stageNum); stageNum);
@ -977,46 +961,39 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'place-block-durability' is missing", quest, stageNum); throw new StageFormatException("'place-block-durability' is missing", quest, stageNum);
} }
} }
int placeIndex = 0; for (int i = 0; i < placeNames.size(); i++) {
for (final String s : placeNames) { final String name = placeNames.get(i);
final ItemStack is; final ItemStack is;
if (placeIndex < placeDurability.size() && placeDurability.get(placeIndex) != -1) { if (i < placeDurability.size() && placeDurability.get(i) != -1) {
is = BukkitItemUtil.processItemStack(s, placeAmounts.get(placeIndex), placeDurability.get(placeIndex)); is = BukkitItemUtil.processItemStack(name, placeAmounts.get(i), placeDurability.get(i));
} else { } else {
// Legacy // Legacy
is = BukkitItemUtil.processItemStack(s, placeAmounts.get(placeIndex), (short) 0); is = BukkitItemUtil.processItemStack(name, placeAmounts.get(i), (short) 0);
} }
if (Material.matchMaterial(s) != null) { if (Material.matchMaterial(name) != null) {
oStage.addBlockToPlace(is); oStage.addBlockToPlace(is);
} else { } else {
throw new StageFormatException("'place-block-names' has invalid item name " + s, quest, stageNum); throw new StageFormatException("'place-block-names' has invalid item name " + name, quest, stageNum);
} }
placeIndex++;
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-names")) { if (config.contains(ordered + ".use-block-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".use-block-names"), String.class)) {
+ ".use-block-names"), String.class)) { useNames = config.getStringList(ordered + ".use-block-names");
useNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".use-block-names");
} else { } else {
throw new StageFormatException("'use-block-names' is not a list of strings", quest, stageNum); throw new StageFormatException("'use-block-names' is not a list of strings", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-amounts")) { if (config.contains(ordered + ".use-block-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".use-block-amounts"),Integer.class)) {
+ ".use-block-amounts"),Integer.class)) { useAmounts = config.getIntegerList(ordered + ".use-block-amounts");
useAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".use-block-amounts");
} else { } else {
throw new StageFormatException("'use-block-amounts' is not a list of numbers", quest, stageNum); throw new StageFormatException("'use-block-amounts' is not a list of numbers", quest, stageNum);
} }
} else { } else {
throw new StageFormatException("'use-block-amounts' is missing", quest, stageNum); throw new StageFormatException("'use-block-amounts' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-durability")) { if (config.contains(ordered + ".use-block-durability")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".use-block-durability"), Integer.class)) {
+ ".use-block-durability"), Integer.class)) { useDurability = config.getShortList(ordered + ".use-block-durability");
useDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
+ ".use-block-durability");
} else { } else {
throw new StageFormatException("'use-block-durability' is not a list of numbers", quest, throw new StageFormatException("'use-block-durability' is not a list of numbers", quest,
stageNum); stageNum);
@ -1025,46 +1002,39 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'use-block-durability' is missing", quest, stageNum); throw new StageFormatException("'use-block-durability' is missing", quest, stageNum);
} }
} }
int useIndex = 0; for (int i = 0; i < useNames.size(); i++) {
for (final String s : useNames) { final String name = useNames.get(i);
final ItemStack is; final ItemStack is;
if (useIndex < useDurability.size() && useDurability.get(useIndex) != -1) { if (i < useDurability.size() && useDurability.get(i) != -1) {
is = BukkitItemUtil.processItemStack(s, useAmounts.get(useIndex), useDurability.get(useIndex)); is = BukkitItemUtil.processItemStack(name, useAmounts.get(i), useDurability.get(i));
} else { } else {
// Legacy // Legacy
is = BukkitItemUtil.processItemStack(s, useAmounts.get(useIndex), (short) 0); is = BukkitItemUtil.processItemStack(name, useAmounts.get(i), (short) 0);
} }
if (Material.matchMaterial(s) != null) { if (Material.matchMaterial(name) != null) {
oStage.addBlockToUse(is); oStage.addBlockToUse(is);
} else { } else {
throw new StageFormatException("'use-block-names' has invalid item name " + s, quest, stageNum); throw new StageFormatException("'use-block-names' has invalid item name " + name, quest, stageNum);
} }
useIndex++;
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-names")) { if (config.contains(ordered + ".cut-block-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".cut-block-names"), String.class)) {
+ ".cut-block-names"), String.class)) { cutNames = config.getStringList(ordered + ".cut-block-names");
cutNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".cut-block-names");
} else { } else {
throw new StageFormatException("'cut-block-names' is not a list of strings", quest, stageNum); throw new StageFormatException("'cut-block-names' is not a list of strings", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-amounts")) { if (config.contains(ordered + ".cut-block-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".cut-block-amounts"), Integer.class)) {
+ ".cut-block-amounts"), Integer.class)) { cutAmounts = config.getIntegerList(ordered + ".cut-block-amounts");
cutAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".cut-block-amounts");
} else { } else {
throw new StageFormatException("'cut-block-amounts' is not a list of numbers", quest, stageNum); throw new StageFormatException("'cut-block-amounts' is not a list of numbers", quest, stageNum);
} }
} else { } else {
throw new StageFormatException("'cut-block-amounts' is missing", quest, stageNum); throw new StageFormatException("'cut-block-amounts' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-durability")) { if (config.contains(ordered + ".cut-block-durability")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".cut-block-durability"), Integer.class)) {
+ ".cut-block-durability"), Integer.class)) { cutDurability = config.getShortList(ordered + ".cut-block-durability");
cutDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
+ ".cut-block-durability");
} else { } else {
throw new StageFormatException("'cut-block-durability' is not a list of numbers", quest, throw new StageFormatException("'cut-block-durability' is not a list of numbers", quest,
stageNum); stageNum);
@ -1073,25 +1043,23 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'cut-block-durability' is missing", quest, stageNum); throw new StageFormatException("'cut-block-durability' is missing", quest, stageNum);
} }
} }
int cutIndex = 0; for (int i = 0; i < cutNames.size(); i++) {
for (final String s : cutNames) { final String name = cutNames.get(i);
final ItemStack is; final ItemStack is;
if (cutIndex < cutDurability.size() && cutDurability.get(cutIndex) != -1) { if (i < cutDurability.size() && cutDurability.get(i) != -1) {
is = BukkitItemUtil.processItemStack(s, cutAmounts.get(cutIndex), cutDurability.get(cutIndex)); is = BukkitItemUtil.processItemStack(name, cutAmounts.get(i), cutDurability.get(i));
} else { } else {
// Legacy // Legacy
is = BukkitItemUtil.processItemStack(s, cutAmounts.get(cutIndex), (short) 0); is = BukkitItemUtil.processItemStack(name, cutAmounts.get(i), (short) 0);
} }
if (Material.matchMaterial(s) != null) { if (Material.matchMaterial(name) != null) {
oStage.addBlockToCut(is); oStage.addBlockToCut(is);
} else { } else {
throw new StageFormatException("'cut-block-names' has invalid item name " + s, quest, stageNum); throw new StageFormatException("'cut-block-names' has invalid item name " + name, quest, stageNum);
} }
cutIndex++;
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-craft")) { if (config.contains(ordered + ".items-to-craft")) {
itemsToCraft = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum itemsToCraft = (List<ItemStack>) config.get(ordered + ".items-to-craft");
+ ".items-to-craft");
if (BukkitConfigUtil.checkList(itemsToCraft, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToCraft, ItemStack.class)) {
for (final ItemStack stack : itemsToCraft) { for (final ItemStack stack : itemsToCraft) {
if (stack != null) { if (stack != null) {
@ -1104,9 +1072,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'items-to-craft' is not formatted properly", quest, stageNum); throw new StageFormatException("'items-to-craft' is not formatted properly", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-smelt")) { if (config.contains(ordered + ".items-to-smelt")) {
itemsToSmelt = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum itemsToSmelt = (List<ItemStack>) config.get(ordered + ".items-to-smelt");
+ ".items-to-smelt");
if (BukkitConfigUtil.checkList(itemsToSmelt, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToSmelt, ItemStack.class)) {
for (final ItemStack stack : itemsToSmelt) { for (final ItemStack stack : itemsToSmelt) {
if (stack != null) { if (stack != null) {
@ -1119,10 +1086,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'items-to-smelt' is not formatted properly", quest, stageNum); throw new StageFormatException("'items-to-smelt' is not formatted properly", quest, stageNum);
} }
} }
if (config.contains(ordered + ".items-to-enchant")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-enchant")) { itemsToEnchant = (List<ItemStack>) config.get(ordered + ".items-to-enchant");
itemsToEnchant = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
+ ".items-to-enchant");
if (BukkitConfigUtil.checkList(itemsToEnchant, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToEnchant, ItemStack.class)) {
for (final ItemStack stack : itemsToEnchant) { for (final ItemStack stack : itemsToEnchant) {
if (stack != null) { if (stack != null) {
@ -1136,11 +1101,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
final LinkedList<Material> types = new LinkedList<>(); final LinkedList<Material> types = new LinkedList<>();
final LinkedList<Enchantment> enchs = new LinkedList<>(); final LinkedList<Enchantment> enchs = new LinkedList<>();
final LinkedList<Integer> amts; final LinkedList<Integer> amts;
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantments")) { if (config.contains(ordered + ".enchantments")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".enchantments"), String.class)) {
+ ".enchantments"), String.class)) { for (final String enchant : config.getStringList(ordered + ".enchantments")) {
for (final String enchant : config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".enchantments")) {
final Enchantment e = BukkitItemUtil.getEnchantmentFromProperName(enchant); final Enchantment e = BukkitItemUtil.getEnchantmentFromProperName(enchant);
if (e != null) { if (e != null) {
enchs.add(e); enchs.add(e);
@ -1150,13 +1113,13 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
} else { } else {
throw new StageFormatException("'enchantments' is not a list of enchantment names", quest, stageNum); throw new StageFormatException("'enchantments' is not a list of enchantment names", quest,
stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-item-names")) { if (config.contains(ordered + ".enchantment-item-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".enchantment-item-names"),
+ ".enchantment-item-names"), String.class)) { String.class)) {
for (final String item : config.getStringList("quests." + questKey + ".stages.ordered." + stageNum for (final String item : config.getStringList(ordered + ".enchantment-item-names")) {
+ ".enchantment-item-names")) {
if (Material.matchMaterial(item) != null) { if (Material.matchMaterial(item) != null) {
types.add(Material.matchMaterial(item)); types.add(Material.matchMaterial(item));
} else { } else {
@ -1165,18 +1128,19 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
} else { } else {
throw new StageFormatException("'enchantment-item-names' has invalid item name", quest, stageNum); throw new StageFormatException("'enchantment-item-names' has invalid item name", quest,
stageNum);
} }
} else { } else {
throw new StageFormatException("'enchantment-item-names' is missing", quest, stageNum); throw new StageFormatException("'enchantment-item-names' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-amounts")) { if (config.contains(ordered + ".enchantment-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered
+ ".enchantment-amounts"), Integer.class)) { + ".enchantment-amounts"), Integer.class)) {
amts = new LinkedList<>(config.getIntegerList("quests." + questKey + ".stages.ordered." amts = new LinkedList<>(config.getIntegerList(ordered + ".enchantment-amounts"));
+ stageNum + ".enchantment-amounts"));
} else { } else {
throw new StageFormatException("'enchantment-amounts' is not a list of numbers", quest, stageNum); throw new StageFormatException("'enchantment-amounts' is not a list of numbers", quest,
stageNum);
} }
} else { } else {
throw new StageFormatException("'enchantment-amounts' is missing", quest, stageNum); throw new StageFormatException("'enchantment-amounts' is missing", quest, stageNum);
@ -1191,9 +1155,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-brew")) { if (config.contains(ordered + ".items-to-brew")) {
itemsToBrew = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum itemsToBrew = (List<ItemStack>) config.get(ordered + ".items-to-brew");
+ ".items-to-brew");
if (BukkitConfigUtil.checkList(itemsToBrew, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToBrew, ItemStack.class)) {
for (final ItemStack stack : itemsToBrew) { for (final ItemStack stack : itemsToBrew) {
if (stack != null) { if (stack != null) {
@ -1206,9 +1169,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'items-to-brew' has invalid formatting", quest, stageNum); throw new StageFormatException("'items-to-brew' has invalid formatting", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-consume")) { if (config.contains(ordered + ".items-to-consume")) {
itemsToConsume = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum itemsToConsume = (List<ItemStack>) config.get(ordered + ".items-to-consume");
+ ".items-to-consume");
if (BukkitConfigUtil.checkList(itemsToConsume, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToConsume, ItemStack.class)) {
for (final ItemStack stack : itemsToConsume) { for (final ItemStack stack : itemsToConsume) {
if (stack != null) { if (stack != null) {
@ -1219,38 +1181,30 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk")) { if (config.contains(ordered + ".cows-to-milk")) {
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk", -999) if (config.getInt(ordered + ".cows-to-milk", -999) != -999) {
!= -999) { oStage.setCowsToMilk(config.getInt(ordered + ".cows-to-milk"));
oStage.setCowsToMilk(config.getInt("quests." + questKey + ".stages.ordered." + stageNum
+ ".cows-to-milk"));
} else { } else {
throw new StageFormatException("'cows-to-milk' is not a number", quest, stageNum); throw new StageFormatException("'cows-to-milk' is not a number", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch")) { if (config.contains(ordered + ".fish-to-catch")) {
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch", -999) if (config.getInt(ordered + ".fish-to-catch", -999) != -999) {
!= -999) { oStage.setFishToCatch(config.getInt(ordered + ".fish-to-catch"));
oStage.setFishToCatch(config.getInt("quests." + questKey + ".stages.ordered." + stageNum
+ ".fish-to-catch"));
} else { } else {
throw new StageFormatException("'fish-to-catch' is not a number", quest, stageNum); throw new StageFormatException("'fish-to-catch' is not a number", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill")) { if (config.contains(ordered + ".players-to-kill")) {
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill", -999) if (config.getInt(ordered + ".players-to-kill", -999) != -999) {
!= -999) { oStage.setPlayersToKill(config.getInt(ordered + ".players-to-kill"));
oStage.setPlayersToKill(config.getInt("quests." + questKey + ".stages.ordered." + stageNum
+ ".players-to-kill"));
} else { } else {
throw new StageFormatException("'players-to-kill' is not a number", quest, stageNum); throw new StageFormatException("'players-to-kill' is not a number", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-talk-to")) { if (config.contains(ordered + ".npc-uuids-to-talk-to")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-uuids-to-talk-to"), String.class)) {
+ ".npc-uuids-to-talk-to"), String.class)) { npcUuidsToTalkTo = config.getStringList(ordered + ".npc-uuids-to-talk-to");
npcUuidsToTalkTo = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".npc-uuids-to-talk-to");
for (final String s : npcUuidsToTalkTo) { for (final String s : npcUuidsToTalkTo) {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
oStage.addNpcToInteract(uuid); oStage.addNpcToInteract(uuid);
@ -1261,12 +1215,10 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'npc-uuids-to-talk-to' is not a list of numbers", quest, stageNum); throw new StageFormatException("'npc-uuids-to-talk-to' is not a list of numbers", quest, stageNum);
} }
} else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-talk-to")) { } else if (config.contains(ordered + ".npc-ids-to-talk-to")) {
// Legacy // Legacy
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-ids-to-talk-to"), Integer.class)) {
+ ".npc-ids-to-talk-to"), Integer.class)) { npcIdsToTalkTo = config.getIntegerList(ordered + ".npc-ids-to-talk-to");
npcIdsToTalkTo = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".npc-ids-to-talk-to");
for (final int i : npcIdsToTalkTo) { for (final int i : npcIdsToTalkTo) {
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
final NPC npc = CitizensAPI.getNPCRegistry().getById(i); final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
@ -1289,18 +1241,15 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'npc-ids-to-talk-to' is not a list of numbers", quest, stageNum); throw new StageFormatException("'npc-ids-to-talk-to' is not a list of numbers", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-deliver")) { if (config.contains(ordered + ".items-to-deliver")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-uuids")) { if (config.contains(ordered + ".npc-delivery-uuids")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered
+ ".npc-delivery-uuids"), String.class)) { + ".npc-delivery-uuids"), String.class)) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum if (config.contains(ordered
+ ".delivery-messages")) { + ".delivery-messages")) {
itemsToDeliver = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." itemsToDeliver = (List<ItemStack>) config.get(ordered + ".items-to-deliver");
+ stageNum + ".items-to-deliver"); itemDeliveryTargetUuids = config.getStringList(ordered + ".npc-delivery-uuids");
itemDeliveryTargetUuids = config.getStringList("quests." + questKey + ".stages.ordered." deliveryMessages = config.getStringList(ordered + ".delivery-messages");
+ stageNum + ".npc-delivery-uuids");
deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".delivery-messages");
int index = 0; int index = 0;
if (BukkitConfigUtil.checkList(itemsToDeliver, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
for (final ItemStack stack : itemsToDeliver) { for (final ItemStack stack : itemsToDeliver) {
@ -1323,26 +1272,19 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'npc-delivery-uuids' is not a list of numbers", quest, stageNum); throw new StageFormatException("'npc-delivery-uuids' is not a list of numbers", quest, stageNum);
} }
} else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum } else if (config.contains(ordered + ".npc-delivery-ids")) {
+ ".npc-delivery-ids")) {
// Legacy // Legacy
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-delivery-ids"), Integer.class)) {
+ ".npc-delivery-ids"), Integer.class)) { if (config.contains(ordered + ".delivery-messages")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum itemsToDeliver = (List<ItemStack>) config.get(ordered + ".items-to-deliver");
+ ".delivery-messages")) { itemDeliveryTargetIds = config.getIntegerList(ordered + ".npc-delivery-ids");
itemsToDeliver = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." deliveryMessages = config.getStringList(ordered + ".delivery-messages");
+ stageNum + ".items-to-deliver");
itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".npc-delivery-ids");
deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".delivery-messages");
int index = 0; int index = 0;
if (BukkitConfigUtil.checkList(itemsToDeliver, ItemStack.class)) { if (BukkitConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
for (final ItemStack stack : itemsToDeliver) { for (final ItemStack stack : itemsToDeliver) {
if (stack != null) { if (stack != null) {
final int npcId = itemDeliveryTargetIds.get(index); final int npcId = itemDeliveryTargetIds.get(index);
final String msg = deliveryMessages.size() > index final String msg = deliveryMessages.size() > index ? deliveryMessages.get(index)
? deliveryMessages.get(index)
: deliveryMessages.get(deliveryMessages.size() - 1); : deliveryMessages.get(deliveryMessages.size() - 1);
index++; index++;
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
@ -1373,16 +1315,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'npc-delivery-uuid' is missing", quest, stageNum); throw new StageFormatException("'npc-delivery-uuid' is missing", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-kill")) { if (config.contains(ordered + ".npc-uuids-to-kill")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-uuids-to-kill"), String.class)) {
+ ".npc-uuids-to-kill"), String.class)) { if (config.contains(ordered + ".npc-kill-amounts")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) { if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-kill-amounts"), Integer.class)) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum npcUuidsToKill = config.getStringList(ordered + ".npc-uuids-to-kill");
+ ".npc-kill-amounts"), Integer.class)) { npcAmountsToKill = config.getIntegerList(ordered + ".npc-kill-amounts");
npcUuidsToKill = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".npc-uuids-to-kill");
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".npc-kill-amounts");
for (final String s : npcUuidsToKill) { for (final String s : npcUuidsToKill) {
final UUID npcUuid = UUID.fromString(s); final UUID npcUuid = UUID.fromString(s);
if (npcAmountsToKill.get(npcUuidsToKill.indexOf(s)) > 0) { if (npcAmountsToKill.get(npcUuidsToKill.indexOf(s)) > 0) {
@ -1404,17 +1342,13 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'npc-kill-amounts' is missing", quest, stageNum); throw new StageFormatException("'npc-kill-amounts' is missing", quest, stageNum);
} }
} }
} else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-kill")) { } else if (config.contains(ordered + ".npc-ids-to-kill")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-ids-to-kill"), Integer.class)) {
+ ".npc-ids-to-kill"), Integer.class)) {
// Legacy // Legacy
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) { if (config.contains(ordered + ".npc-kill-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-kill-amounts"), Integer.class)) {
+ ".npc-kill-amounts"), Integer.class)) { npcIdsToKill = config.getIntegerList(ordered + ".npc-ids-to-kill");
npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum npcAmountsToKill = config.getIntegerList(ordered + ".npc-kill-amounts");
+ ".npc-ids-to-kill");
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".npc-kill-amounts");
for (final int i : npcIdsToKill) { for (final int i : npcIdsToKill) {
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
final NPC npc = CitizensAPI.getNPCRegistry().getById(i); final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
@ -1448,11 +1382,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} }
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-kill")) { if (config.contains(ordered + ".mobs-to-kill")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".mobs-to-kill"), String.class)) {
+ ".mobs-to-kill"), String.class)) { final List<String> mobNames = config.getStringList(ordered + ".mobs-to-kill");
final List<String> mobNames = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".mobs-to-kill");
for (final String mob : mobNames) { for (final String mob : mobNames) {
final EntityType type = BukkitMiscUtil.getProperMobType(mob); final EntityType type = BukkitMiscUtil.getProperMobType(mob);
if (type != null) { if (type != null) {
@ -1464,11 +1396,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'mobs-to-kill' is not a list of mob names", quest, stageNum); throw new StageFormatException("'mobs-to-kill' is not a list of mob names", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-amounts")) { if (config.contains(ordered + ".mob-amounts")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".mob-amounts"), Integer.class)) {
+ ".mob-amounts"), Integer.class)) { mobNumsToKill.addAll(config.getIntegerList(ordered + ".mob-amounts"));
mobNumsToKill.addAll(config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
+ ".mob-amounts"));
} else { } else {
throw new StageFormatException("'mob-amounts' is not a list of numbers", quest, stageNum); throw new StageFormatException("'mob-amounts' is not a list of numbers", quest, stageNum);
} }
@ -1476,11 +1406,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'mob-amounts' is missing", quest, stageNum); throw new StageFormatException("'mob-amounts' is missing", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-kill")) { if (config.contains(ordered + ".locations-to-kill")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".locations-to-kill"), String.class)) {
+ ".locations-to-kill"), String.class)) { final List<String> locations = config.getStringList(ordered + ".locations-to-kill");
final List<String> locations = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".locations-to-kill");
for (final String loc : locations) { for (final String loc : locations) {
if (BukkitConfigUtil.getLocation(loc) != null) { if (BukkitConfigUtil.getLocation(loc) != null) {
locationsToKillWithin.add(BukkitConfigUtil.getLocation(loc)); locationsToKillWithin.add(BukkitConfigUtil.getLocation(loc));
@ -1492,11 +1420,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'locations-to-kill' is not a list of locations", quest, stageNum); throw new StageFormatException("'locations-to-kill' is not a list of locations", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-radii")) { if (config.contains(ordered + ".kill-location-radii")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".kill-location-radii"), Integer.class)) {
+ ".kill-location-radii"), Integer.class)) { final List<Integer> radii = config.getIntegerList(ordered + ".kill-location-radii");
final List<Integer> radii = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".kill-location-radii");
radiiToKillWithin.addAll(radii); radiiToKillWithin.addAll(radii);
} else { } else {
throw new StageFormatException("'kill-location-radii' is not a list of numbers", quest, stageNum); throw new StageFormatException("'kill-location-radii' is not a list of numbers", quest, stageNum);
@ -1504,11 +1430,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'kill-location-radii' is missing", quest, stageNum); throw new StageFormatException("'kill-location-radii' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-names")) { if (config.contains(ordered + ".kill-location-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".kill-location-names"), String.class)) {
+ ".kill-location-names"), String.class)) { final List<String> locationNames = config.getStringList(ordered + ".kill-location-names");
final List<String> locationNames = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".kill-location-names");
areaNames.addAll(locationNames); areaNames.addAll(locationNames);
} else { } else {
throw new StageFormatException("'kill-location-names' is not a list of names", quest, stageNum); throw new StageFormatException("'kill-location-names' is not a list of names", quest, stageNum);
@ -1532,11 +1456,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
for (String killName : areaNames) { for (String killName : areaNames) {
oStage.addKillName(killName); oStage.addKillName(killName);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-reach")) { if (config.contains(ordered + ".locations-to-reach")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".locations-to-reach"), String.class)) {
+ ".locations-to-reach"), String.class)) { final List<String> locations = config.getStringList(ordered + ".locations-to-reach");
final List<String> locations = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
+ ".locations-to-reach");
for (final String loc : locations) { for (final String loc : locations) {
if (BukkitConfigUtil.getLocation(loc) != null) { if (BukkitConfigUtil.getLocation(loc) != null) {
oStage.addLocationToReach(BukkitConfigUtil.getLocation(loc)); oStage.addLocationToReach(BukkitConfigUtil.getLocation(loc));
@ -1548,11 +1470,10 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'locations-to-reach' is not a list of locations", quest, stageNum); throw new StageFormatException("'locations-to-reach' is not a list of locations", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-radii")) { if (config.contains(ordered + ".reach-location-radii")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered
+ ".reach-location-radii"), Integer.class)) { + ".reach-location-radii"), Integer.class)) {
final List<Integer> radii = config.getIntegerList("quests." + questKey + ".stages.ordered." final List<Integer> radii = config.getIntegerList(ordered + ".reach-location-radii");
+ stageNum + ".reach-location-radii");
for (Integer radius : radii) { for (Integer radius : radii) {
oStage.addRadiusToReachWithin(radius); oStage.addRadiusToReachWithin(radius);
} }
@ -1563,11 +1484,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
} else { } else {
throw new StageFormatException("'reach-location-radii' is missing", quest, stageNum); throw new StageFormatException("'reach-location-radii' is missing", quest, stageNum);
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-names")) { if (config.contains(ordered + ".reach-location-names")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".reach-location-names"), String.class)) {
+ ".reach-location-names"), String.class)) { final List<String> locationNames = config.getStringList(ordered + ".reach-location-names");
final List<String> locationNames = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".reach-location-names");
for (String locationName : locationNames) { for (String locationName : locationNames) {
oStage.addLocationName(locationName); oStage.addLocationName(locationName);
} }
@ -1578,16 +1497,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'reach-location-names' is missing", quest, stageNum); throw new StageFormatException("'reach-location-names' is missing", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-tame")) { if (config.contains(ordered + ".mobs-to-tame")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".mobs-to-tame"), String.class)) {
+ ".mobs-to-tame"), String.class)) { if (config.contains(ordered + ".mob-tame-amounts")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-tame-amounts")) { if (BukkitConfigUtil.checkList(config.getList(ordered + ".mob-tame-amounts"), Integer.class)) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum final List<String> mobs = config.getStringList(ordered + ".mobs-to-tame");
+ ".mob-tame-amounts"), Integer.class)) { final List<Integer> mobAmounts = config.getIntegerList(ordered + ".mob-tame-amounts");
final List<String> mobs = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".mobs-to-tame");
final List<Integer> mobAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered."
+ stageNum + ".mob-tame-amounts");
for (final String mob : mobs) { for (final String mob : mobs) {
final EntityType type = BukkitMiscUtil.getProperMobType(mob); final EntityType type = BukkitMiscUtil.getProperMobType(mob);
if (type != null) { if (type != null) {
@ -1600,7 +1515,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
quest, stageNum); quest, stageNum);
} }
} else { } else {
throw new StageFormatException("'mobs-to-tame' has invalid mob name " + mob, quest, stageNum); throw new StageFormatException("'mobs-to-tame' has invalid mob name " + mob, quest,
stageNum);
} }
} }
} else { } else {
@ -1614,16 +1530,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'mobs-to-tame' is not a list of mob names", quest, stageNum); throw new StageFormatException("'mobs-to-tame' is not a list of mob names", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-to-shear")) { if (config.contains(ordered + ".sheep-to-shear")) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum if (BukkitConfigUtil.checkList(config.getList(ordered + ".sheep-to-shear"), String.class)) {
+ ".sheep-to-shear"), String.class)) { if (config.contains(ordered + ".sheep-amounts")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-amounts")) { if (BukkitConfigUtil.checkList(config.getList(ordered + ".sheep-amounts"), Integer.class)) {
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum final List<String> sheep = config.getStringList(ordered + ".sheep-to-shear");
+ ".sheep-amounts"), Integer.class)) { final List<Integer> shearAmounts = config.getIntegerList(ordered + ".sheep-amounts");
final List<String> sheep = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".sheep-to-shear");
final List<Integer> shearAmounts = config.getIntegerList("quests." + questKey
+ ".stages.ordered." + stageNum + ".sheep-amounts");
for (String sheepColor : sheep) { for (String sheepColor : sheep) {
final String originalColor = sheepColor; final String originalColor = sheepColor;
DyeColor dc = null; DyeColor dc = null;
@ -1697,12 +1609,10 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'sheep-to-shear' is not a list of colors", quest, stageNum); throw new StageFormatException("'sheep-to-shear' is not a list of colors", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-displays")) { if (config.contains(ordered + ".password-displays")) {
final List<String> displays = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum final List<String> displays = config.getStringList(ordered + ".password-displays");
+ ".password-displays"); if (config.contains(ordered + ".password-phrases")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-phrases")) { final List<String> phrases = config.getStringList(ordered + ".password-phrases");
final List<String> phrases = config.getStringList("quests." + questKey + ".stages.ordered."
+ stageNum + ".password-phrases");
if (displays.size() == phrases.size()) { if (displays.size() == phrases.size()) {
for (int passIndex = 0; passIndex < displays.size(); passIndex++) { for (int passIndex = 0; passIndex < displays.size(); passIndex++) {
oStage.addPasswordDisplay(displays.get(passIndex)); oStage.addPasswordDisplay(displays.get(passIndex));
@ -1716,24 +1626,20 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'password-phrases' is missing", quest, stageNum); throw new StageFormatException("'password-phrases' is missing", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override")) { if (config.contains(ordered + ".objective-override")) {
final Object o = config.get("quests." + questKey + ".stages.ordered." + stageNum final Object o = config.get(ordered + ".objective-override");
+ ".objective-override");
if (o instanceof List) { if (o instanceof List) {
for (String objectiveOverride : config.getStringList("quests." + questKey for (String objectiveOverride : config.getStringList(ordered + ".objective-override")) {
+ ".stages.ordered." + stageNum + ".objective-override")) {
oStage.addObjectiveOverride(objectiveOverride); oStage.addObjectiveOverride(objectiveOverride);
} }
} else { } else {
// Legacy // Legacy
final String s = config.getString("quests." + questKey + ".stages.ordered." + stageNum final String s = config.getString(ordered + ".objective-override");
+ ".objective-override");
oStage.addObjectiveOverride(s); oStage.addObjectiveOverride(s);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) { if (config.contains(ordered + ".start-event")) {
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum final String actionName = config.getString(ordered + ".start-event");
+ ".start-event");
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
.filter(a -> a.getName().equals(actionName)).findAny(); .filter(a -> a.getName().equals(actionName)).findAny();
if (action.isPresent()) { if (action.isPresent()) {
@ -1742,9 +1648,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'start-event' failed to load", quest, stageNum); throw new StageFormatException("'start-event' failed to load", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")) { if (config.contains(ordered + ".finish-event")) {
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum final String actionName = config.getString(ordered + ".finish-event");
+ ".finish-event");
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
.filter(a -> a.getName().equals(actionName)).findAny(); .filter(a -> a.getName().equals(actionName)).findAny();
if (action.isPresent()) { if (action.isPresent()) {
@ -1753,9 +1658,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'finish-event' failed to load", quest, stageNum); throw new StageFormatException("'finish-event' failed to load", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fail-event")) { if (config.contains(ordered + ".fail-event")) {
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum final String actionName = config.getString(ordered + ".fail-event");
+ ".fail-event");
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
.filter(a -> a.getName().equals(actionName)).findAny(); .filter(a -> a.getName().equals(actionName)).findAny();
if (action.isPresent()) { if (action.isPresent()) {
@ -1764,9 +1668,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'fail-event' failed to load", quest, stageNum); throw new StageFormatException("'fail-event' failed to load", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")) { if (config.contains(ordered + ".death-event")) {
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum final String actionName = config.getString(ordered + ".death-event");
+ ".death-event");
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
.filter(a -> a.getName().equals(actionName)).findAny(); .filter(a -> a.getName().equals(actionName)).findAny();
if (action.isPresent()) { if (action.isPresent()) {
@ -1775,9 +1678,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'death-event' failed to load", quest, stageNum); throw new StageFormatException("'death-event' failed to load", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")) { if (config.contains(ordered + ".disconnect-event")) {
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum final String actionName = config.getString(ordered + ".disconnect-event");
+ ".disconnect-event");
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
.filter(a -> a.getName().equals(actionName)).findAny(); .filter(a -> a.getName().equals(actionName)).findAny();
if (action.isPresent()) { if (action.isPresent()) {
@ -1786,16 +1688,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'disconnect-event' failed to load", quest, stageNum); throw new StageFormatException("'disconnect-event' failed to load", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) { if (config.contains(ordered + ".chat-events")) {
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) { if (config.isList(ordered + ".chat-events")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum if (config.contains(ordered + ".chat-event-triggers")) {
+ ".chat-event-triggers")) { if (config.isList(ordered + ".chat-event-triggers")) {
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum final List<String> chatEvents = config.getStringList(ordered + ".chat-events");
+ ".chat-event-triggers")) { final List<String> chatEventTriggers = config.getStringList(ordered + ".chat-event-triggers");
final List<String> chatEvents = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".chat-events");
final List<String> chatEventTriggers = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".chat-event-triggers");
for (int i = 0; i < chatEvents.size(); i++) { for (int i = 0; i < chatEvents.size(); i++) {
final String actionName = chatEvents.get(i); final String actionName = chatEvents.get(i);
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
@ -1824,16 +1722,13 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'chat-events' is not in list format", quest, stageNum); throw new StageFormatException("'chat-events' is not in list format", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) { if (config.contains(ordered + ".command-events")) {
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) { if (config.isList(ordered + ".command-events")) {
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum if (config.contains(ordered + ".command-event-triggers")) {
+ ".command-event-triggers")) { if (config.isList(ordered + ".command-event-triggers")) {
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum final List<String> commandEvents = config.getStringList(ordered + ".command-events");
+ ".command-event-triggers")) { final List<String> commandEventTriggers = config.getStringList(ordered
final List<String> commandEvents = config.getStringList("quests." + questKey + ".command-event-triggers");
+ ".stages.ordered." + stageNum + ".command-events");
final List<String> commandEventTriggers = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".command-event-triggers");
for (int i = 0; i < commandEvents.size(); i++) { for (int i = 0; i < commandEvents.size(); i++) {
final String actionName = commandEvents.get(i); final String actionName = commandEvents.get(i);
final Optional<Action> action = plugin.getLoadedActions().stream() final Optional<Action> action = plugin.getLoadedActions().stream()
@ -1862,9 +1757,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'command-events' is not in list format", quest, stageNum); throw new StageFormatException("'command-events' is not in list format", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".condition")) { if (config.contains(ordered + ".condition")) {
final String conditionName = config.getString("quests." + questKey + ".stages.ordered." final String conditionName = config.getString(ordered + ".condition");
+ stageNum + ".condition");
final Optional<Condition> condition = plugin.getLoadedConditions().stream() final Optional<Condition> condition = plugin.getLoadedConditions().stream()
.filter(c -> c.getName().equals(conditionName)).findAny(); .filter(c -> c.getName().equals(conditionName)).findAny();
if (condition.isPresent()) { if (condition.isPresent()) {
@ -1873,25 +1767,22 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
throw new StageFormatException("'condition' failed to load", quest, stageNum); throw new StageFormatException("'condition' failed to load", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) { if (config.contains(ordered + ".delay")) {
final int delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999); final int delay = config.getInt(ordered + ".delay", -999);
if (delay > 0) { if (delay > 0) {
oStage.setDelay(delay * 1000L); oStage.setDelay(delay * 1000L);
} else if (delay != -999) { } else if (delay != -999) {
throw new StageFormatException("'delay' is not a positive number", quest, stageNum); throw new StageFormatException("'delay' is not a positive number", quest, stageNum);
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay-message")) { if (config.contains(ordered + ".delay-message")) {
oStage.setDelayMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum oStage.setDelayMessage(config.getString(ordered + ".delay-message"));
+ ".delay-message"));
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-message")) { if (config.contains(ordered + ".start-message")) {
oStage.setStartMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum oStage.setStartMessage(config.getString(ordered + ".start-message"));
+ ".start-message"));
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".complete-message")) { if (config.contains(ordered + ".complete-message")) {
oStage.setCompleteMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum oStage.setCompleteMessage(config.getString(ordered + ".complete-message"));
+ ".complete-message"));
} }
quest.getStages().add(oStage); quest.getStages().add(oStage);
} }

View File

@ -152,7 +152,7 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
quester.setCurrentQuests(currentQuests); quester.setCurrentQuests(currentQuests);
final ConfigurationSection dataSec = data.getConfigurationSection("questData"); final ConfigurationSection dataSec = data.getConfigurationSection("questData");
if (dataSec == null || dataSec.getKeys(false).isEmpty()) { if (dataSec == null || dataSec.getKeys(false).isEmpty()) {
return null; return quester;
} }
final ConcurrentHashMap<Quest, BukkitQuestProgress> questProgress = new ConcurrentHashMap<>(); final ConcurrentHashMap<Quest, BukkitQuestProgress> questProgress = new ConcurrentHashMap<>();
for (final String key : dataSec.getKeys(false)) { for (final String key : dataSec.getKeys(false)) {
@ -172,100 +172,100 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
if (questSec == null) { if (questSec == null) {
continue; continue;
} }
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) quester.getQuestDataOrDefault(quest); final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(quest);
if (questSec.contains("blocks-broken-amounts")) { if (questSec.contains("blocks-broken-amounts")) {
final List<Integer> brokenAmounts = questSec.getIntegerList("blocks-broken-amounts"); final List<Integer> brokenAmounts = questSec.getIntegerList("blocks-broken-amounts");
bukkitQuestData.setBlocksBroken(new LinkedList<>(brokenAmounts)); bukkitQuestProgress.setBlocksBroken(new LinkedList<>(brokenAmounts));
} }
if (questSec.contains("blocks-damaged-amounts")) { if (questSec.contains("blocks-damaged-amounts")) {
final List<Integer> damagedAmounts = questSec.getIntegerList("blocks-damaged-amounts"); final List<Integer> damagedAmounts = questSec.getIntegerList("blocks-damaged-amounts");
bukkitQuestData.setBlocksDamaged(new LinkedList<>(damagedAmounts)); bukkitQuestProgress.setBlocksDamaged(new LinkedList<>(damagedAmounts));
} }
if (questSec.contains("blocks-placed-amounts")) { if (questSec.contains("blocks-placed-amounts")) {
final List<Integer> placedAmounts = questSec.getIntegerList("blocks-placed-amounts"); final List<Integer> placedAmounts = questSec.getIntegerList("blocks-placed-amounts");
bukkitQuestData.setBlocksPlaced(new LinkedList<>(placedAmounts)); bukkitQuestProgress.setBlocksPlaced(new LinkedList<>(placedAmounts));
} }
if (questSec.contains("blocks-used-amounts")) { if (questSec.contains("blocks-used-amounts")) {
final List<Integer> usedAmounts = questSec.getIntegerList("blocks-used-amounts"); final List<Integer> usedAmounts = questSec.getIntegerList("blocks-used-amounts");
bukkitQuestData.setBlocksUsed(new LinkedList<>(usedAmounts)); bukkitQuestProgress.setBlocksUsed(new LinkedList<>(usedAmounts));
} }
if (questSec.contains("blocks-cut-amounts")) { if (questSec.contains("blocks-cut-amounts")) {
final List<Integer> cutAmounts = questSec.getIntegerList("blocks-cut-amounts"); final List<Integer> cutAmounts = questSec.getIntegerList("blocks-cut-amounts");
bukkitQuestData.setBlocksCut(new LinkedList<>(cutAmounts)); bukkitQuestProgress.setBlocksCut(new LinkedList<>(cutAmounts));
} }
if (questSec.contains("item-craft-amounts")) { if (questSec.contains("item-craft-amounts")) {
final List<Integer> craftAmounts = questSec.getIntegerList("item-craft-amounts"); final List<Integer> craftAmounts = questSec.getIntegerList("item-craft-amounts");
bukkitQuestData.setItemsCrafted(new LinkedList<>(craftAmounts)); bukkitQuestProgress.setItemsCrafted(new LinkedList<>(craftAmounts));
} }
if (questSec.contains("item-smelt-amounts")) { if (questSec.contains("item-smelt-amounts")) {
final List<Integer> smeltAmounts = questSec.getIntegerList("item-smelt-amounts"); final List<Integer> smeltAmounts = questSec.getIntegerList("item-smelt-amounts");
bukkitQuestData.setItemsSmelted(new LinkedList<>(smeltAmounts)); bukkitQuestProgress.setItemsSmelted(new LinkedList<>(smeltAmounts));
} }
if (questSec.contains("item-enchant-amounts")) { if (questSec.contains("item-enchant-amounts")) {
final List<Integer> enchantAmounts = questSec.getIntegerList("item-enchant-amounts"); final List<Integer> enchantAmounts = questSec.getIntegerList("item-enchant-amounts");
bukkitQuestData.setItemsEnchanted(new LinkedList<>(enchantAmounts)); bukkitQuestProgress.setItemsEnchanted(new LinkedList<>(enchantAmounts));
} }
if (questSec.contains("item-brew-amounts")) { if (questSec.contains("item-brew-amounts")) {
final List<Integer> brewAmounts = questSec.getIntegerList("item-brew-amounts"); final List<Integer> brewAmounts = questSec.getIntegerList("item-brew-amounts");
bukkitQuestData.setItemsBrewed(new LinkedList<>(brewAmounts)); bukkitQuestProgress.setItemsBrewed(new LinkedList<>(brewAmounts));
} }
if (questSec.contains("item-consume-amounts")) { if (questSec.contains("item-consume-amounts")) {
final List<Integer> consumeAmounts = questSec.getIntegerList("item-consume-amounts"); final List<Integer> consumeAmounts = questSec.getIntegerList("item-consume-amounts");
bukkitQuestData.setItemsConsumed(new LinkedList<>(consumeAmounts)); bukkitQuestProgress.setItemsConsumed(new LinkedList<>(consumeAmounts));
} }
if (questSec.contains("item-delivery-amounts")) { if (questSec.contains("item-delivery-amounts")) {
final List<Integer> deliveryAmounts = questSec.getIntegerList("item-delivery-amounts"); final List<Integer> deliveryAmounts = questSec.getIntegerList("item-delivery-amounts");
bukkitQuestData.setItemsDelivered(new LinkedList<>(deliveryAmounts)); bukkitQuestProgress.setItemsDelivered(new LinkedList<>(deliveryAmounts));
} }
if (questSec.contains("has-talked-to")) { if (questSec.contains("has-talked-to")) {
final List<Boolean> talkAmount = questSec.getBooleanList("has-talked-to"); final List<Boolean> talkAmount = questSec.getBooleanList("has-talked-to");
bukkitQuestData.setNpcsInteracted(new LinkedList<>(talkAmount)); bukkitQuestProgress.setNpcsInteracted(new LinkedList<>(talkAmount));
} }
if (questSec.contains("npc-killed-amounts")) { if (questSec.contains("npc-killed-amounts")) {
final List<Integer> npcAmounts = questSec.getIntegerList("npc-killed-amounts"); final List<Integer> npcAmounts = questSec.getIntegerList("npc-killed-amounts");
bukkitQuestData.setNpcsNumKilled(new LinkedList<>(npcAmounts)); bukkitQuestProgress.setNpcsNumKilled(new LinkedList<>(npcAmounts));
} else if (questSec.contains("citizen-amounts-killed")) { } else if (questSec.contains("citizen-amounts-killed")) {
// Legacy // Legacy
final List<Integer> npcAmounts = questSec.getIntegerList("citizen-amounts-killed"); final List<Integer> npcAmounts = questSec.getIntegerList("citizen-amounts-killed");
bukkitQuestData.setNpcsNumKilled(new LinkedList<>(npcAmounts)); bukkitQuestProgress.setNpcsNumKilled(new LinkedList<>(npcAmounts));
} }
if (questSec.contains("cows-milked")) { if (questSec.contains("cows-milked")) {
bukkitQuestData.setCowsMilked(questSec.getInt("cows-milked")); bukkitQuestProgress.setCowsMilked(questSec.getInt("cows-milked"));
} }
if (questSec.contains("fish-caught")) { if (questSec.contains("fish-caught")) {
bukkitQuestData.setFishCaught(questSec.getInt("fish-caught")); bukkitQuestProgress.setFishCaught(questSec.getInt("fish-caught"));
} }
if (questSec.contains("players-killed")) { if (questSec.contains("players-killed")) {
bukkitQuestData.setPlayersKilled(questSec.getInt("players-killed")); bukkitQuestProgress.setPlayersKilled(questSec.getInt("players-killed"));
} }
if (questSec.contains("mobs-killed-amounts")) { if (questSec.contains("mobs-killed-amounts")) {
final List<Integer> mobAmounts = questSec.getIntegerList("mobs-killed-amounts"); final List<Integer> mobAmounts = questSec.getIntegerList("mobs-killed-amounts");
bukkitQuestData.setMobNumKilled(new LinkedList<>(mobAmounts)); bukkitQuestProgress.setMobNumKilled(new LinkedList<>(mobAmounts));
} }
if (questSec.contains("has-reached-location")) { if (questSec.contains("has-reached-location")) {
final List<Boolean> hasReached = questSec.getBooleanList("has-reached-location"); final List<Boolean> hasReached = questSec.getBooleanList("has-reached-location");
bukkitQuestData.setLocationsReached(new LinkedList<>(hasReached)); bukkitQuestProgress.setLocationsReached(new LinkedList<>(hasReached));
} }
if (questSec.contains("mob-tame-amounts")) { if (questSec.contains("mob-tame-amounts")) {
final List<Integer> tameAmounts = questSec.getIntegerList("mob-tame-amounts"); final List<Integer> tameAmounts = questSec.getIntegerList("mob-tame-amounts");
bukkitQuestData.setMobsTamed(new LinkedList<>(tameAmounts)); bukkitQuestProgress.setMobsTamed(new LinkedList<>(tameAmounts));
} }
if (questSec.contains("sheep-sheared")) { if (questSec.contains("sheep-sheared")) {
final List<Integer> sheepAmounts = questSec.getIntegerList("sheep-sheared"); final List<Integer> sheepAmounts = questSec.getIntegerList("sheep-sheared");
bukkitQuestData.setSheepSheared(new LinkedList<>(sheepAmounts)); bukkitQuestProgress.setSheepSheared(new LinkedList<>(sheepAmounts));
} }
if (questSec.contains("passwords-said")) { if (questSec.contains("passwords-said")) {
final List<Boolean> passAmounts = questSec.getBooleanList("passwords-said"); final List<Boolean> passAmounts = questSec.getBooleanList("passwords-said");
bukkitQuestData.setPasswordsSaid(new LinkedList<>(passAmounts)); bukkitQuestProgress.setPasswordsSaid(new LinkedList<>(passAmounts));
} }
if (questSec.contains("custom-objective-counts")) { if (questSec.contains("custom-objective-counts")) {
final List<Integer> customObjCounts = questSec.getIntegerList("custom-objective-counts"); final List<Integer> customObjCounts = questSec.getIntegerList("custom-objective-counts");
bukkitQuestData.setCustomObjectiveCounts(new LinkedList<>(customObjCounts)); bukkitQuestProgress.setCustomObjectiveCounts(new LinkedList<>(customObjCounts));
} }
if (questSec.contains("stage-delay")) { if (questSec.contains("stage-delay")) {
bukkitQuestData.setDelayTimeLeft(questSec.getLong("stage-delay")); bukkitQuestProgress.setDelayTimeLeft(questSec.getLong("stage-delay"));
} }
questProgress.put(quest, bukkitQuestData); questProgress.put(quest, bukkitQuestProgress);
} }
quester.setQuestProgress(questProgress); quester.setQuestProgress(questProgress);
} }

View File

@ -261,9 +261,9 @@ public class BukkitQuesterSqlStorage implements QuesterStorageImpl {
final Set<String> redoableQuests = bukkitQuester.getCompletedTimes().keySet().stream().map(Quest::getId).collect(Collectors.toSet()); final Set<String> redoableQuests = bukkitQuester.getCompletedTimes().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
final Set<String> oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet()); final Set<String> oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
oldRedoableQuests.removeAll(redoableQuests); oldRedoableQuests.removeAll(redoableQuests);
final Set<String> questData = bukkitQuester.getQuestProgress().keySet().stream().map(Quest::getId).collect(Collectors.toSet()); final Set<String> questProgress = bukkitQuester.getQuestProgress().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
final Set<String> oldQuestData = getQuesterQuestProgress(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet()); final Set<String> oldQuestData = getQuesterQuestProgress(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
oldQuestData.removeAll(questData); oldQuestData.removeAll(questProgress);
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
if (oldLastKnownName != null && lastKnownName != null && !lastKnownName.equals(oldLastKnownName)) { if (oldLastKnownName != null && lastKnownName != null && !lastKnownName.equals(oldLastKnownName)) {

View File

@ -31,7 +31,7 @@ public class BukkitStageTimer implements Runnable {
if (quester == null) { if (quester == null) {
return; return;
} }
if (quester.getQuestDataOrDefault(quest) == null) { if (quester.getQuestProgressOrDefault(quest) == null) {
return; return;
} }
if (quester.getCurrentStage(quest) == null) { if (quester.getCurrentStage(quest) == null) {
@ -50,8 +50,8 @@ public class BukkitStageTimer implements Runnable {
quest.completeQuest(quester); quest.completeQuest(quester);
} else { } else {
final int stageNum = quester.getCurrentQuests().get(quest) + 1; final int stageNum = quester.getCurrentQuests().get(quest) + 1;
quester.getQuestDataOrDefault(quest).setDelayStartTime(0); quester.getQuestProgressOrDefault(quest).setDelayStartTime(0);
quester.getQuestDataOrDefault(quest).setDelayTimeLeft(-1); quester.getQuestProgressOrDefault(quest).setDelayTimeLeft(-1);
try { try {
quest.setStage(quester, stageNum); quest.setStage(quester, stageNum);
} catch (final IndexOutOfBoundsException e) { } catch (final IndexOutOfBoundsException e) {