mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-21 18:15:32 +01:00
Track progress through int, part 6. See #2250
This commit is contained in:
parent
217620a4db
commit
db83260706
@ -100,8 +100,13 @@ public interface Quester extends Comparable<Quester> {
|
||||
|
||||
Stage getCurrentStage(final Quest quest);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getQuestProgressOrDefault(Quest)} instead
|
||||
*/
|
||||
QuestProgress getQuestDataOrDefault(final Quest quest);
|
||||
|
||||
QuestProgress getQuestProgressOrDefault(final Quest quest);
|
||||
|
||||
boolean hasJournal();
|
||||
|
||||
ItemStack getJournal();
|
||||
|
@ -701,6 +701,10 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
|
||||
questLoader.init();
|
||||
for (final Quester quester : questers) {
|
||||
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()) {
|
||||
loaded.checkQuest(quest);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class BukkitQuestCommandHandler {
|
||||
for (final Quest q : quester.getCurrentQuests().keySet()) {
|
||||
final Stage stage = quester.getCurrentStage(q);
|
||||
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) {
|
||||
final String msg = BukkitLang.get(player, "questObjectivesTitle")
|
||||
.replace("<quest>", q.getName());
|
||||
|
@ -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()) {
|
||||
// Ignore blocks broken once replaced (self)
|
||||
if (currentStage.containsObjective(placeType)) {
|
||||
for (int i = 0; i < questData.blocksPlaced.size(); i++) {
|
||||
final int progress = questData.blocksPlaced.get(i) - 1;
|
||||
for (int i = 0; i < questProgress.blocksPlaced.size(); i++) {
|
||||
final int progress = questProgress.blocksPlaced.get(i) - 1;
|
||||
if (progress < 0) {
|
||||
break;
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class BukkitBlockListener implements Listener {
|
||||
new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
questData.blocksPlaced.set(i, progress);
|
||||
questProgress.blocksPlaced.set(i, progress);
|
||||
|
||||
final BukkitQuesterPostUpdateObjectiveEvent postEvent
|
||||
= new BukkitQuesterPostUpdateObjectiveEvent(quester, quest,
|
||||
@ -134,9 +134,9 @@ public class BukkitBlockListener implements Listener {
|
||||
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
|
||||
final BukkitQuestProgress qQuestData = (BukkitQuestProgress) q.getQuestDataOrDefault(cq);
|
||||
for (int i = 0; i < qQuestData.blocksPlaced.size(); i++) {
|
||||
final int progress = qQuestData.blocksPlaced.get(i) - 1;
|
||||
final BukkitQuestProgress qQuestProgress = (BukkitQuestProgress) q.getQuestProgressOrDefault(cq);
|
||||
for (int i = 0; i < qQuestProgress.blocksPlaced.size(); i++) {
|
||||
final int progress = qQuestProgress.blocksPlaced.get(i) - 1;
|
||||
if (progress < 0) {
|
||||
break;
|
||||
}
|
||||
@ -154,7 +154,7 @@ public class BukkitBlockListener implements Listener {
|
||||
new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
qQuestData.blocksPlaced.set(i, progress);
|
||||
qQuestProgress.blocksPlaced.set(i, progress);
|
||||
|
||||
final BukkitQuesterPostUpdateObjectiveEvent postEvent
|
||||
= new BukkitQuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq,
|
||||
@ -250,12 +250,12 @@ public class BukkitBlockListener implements Listener {
|
||||
quester.placeBlock(quest, blockItemStack);
|
||||
}
|
||||
|
||||
final BukkitQuestProgress questData = (BukkitQuestProgress) quester.getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress questProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(quest);
|
||||
if (quest.getOptions().canIgnoreBlockReplace()) {
|
||||
// Ignore blocks replaced once broken (self)
|
||||
if (currentStage.containsObjective(breakType)) {
|
||||
for (int i = 0; i < questData.blocksBroken.size(); i++) {
|
||||
final int progress = questData.blocksBroken.get(i) - 1;
|
||||
for (int i = 0; i < questProgress.blocksBroken.size(); i++) {
|
||||
final int progress = questProgress.blocksBroken.get(i) - 1;
|
||||
if (progress < 0) {
|
||||
break;
|
||||
}
|
||||
@ -273,7 +273,7 @@ public class BukkitBlockListener implements Listener {
|
||||
new BukkitObjective(placeType, null, is.getAmount(), goal.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
questData.blocksBroken.set(i, progress);
|
||||
questProgress.blocksBroken.set(i, progress);
|
||||
|
||||
final BukkitQuesterPostUpdateObjectiveEvent postEvent
|
||||
= new BukkitQuesterPostUpdateObjectiveEvent(quester, quest,
|
||||
@ -286,9 +286,9 @@ public class BukkitBlockListener implements Listener {
|
||||
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
|
||||
final BukkitQuestProgress qQuestData = (BukkitQuestProgress) q.getQuestDataOrDefault(cq);
|
||||
for (final int i : new LinkedList<>(qQuestData.blocksBroken)) {
|
||||
final int progress = qQuestData.blocksBroken.get(i) - 1;
|
||||
final BukkitQuestProgress qQuestProgress = (BukkitQuestProgress) q.getQuestProgressOrDefault(cq);
|
||||
for (final int i : new LinkedList<>(qQuestProgress.blocksBroken)) {
|
||||
final int progress = qQuestProgress.blocksBroken.get(i) - 1;
|
||||
if (progress < 0) {
|
||||
break;
|
||||
}
|
||||
@ -306,7 +306,7 @@ public class BukkitBlockListener implements Listener {
|
||||
new BukkitObjective(breakType, null, is.getAmount(), goal.getAmount()));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
qQuestData.blocksBroken.set(i, progress);
|
||||
qQuestProgress.blocksBroken.set(i, progress);
|
||||
|
||||
final BukkitQuesterPostUpdateObjectiveEvent postEvent
|
||||
= new BukkitQuesterPostUpdateObjectiveEvent((BukkitQuester) q, cq,
|
||||
|
@ -199,9 +199,9 @@ public class BukkitCitizensListener implements Listener {
|
||||
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNPC().getUniqueId())) {
|
||||
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNPC()
|
||||
.getUniqueId());
|
||||
if (quester.getQuestDataOrDefault(quest) != null && npcIndex > -1) {
|
||||
if (quester.getQuestProgressOrDefault(quest) != null && npcIndex > -1) {
|
||||
final LinkedList<Boolean> interacted
|
||||
= ((BukkitQuestProgress) quester.getQuestDataOrDefault(quest)).npcsInteracted;
|
||||
= ((BukkitQuestProgress) quester.getQuestProgressOrDefault(quest)).npcsInteracted;
|
||||
if (interacted.size() > npcIndex && !interacted.get(npcIndex)) {
|
||||
hasObjective = true;
|
||||
}
|
||||
|
@ -195,8 +195,8 @@ public class BukkitZnpcsApiListener implements Listener {
|
||||
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUuid())) {
|
||||
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc()
|
||||
.getUuid());
|
||||
if (quester.getQuestDataOrDefault(quest) != null && npcIndex > -1
|
||||
&& !((BukkitQuestProgress) quester.getQuestDataOrDefault(quest)).npcsInteracted.get(npcIndex)) {
|
||||
if (quester.getQuestProgressOrDefault(quest) != null && npcIndex > -1
|
||||
&& !((BukkitQuestProgress) quester.getQuestProgressOrDefault(quest)).npcsInteracted.get(npcIndex)) {
|
||||
hasObjective = true;
|
||||
}
|
||||
quester.interactWithNPC(quest, event.getNpc().getUuid());
|
||||
|
@ -203,8 +203,8 @@ public class BukkitZnpcsListener implements Listener {
|
||||
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUUID())) {
|
||||
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc()
|
||||
.getUUID());
|
||||
if (quester.getQuestDataOrDefault(quest) != null && npcIndex > -1
|
||||
&& !((BukkitQuestProgress) quester.getQuestDataOrDefault(quest)).npcsInteracted.get(npcIndex)) {
|
||||
if (quester.getQuestProgressOrDefault(quest) != null && npcIndex > -1
|
||||
&& !((BukkitQuestProgress) quester.getQuestProgressOrDefault(quest)).npcsInteracted.get(npcIndex)) {
|
||||
hasObjective = true;
|
||||
}
|
||||
quester.interactWithNPC(quest, event.getNpc().getUUID());
|
||||
|
@ -222,8 +222,8 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
|
||||
return;
|
||||
}
|
||||
int index = -1;
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) quester.getQuestDataOrDefault(bukkitQuest);
|
||||
final LinkedList<Integer> customObjCounts = bukkitQuestData.customObjectiveCounts;
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(bukkitQuest);
|
||||
final LinkedList<Integer> customObjCounts = bukkitQuestProgress.customObjectiveCounts;
|
||||
for (final CustomObjective co : quester.getCurrentStage(bukkitQuest).getCustomObjectives()) {
|
||||
index++;
|
||||
if (co.getName().equals(this.getName())) {
|
||||
@ -233,7 +233,7 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
|
||||
continue;
|
||||
}
|
||||
final int old = customObjCounts.get(index);
|
||||
bukkitQuestData.customObjectiveCounts.set(index, old + count);
|
||||
bukkitQuestProgress.customObjectiveCounts.set(index, old + count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -253,9 +253,9 @@ public class BukkitCustomObjective implements CustomObjective, Listener {
|
||||
// Multiplayer
|
||||
final int finalIndex = index;
|
||||
quester.dispatchMultiplayerObjectives(bukkitQuest, quester.getCurrentStage(bukkitQuest), (final Quester q) -> {
|
||||
final BukkitQuestProgress qBukkitQuestData = (BukkitQuestProgress) q.getQuestDataOrDefault(bukkitQuest);
|
||||
final int old = qBukkitQuestData.customObjectiveCounts.get(finalIndex);
|
||||
qBukkitQuestData.customObjectiveCounts.set(finalIndex, old + count);
|
||||
final BukkitQuestProgress qBukkitQuestProgress = (BukkitQuestProgress) q.getQuestProgressOrDefault(bukkitQuest);
|
||||
final int old = qBukkitQuestProgress.customObjectiveCounts.get(finalIndex);
|
||||
qBukkitQuestProgress.customObjectiveCounts.set(finalIndex, old + count);
|
||||
q.finishObjective(bukkitQuest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, bukkitCustomObj);
|
||||
return null;
|
||||
|
@ -422,6 +422,17 @@ public class BukkitQuester implements Quester {
|
||||
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
|
||||
*
|
||||
@ -429,7 +440,7 @@ public class BukkitQuester implements Quester {
|
||||
* @return Existing or current progress, or default
|
||||
*/
|
||||
@Override
|
||||
public QuestProgress getQuestDataOrDefault(final Quest quest) {
|
||||
public QuestProgress getQuestProgressOrDefault(final Quest quest) {
|
||||
if (questProgress.get(quest) != null) {
|
||||
return questProgress.get(quest);
|
||||
}
|
||||
@ -1168,7 +1179,7 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getLogger().severe("Quest was null when getting objectives for " + getLastKnownName());
|
||||
return new LinkedList<>();
|
||||
}
|
||||
if (getQuestDataOrDefault(quest) == null) {
|
||||
if (getQuestProgressOrDefault(quest) == null) {
|
||||
plugin.getLogger().warning("Quest data was null when getting objectives for " + quest.getName());
|
||||
return new LinkedList<>();
|
||||
}
|
||||
@ -1190,7 +1201,7 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
return objectives;
|
||||
}
|
||||
final BukkitQuestProgress data = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress data = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
final LinkedList<Objective> objectives = new LinkedList<>();
|
||||
for (int i = 0; i < data.getBlocksBroken().size(); 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());
|
||||
return;
|
||||
}
|
||||
if (quester.getQuestDataOrDefault(quest) == null) {
|
||||
if (quester.getQuestProgressOrDefault(quest) == null) {
|
||||
plugin.getLogger().warning("Quest data was null when showing conditions for " + quest.getName());
|
||||
return;
|
||||
}
|
||||
@ -1827,13 +1838,13 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, broken.getAmount(), goal.getAmount()));
|
||||
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);
|
||||
if (bukkitQuestData.blocksBroken.get(breakIndex) > goal.getAmount()) {
|
||||
if (bukkitQuestProgress.blocksBroken.get(breakIndex) > goal.getAmount()) {
|
||||
return;
|
||||
}
|
||||
final int progress = bukkitQuestData.blocksBroken.get(breakIndex) + 1;
|
||||
bukkitQuestData.blocksBroken.set(breakIndex, progress);
|
||||
final int progress = bukkitQuestProgress.blocksBroken.get(breakIndex) + 1;
|
||||
bukkitQuestProgress.blocksBroken.set(breakIndex, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
|
||||
null, null, null, null);
|
||||
@ -1841,7 +1852,7 @@ public class BukkitQuester implements Quester {
|
||||
// Multiplayer
|
||||
final ItemStack finalGoal = goal;
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -1897,13 +1908,13 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, damaged.getAmount(), goal.getAmount()));
|
||||
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);
|
||||
if (bukkitQuestData.blocksDamaged.get(damageIndex) > goal.getAmount()) {
|
||||
if (bukkitQuestProgress.blocksDamaged.get(damageIndex) > goal.getAmount()) {
|
||||
return;
|
||||
}
|
||||
final int progress = bukkitQuestData.blocksDamaged.get(damageIndex) + 1;
|
||||
bukkitQuestData.blocksDamaged.set(damageIndex, progress);
|
||||
final int progress = bukkitQuestProgress.blocksDamaged.get(damageIndex) + 1;
|
||||
bukkitQuestProgress.blocksDamaged.set(damageIndex, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
|
||||
null, null, null, null);
|
||||
@ -1911,7 +1922,7 @@ public class BukkitQuester implements Quester {
|
||||
// Multiplayer
|
||||
final ItemStack finalGoal = goal;
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -1967,13 +1978,13 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, placed.getAmount(), goal.getAmount()));
|
||||
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);
|
||||
if (bukkitQuestData.blocksPlaced.get(placeIndex) > goal.getAmount()) {
|
||||
if (bukkitQuestProgress.blocksPlaced.get(placeIndex) > goal.getAmount()) {
|
||||
return;
|
||||
}
|
||||
final int progress = bukkitQuestData.blocksPlaced.get(placeIndex) + 1;
|
||||
bukkitQuestData.blocksPlaced.set(placeIndex, progress);
|
||||
final int progress = bukkitQuestProgress.blocksPlaced.get(placeIndex) + 1;
|
||||
bukkitQuestProgress.blocksPlaced.set(placeIndex, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
|
||||
null, null, null, null);
|
||||
@ -1981,7 +1992,7 @@ public class BukkitQuester implements Quester {
|
||||
// Multiplayer
|
||||
final ItemStack finalGoal = goal;
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2037,13 +2048,13 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, used.getAmount(), goal.getAmount()));
|
||||
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);
|
||||
if (bukkitQuestData.blocksUsed.get(useIndex) > goal.getAmount()) {
|
||||
if (bukkitQuestProgress.blocksUsed.get(useIndex) > goal.getAmount()) {
|
||||
return;
|
||||
}
|
||||
final int progress = bukkitQuestData.blocksUsed.get(useIndex) + 1;
|
||||
bukkitQuestData.blocksUsed.set(useIndex, progress);
|
||||
final int progress = bukkitQuestProgress.blocksUsed.get(useIndex) + 1;
|
||||
bukkitQuestProgress.blocksUsed.set(useIndex, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
|
||||
null, null, null, null);
|
||||
@ -2051,7 +2062,7 @@ public class BukkitQuester implements Quester {
|
||||
// Multiplayer
|
||||
final ItemStack finalGoal = goal;
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2107,13 +2118,13 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, cut.getAmount(), goal.getAmount()));
|
||||
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);
|
||||
if (bukkitQuestData.blocksCut.get(cutIndex) > goal.getAmount()) {
|
||||
if (bukkitQuestProgress.blocksCut.get(cutIndex) > goal.getAmount()) {
|
||||
return;
|
||||
}
|
||||
final int progress = bukkitQuestData.blocksCut.get(cutIndex) + 1;
|
||||
bukkitQuestData.blocksCut.set(cutIndex, progress);
|
||||
final int progress = bukkitQuestProgress.blocksCut.get(cutIndex) + 1;
|
||||
bukkitQuestProgress.blocksCut.set(cutIndex, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null,
|
||||
null, null, null, null);
|
||||
@ -2121,7 +2132,7 @@ public class BukkitQuester implements Quester {
|
||||
// Multiplayer
|
||||
final ItemStack finalGoal = goal;
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2142,7 +2153,7 @@ public class BukkitQuester implements Quester {
|
||||
public void craftItem(final Quest quest, final ItemStack crafted) {
|
||||
int currentIndex = -1;
|
||||
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()) {
|
||||
currentIndex++;
|
||||
if (BukkitItemUtil.compareItems(crafted, toCraft, true) == 0) {
|
||||
@ -2153,7 +2164,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
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 ObjectiveType type = ObjectiveType.CRAFT_ITEM;
|
||||
@ -2162,14 +2173,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int progress = crafted.getAmount() + amount;
|
||||
bukkitQuestData.itemsCrafted.set(match, progress);
|
||||
bukkitQuestProgress.itemsCrafted.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
|
||||
null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2191,7 +2202,7 @@ public class BukkitQuester implements Quester {
|
||||
public void smeltItem(final Quest quest, final ItemStack smelted) {
|
||||
int currentIndex = -1;
|
||||
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()) {
|
||||
currentIndex++;
|
||||
if (BukkitItemUtil.compareItems(smelted, toSmelt, true) == 0) {
|
||||
@ -2202,7 +2213,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
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 ObjectiveType type = ObjectiveType.SMELT_ITEM;
|
||||
@ -2211,14 +2222,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int progress = smelted.getAmount() + amount;
|
||||
bukkitQuestData.itemsSmelted.set(match, progress);
|
||||
bukkitQuestProgress.itemsSmelted.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
|
||||
null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2241,7 +2252,7 @@ public class BukkitQuester implements Quester {
|
||||
final Map<Enchantment, Integer> enchantsToAdd) {
|
||||
int currentIndex = -1;
|
||||
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()) {
|
||||
currentIndex++;
|
||||
if (toEnchant.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
@ -2254,7 +2265,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
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 ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
|
||||
@ -2263,14 +2274,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int progress = enchantedBook.getAmount() + amount;
|
||||
bukkitQuestData.itemsEnchanted.set(match, progress);
|
||||
bukkitQuestProgress.itemsEnchanted.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
|
||||
null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2292,7 +2303,7 @@ public class BukkitQuester implements Quester {
|
||||
public void enchantItem(final Quest quest, final ItemStack enchanted) {
|
||||
int currentIndex = -1;
|
||||
final LinkedList<Integer> matches = new LinkedList<>();
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (!enchanted.getType().equals(Material.BOOK)) {
|
||||
for (final ItemStack toEnchant : ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant()) {
|
||||
currentIndex++;
|
||||
@ -2311,7 +2322,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
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 ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
|
||||
@ -2320,14 +2331,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int progress = enchanted.getAmount() + amount;
|
||||
bukkitQuestData.itemsEnchanted.set(match, progress);
|
||||
bukkitQuestProgress.itemsEnchanted.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
|
||||
null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2349,7 +2360,7 @@ public class BukkitQuester implements Quester {
|
||||
public void brewItem(final Quest quest, final ItemStack brewed) {
|
||||
int currentIndex = -1;
|
||||
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()) {
|
||||
currentIndex++;
|
||||
if (BukkitItemUtil.compareItems(brewed, toBrew, true) == 0) {
|
||||
@ -2360,7 +2371,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
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 ObjectiveType type = ObjectiveType.BREW_ITEM;
|
||||
@ -2369,14 +2380,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int progress = brewed.getAmount() + amount;
|
||||
bukkitQuestData.itemsBrewed.set(match, progress);
|
||||
bukkitQuestProgress.itemsBrewed.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
|
||||
null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2398,7 +2409,7 @@ public class BukkitQuester implements Quester {
|
||||
public void consumeItem(final Quest quest, final ItemStack consumed) {
|
||||
int currentIndex = -1;
|
||||
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()) {
|
||||
currentIndex++;
|
||||
if (BukkitItemUtil.compareItems(consumed, toConsume, true) == 0) {
|
||||
@ -2409,7 +2420,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
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 ObjectiveType type = ObjectiveType.CONSUME_ITEM;
|
||||
@ -2418,14 +2429,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int progress = consumed.getAmount() + amount;
|
||||
bukkitQuestData.itemsConsumed.set(match, progress);
|
||||
bukkitQuestProgress.itemsConsumed.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, progress, goal), null, null, null, null,
|
||||
null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
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,
|
||||
null, null, null, null);
|
||||
return null;
|
||||
@ -2452,7 +2463,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
int currentIndex = -1;
|
||||
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()) {
|
||||
currentIndex++;
|
||||
if (BukkitItemUtil.compareItems(delivered, toDeliver, true) == 0) {
|
||||
@ -2467,7 +2478,7 @@ public class BukkitQuester implements Quester {
|
||||
if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc)) {
|
||||
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 ObjectiveType type = ObjectiveType.DELIVER_ITEM;
|
||||
@ -2482,7 +2493,7 @@ public class BukkitQuester implements Quester {
|
||||
// Already delivered in previous loop
|
||||
return;
|
||||
}
|
||||
bukkitQuestData.itemsDelivered.set(match, progress);
|
||||
bukkitQuestProgress.itemsDelivered.set(match, progress);
|
||||
if (progress >= goal.getAmount()) {
|
||||
if ((delivered.getAmount() + amount) >= goal.getAmount()) {
|
||||
// Take away remaining amount to be delivered
|
||||
@ -2508,7 +2519,7 @@ public class BukkitQuester implements Quester {
|
||||
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, ObjectiveType.DELIVER_ITEM,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
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)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2534,8 +2545,8 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
|
||||
final int index = getCurrentStage(quest).getNpcsToInteract().indexOf(npc);
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final boolean npcsInteracted = bukkitQuestData.npcsInteracted.get(index);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
final boolean npcsInteracted = bukkitQuestProgress.npcsInteracted.get(index);
|
||||
|
||||
final ObjectiveType type = ObjectiveType.TALK_TO_NPC;
|
||||
final Set<String> dispatchedQuestIDs = new HashSet<>();
|
||||
@ -2544,14 +2555,14 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
if (!npcsInteracted) {
|
||||
bukkitQuestData.npcsInteracted.set(index, true);
|
||||
bukkitQuestProgress.npcsInteracted.set(index, true);
|
||||
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, 1)), null, null, npc, null, null, null, null);
|
||||
|
||||
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
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)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2577,8 +2588,8 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
|
||||
final int index = getCurrentStage(quest).getNpcsToKill().indexOf(npc);
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final int npcsKilled = bukkitQuestData.npcsNumKilled.get(index);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
final int npcsKilled = bukkitQuestProgress.npcsNumKilled.get(index);
|
||||
final int npcsToKill = getCurrentStage(quest).getNpcNumToKill().get(index);
|
||||
|
||||
final ObjectiveType type = ObjectiveType.KILL_NPC;
|
||||
@ -2587,9 +2598,9 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, npcsKilled, npcsToKill));
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
final int newNpcsKilled = bukkitQuestData.npcsNumKilled.get(index) + 1;
|
||||
final int newNpcsKilled = bukkitQuestProgress.npcsNumKilled.get(index) + 1;
|
||||
if (npcsKilled < npcsToKill) {
|
||||
bukkitQuestData.npcsNumKilled.set(index, newNpcsKilled);
|
||||
bukkitQuestProgress.npcsNumKilled.set(index, newNpcsKilled);
|
||||
if (newNpcsKilled >= npcsToKill) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).npcsNumKilled
|
||||
((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).npcsNumKilled
|
||||
.set(index, newNpcsKilled);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
@ -2619,8 +2630,8 @@ public class BukkitQuester implements Quester {
|
||||
* @param quest The quest for which the fish is being caught
|
||||
*/
|
||||
public void milkCow(final Quest quest) {
|
||||
final BukkitQuestProgress questData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
if (questData == null) {
|
||||
final BukkitQuestProgress questProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (questProgress == null) {
|
||||
return;
|
||||
}
|
||||
final Stage currentStage = getCurrentStage(quest);
|
||||
@ -2631,7 +2642,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
|
||||
final int cowsMilked = questData.getCowsMilked();
|
||||
final int cowsMilked = questProgress.getCowsMilked();
|
||||
final int cowsToMilk = currentStage.getCowsToMilk();
|
||||
|
||||
final ObjectiveType type = ObjectiveType.MILK_COW;
|
||||
@ -2642,7 +2653,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
final int newCowsMilked = cowsMilked + 1;
|
||||
if (cowsMilked < cowsToMilk) {
|
||||
questData.setCowsMilked(newCowsMilked);
|
||||
questProgress.setCowsMilked(newCowsMilked);
|
||||
|
||||
if (newCowsMilked >= cowsToMilk) {
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
q.getQuestDataOrDefault(quest).setCowsMilked(newCowsMilked);
|
||||
q.getQuestProgressOrDefault(quest).setCowsMilked(newCowsMilked);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2672,8 +2683,8 @@ public class BukkitQuester implements Quester {
|
||||
* @param quest The quest for which the fish is being caught
|
||||
*/
|
||||
public void catchFish(final Quest quest) {
|
||||
final BukkitQuestProgress questData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
if (questData == null) {
|
||||
final BukkitQuestProgress questProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (questProgress == null) {
|
||||
return;
|
||||
}
|
||||
final Stage currentStage = getCurrentStage(quest);
|
||||
@ -2684,7 +2695,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
|
||||
final int fishCaught = questData.getFishCaught();
|
||||
final int fishCaught = questProgress.getFishCaught();
|
||||
final int fishToCatch = currentStage.getFishToCatch();
|
||||
|
||||
final ObjectiveType type = ObjectiveType.CATCH_FISH;
|
||||
@ -2695,7 +2706,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
final int newFishCaught = fishCaught + 1;
|
||||
if (fishCaught < fishToCatch) {
|
||||
questData.setFishCaught(newFishCaught);
|
||||
questProgress.setFishCaught(newFishCaught);
|
||||
|
||||
if (newFishCaught >= fishToCatch) {
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
q.getQuestDataOrDefault(quest).setFishCaught(newFishCaught);
|
||||
q.getQuestProgressOrDefault(quest).setFishCaught(newFishCaught);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2727,7 +2738,7 @@ public class BukkitQuester implements Quester {
|
||||
* @param entityType The mob to be killed
|
||||
*/
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -2739,7 +2750,7 @@ public class BukkitQuester implements Quester {
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
final int mobsKilled = bukkitQuestData.mobNumKilled.get(index);
|
||||
final int mobsKilled = bukkitQuestProgress.mobNumKilled.get(index);
|
||||
final int mobsToKill = currentStage.getMobNumToKill().get(index);
|
||||
if (!currentStage.getLocationsToKillWithin().isEmpty()) {
|
||||
final Location locationToKillWithin = currentStage.getLocationsToKillWithin().get(index);
|
||||
@ -2771,7 +2782,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
final int newMobsKilled = mobsKilled + 1;
|
||||
if (mobsKilled < mobsToKill) {
|
||||
bukkitQuestData.mobNumKilled.set(index, newMobsKilled);
|
||||
bukkitQuestProgress.mobNumKilled.set(index, newMobsKilled);
|
||||
if (newMobsKilled >= mobsToKill) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, mobsToKill)), entityType, null, null, null, null, null, null);
|
||||
@ -2784,8 +2795,8 @@ public class BukkitQuester implements Quester {
|
||||
if (i == -1) {
|
||||
return null;
|
||||
}
|
||||
final int kills = q.getQuestDataOrDefault(quest).getMobNumKilled().get(i);
|
||||
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).mobNumKilled.set(index, kills + 1);
|
||||
final int kills = q.getQuestProgressOrDefault(quest).getMobNumKilled().get(i);
|
||||
((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).mobNumKilled.set(index, kills + 1);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2806,8 +2817,8 @@ public class BukkitQuester implements Quester {
|
||||
* @param player The player to be killed
|
||||
*/
|
||||
public void killPlayer(final Quest quest, final Player player) {
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
if (bukkitQuestData == null) {
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (bukkitQuestProgress == null) {
|
||||
return;
|
||||
}
|
||||
final Stage currentStage = getCurrentStage(quest);
|
||||
@ -2818,7 +2829,7 @@ public class BukkitQuester implements Quester {
|
||||
return;
|
||||
}
|
||||
|
||||
final int playersKilled = bukkitQuestData.getPlayersKilled();
|
||||
final int playersKilled = bukkitQuestProgress.getPlayersKilled();
|
||||
final int playersToKill = currentStage.getPlayersToKill();
|
||||
|
||||
final ObjectiveType type = ObjectiveType.KILL_PLAYER;
|
||||
@ -2829,7 +2840,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
final int newPlayersKilled = playersKilled + 1;
|
||||
if (playersKilled < playersToKill) {
|
||||
bukkitQuestData.setPlayersKilled(newPlayersKilled);
|
||||
bukkitQuestProgress.setPlayersKilled(newPlayersKilled);
|
||||
if (newPlayersKilled >= playersToKill) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
final int kills = q.getQuestDataOrDefault(quest).getPlayersKilled();
|
||||
q.getQuestDataOrDefault(quest).setPlayersKilled(kills + 1);
|
||||
final int kills = q.getQuestProgressOrDefault(quest).getPlayersKilled();
|
||||
q.getQuestProgressOrDefault(quest).setPlayersKilled(kills + 1);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2860,8 +2871,8 @@ public class BukkitQuester implements Quester {
|
||||
* @param location The location being reached
|
||||
*/
|
||||
public void reachLocation(final Quest quest, final Location location) {
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
if (bukkitQuestData == null || bukkitQuestData.locationsReached == null || getCurrentStage(quest) == null
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (bukkitQuestProgress == null || bukkitQuestProgress.locationsReached == null || getCurrentStage(quest) == null
|
||||
|| getCurrentStage(quest).getLocationsToReach() == null) {
|
||||
return;
|
||||
}
|
||||
@ -2876,9 +2887,9 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
final double radius = getCurrentStage(quest).getRadiiToReachWithin().get(i);
|
||||
if (toReach.distanceSquared(location) <= radius * radius) {
|
||||
if (!bukkitQuestData.locationsReached.get(i)) {
|
||||
if (!bukkitQuestProgress.locationsReached.get(i)) {
|
||||
int progress = 0;
|
||||
for (final Boolean b : bukkitQuestData.locationsReached) {
|
||||
for (final Boolean b : bukkitQuestProgress.locationsReached) {
|
||||
if (b) {
|
||||
progress++;
|
||||
}
|
||||
@ -2890,7 +2901,7 @@ public class BukkitQuester implements Quester {
|
||||
new BukkitObjective(type, null, progress, goal));
|
||||
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),
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).locationsReached
|
||||
((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).locationsReached
|
||||
.set(finalIndex, true);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
@ -2925,7 +2936,7 @@ public class BukkitQuester implements Quester {
|
||||
* @param entityType The type of mob being tamed
|
||||
*/
|
||||
public void tameMob(final Quest quest, final EntityType entityType) {
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (entityType == null) {
|
||||
return;
|
||||
}
|
||||
@ -2940,7 +2951,7 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
|
||||
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 Set<String> dispatchedQuestIDs = new HashSet<>();
|
||||
@ -2950,7 +2961,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
final int newMobsToTame = mobsTamed + 1;
|
||||
if (mobsTamed < mobsToTame) {
|
||||
bukkitQuestData.mobsTamed.set(index, newMobsToTame);
|
||||
bukkitQuestProgress.mobsTamed.set(index, newMobsToTame);
|
||||
if (newMobsToTame >= mobsToTame) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
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)) {
|
||||
quest.nextStage(q, false);
|
||||
}
|
||||
@ -2980,7 +2991,7 @@ public class BukkitQuester implements Quester {
|
||||
* @param color The wool color of the sheep being sheared
|
||||
*/
|
||||
public void shearSheep(final Quest quest, final DyeColor color) {
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
@ -2995,7 +3006,7 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
|
||||
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 Set<String> dispatchedQuestIDs = new HashSet<>();
|
||||
@ -3005,7 +3016,7 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
final int newSheepSheared = sheepSheared + 1;
|
||||
if (sheepSheared < sheepToShear) {
|
||||
bukkitQuestData.sheepSheared.set(index, newSheepSheared);
|
||||
bukkitQuestProgress.sheepSheared.set(index, newSheepSheared);
|
||||
if (newSheepSheared >= sheepToShear) {
|
||||
finishObjective(quest, new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
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,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).sheepSheared
|
||||
((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).sheepSheared
|
||||
.set(index, newSheepSheared);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
@ -3044,11 +3055,11 @@ public class BukkitQuester implements Quester {
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
int index = 0;
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
for (final String pass : getCurrentStage(quest).getPasswordPhrases()) {
|
||||
if (pass.equalsIgnoreCase(evt.getMessage())) {
|
||||
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,
|
||||
new BukkitObjective(type, null, new ItemStack(Material.AIR, 1),
|
||||
@ -3058,7 +3069,7 @@ public class BukkitQuester implements Quester {
|
||||
dispatchedQuestIDs.addAll(dispatchMultiplayerEverything(quest, type,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
((BukkitQuestProgress) q.getQuestDataOrDefault(quest)).passwordsSaid
|
||||
((BukkitQuestProgress) q.getQuestProgressOrDefault(quest)).passwordsSaid
|
||||
.set(finalIndex, true);
|
||||
if (q.testComplete(quest)) {
|
||||
quest.nextStage(q, false);
|
||||
@ -3575,16 +3586,13 @@ public class BukkitQuester implements Quester {
|
||||
|
||||
public FileConfiguration getBaseData() {
|
||||
final FileConfiguration data = new YamlConfiguration();
|
||||
final ArrayList<String> currentQuestIds = new ArrayList<>();
|
||||
final ArrayList<Integer> currentQuestStages = new ArrayList<>();
|
||||
if (!currentQuests.isEmpty()) {
|
||||
final ArrayList<String> questIds = new ArrayList<>();
|
||||
final ArrayList<Integer> questStages = new ArrayList<>();
|
||||
for (final Quest quest : currentQuests.keySet()) {
|
||||
questIds.add(quest.getId());
|
||||
questStages.add(currentQuests.get(quest));
|
||||
currentQuestIds.add(quest.getId());
|
||||
currentQuestStages.add(currentQuests.get(quest));
|
||||
}
|
||||
data.set("currentQuests", questIds);
|
||||
data.set("currentStages", questStages);
|
||||
data.set("quest-points", questPoints);
|
||||
final ConfigurationSection dataSec = data.createSection("questData");
|
||||
for (final Quest quest : currentQuests.keySet()) {
|
||||
if (quest.getName() == null || quest.getName().isEmpty()) {
|
||||
@ -3592,91 +3600,88 @@ public class BukkitQuester implements Quester {
|
||||
return null;
|
||||
}
|
||||
final ConfigurationSection questSec = dataSec.createSection(quest.getId());
|
||||
final BukkitQuestProgress questData = (BukkitQuestProgress) getQuestDataOrDefault(quest);
|
||||
if (questData == null) {
|
||||
final BukkitQuestProgress questProgress = (BukkitQuestProgress) getQuestProgressOrDefault(quest);
|
||||
if (questProgress == null) {
|
||||
continue;
|
||||
}
|
||||
if (!questData.blocksBroken.isEmpty()) {
|
||||
questSec.set("blocks-broken-amounts", questData.blocksBroken);
|
||||
if (!questProgress.blocksBroken.isEmpty()) {
|
||||
questSec.set("blocks-broken-amounts", questProgress.blocksBroken);
|
||||
}
|
||||
if (!questData.blocksDamaged.isEmpty()) {
|
||||
questSec.set("blocks-damaged-amounts", questData.blocksDamaged);
|
||||
if (!questProgress.blocksDamaged.isEmpty()) {
|
||||
questSec.set("blocks-damaged-amounts", questProgress.blocksDamaged);
|
||||
}
|
||||
if (!questData.blocksPlaced.isEmpty()) {
|
||||
questSec.set("blocks-placed-amounts", questData.blocksPlaced);
|
||||
if (!questProgress.blocksPlaced.isEmpty()) {
|
||||
questSec.set("blocks-placed-amounts", questProgress.blocksPlaced);
|
||||
}
|
||||
if (!questData.blocksUsed.isEmpty()) {
|
||||
questSec.set("blocks-used-amounts", questData.blocksUsed);
|
||||
if (!questProgress.blocksUsed.isEmpty()) {
|
||||
questSec.set("blocks-used-amounts", questProgress.blocksUsed);
|
||||
}
|
||||
if (!questData.blocksCut.isEmpty()) {
|
||||
questSec.set("blocks-cut-amounts", questData.blocksCut);
|
||||
if (!questProgress.blocksCut.isEmpty()) {
|
||||
questSec.set("blocks-cut-amounts", questProgress.blocksCut);
|
||||
}
|
||||
if (!questData.itemsCrafted.isEmpty()) {
|
||||
questSec.set("item-craft-amounts", questData.itemsCrafted);
|
||||
if (!questProgress.itemsCrafted.isEmpty()) {
|
||||
questSec.set("item-craft-amounts", questProgress.itemsCrafted);
|
||||
}
|
||||
if (!questData.itemsSmelted.isEmpty()) {
|
||||
questSec.set("item-smelt-amounts", questData.itemsSmelted);
|
||||
if (!questProgress.itemsSmelted.isEmpty()) {
|
||||
questSec.set("item-smelt-amounts", questProgress.itemsSmelted);
|
||||
}
|
||||
if (!questData.itemsEnchanted.isEmpty()) {
|
||||
questSec.set("item-enchant-amounts", questData.itemsEnchanted);
|
||||
if (!questProgress.itemsEnchanted.isEmpty()) {
|
||||
questSec.set("item-enchant-amounts", questProgress.itemsEnchanted);
|
||||
}
|
||||
if (!questData.itemsBrewed.isEmpty()) {
|
||||
questSec.set("item-brew-amounts", questData.itemsBrewed);
|
||||
if (!questProgress.itemsBrewed.isEmpty()) {
|
||||
questSec.set("item-brew-amounts", questProgress.itemsBrewed);
|
||||
}
|
||||
if (!questData.itemsConsumed.isEmpty()) {
|
||||
questSec.set("item-consume-amounts", questData.itemsConsumed);
|
||||
if (!questProgress.itemsConsumed.isEmpty()) {
|
||||
questSec.set("item-consume-amounts", questProgress.itemsConsumed);
|
||||
}
|
||||
if (!questData.itemsDelivered.isEmpty()) {
|
||||
questSec.set("item-delivery-amounts", questData.itemsDelivered);
|
||||
if (!questProgress.itemsDelivered.isEmpty()) {
|
||||
questSec.set("item-delivery-amounts", questProgress.itemsDelivered);
|
||||
}
|
||||
if (!questData.npcsInteracted.isEmpty()) {
|
||||
questSec.set("has-talked-to", questData.npcsInteracted);
|
||||
if (!questProgress.npcsInteracted.isEmpty()) {
|
||||
questSec.set("has-talked-to", questProgress.npcsInteracted);
|
||||
}
|
||||
if (!questData.npcsNumKilled.isEmpty()) {
|
||||
questSec.set("npc-killed-amounts", questData.npcsNumKilled);
|
||||
if (!questProgress.npcsNumKilled.isEmpty()) {
|
||||
questSec.set("npc-killed-amounts", questProgress.npcsNumKilled);
|
||||
}
|
||||
if (!questData.mobNumKilled.isEmpty()) {
|
||||
questSec.set("mobs-killed-amounts", questData.mobNumKilled);
|
||||
if (!questProgress.mobNumKilled.isEmpty()) {
|
||||
questSec.set("mobs-killed-amounts", questProgress.mobNumKilled);
|
||||
}
|
||||
if (!questData.mobsTamed.isEmpty()) {
|
||||
questSec.set("mob-tame-amounts", questData.mobsTamed);
|
||||
if (!questProgress.mobsTamed.isEmpty()) {
|
||||
questSec.set("mob-tame-amounts", questProgress.mobsTamed);
|
||||
}
|
||||
final Stage stage = getCurrentStage(quest);
|
||||
if (stage != null) {
|
||||
if (stage.getFishToCatch() != null) {
|
||||
questSec.set("fish-caught", questData.getFishCaught());
|
||||
questSec.set("fish-caught", questProgress.getFishCaught());
|
||||
}
|
||||
if (stage.getCowsToMilk() != null) {
|
||||
questSec.set("cows-milked", questData.getCowsMilked());
|
||||
questSec.set("cows-milked", questProgress.getCowsMilked());
|
||||
}
|
||||
if (stage.getPlayersToKill() != null) {
|
||||
questSec.set("players-killed", questData.getPlayersKilled());
|
||||
questSec.set("players-killed", questProgress.getPlayersKilled());
|
||||
}
|
||||
}
|
||||
if (!questData.sheepSheared.isEmpty()) {
|
||||
questSec.set("sheep-sheared", questData.sheepSheared);
|
||||
if (!questProgress.sheepSheared.isEmpty()) {
|
||||
questSec.set("sheep-sheared", questProgress.sheepSheared);
|
||||
}
|
||||
if (!questData.locationsReached.isEmpty()) {
|
||||
questSec.set("has-reached-location", questData.locationsReached);
|
||||
if (!questProgress.locationsReached.isEmpty()) {
|
||||
questSec.set("has-reached-location", questProgress.locationsReached);
|
||||
}
|
||||
if (!questData.passwordsSaid.isEmpty()) {
|
||||
questSec.set("passwords-said", questData.passwordsSaid);
|
||||
if (!questProgress.passwordsSaid.isEmpty()) {
|
||||
questSec.set("passwords-said", questProgress.passwordsSaid);
|
||||
}
|
||||
if (!questData.customObjectiveCounts.isEmpty()) {
|
||||
questSec.set("custom-objective-counts", questData.customObjectiveCounts);
|
||||
if (!questProgress.customObjectiveCounts.isEmpty()) {
|
||||
questSec.set("custom-objective-counts", questProgress.customObjectiveCounts);
|
||||
}
|
||||
if (questData.getDelayTimeLeft() > 0) {
|
||||
questSec.set("stage-delay", questData.getDelayTimeLeft());
|
||||
if (questProgress.getDelayTimeLeft() > 0) {
|
||||
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("completed-Quests", "none");
|
||||
} else {
|
||||
data.set("currentQuests", currentQuestIds);
|
||||
data.set("currentStages", currentQuestStages);
|
||||
data.set("quest-points", questPoints);
|
||||
if (!completedQuests.isEmpty()) {
|
||||
final List<String> questIds = new LinkedList<>();
|
||||
for (final Quest quest : completedQuests) {
|
||||
questIds.add(quest.getId());
|
||||
@ -3746,9 +3751,9 @@ public class BukkitQuester implements Quester {
|
||||
* @param quest The quest of which the timer is for
|
||||
*/
|
||||
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),
|
||||
(long) (getQuestDataOrDefault(quest).getDelayTimeLeft() * 0.02));
|
||||
(long) (getQuestProgressOrDefault(quest).getDelayTimeLeft() * 0.02));
|
||||
} else {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new BukkitStageTimer(plugin, this, quest),
|
||||
(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
|
||||
*/
|
||||
public void stopStageTimer(final Quest quest) {
|
||||
if (getQuestDataOrDefault(quest).getDelayTimeLeft() > -1) {
|
||||
getQuestDataOrDefault(quest).setDelayTimeLeft(getQuestDataOrDefault(quest).getDelayTimeLeft()
|
||||
- (System.currentTimeMillis() - getQuestDataOrDefault(quest).getDelayStartTime()));
|
||||
if (getQuestProgressOrDefault(quest).getDelayTimeLeft() > -1) {
|
||||
getQuestProgressOrDefault(quest).setDelayTimeLeft(getQuestProgressOrDefault(quest).getDelayTimeLeft()
|
||||
- (System.currentTimeMillis() - getQuestProgressOrDefault(quest).getDelayStartTime()));
|
||||
} else {
|
||||
getQuestDataOrDefault(quest).setDelayTimeLeft(getCurrentStage(quest).getDelay() - (System.currentTimeMillis()
|
||||
- getQuestDataOrDefault(quest).getDelayStartTime()));
|
||||
getQuestProgressOrDefault(quest).setDelayTimeLeft(getCurrentStage(quest).getDelay() - (System.currentTimeMillis()
|
||||
- getQuestProgressOrDefault(quest).getDelayStartTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3783,12 +3788,12 @@ public class BukkitQuester implements Quester {
|
||||
* @return Remaining time in milliseconds
|
||||
*/
|
||||
public long getStageTime(final Quest quest) {
|
||||
if (getQuestDataOrDefault(quest).getDelayTimeLeft() > -1) {
|
||||
return getQuestDataOrDefault(quest).getDelayTimeLeft() - (System.currentTimeMillis()
|
||||
- getQuestDataOrDefault(quest).getDelayStartTime());
|
||||
if (getQuestProgressOrDefault(quest).getDelayTimeLeft() > -1) {
|
||||
return getQuestProgressOrDefault(quest).getDelayTimeLeft() - (System.currentTimeMillis()
|
||||
- getQuestProgressOrDefault(quest).getDelayStartTime());
|
||||
} else {
|
||||
return getCurrentStage(quest).getDelay() - (System.currentTimeMillis()
|
||||
- getQuestDataOrDefault(quest).getDelayStartTime());
|
||||
- getQuestProgressOrDefault(quest).getDelayStartTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,9 +306,9 @@ public class BukkitQuest implements Quest {
|
||||
} else {
|
||||
setStage(quester, quester.getCurrentQuests().get(this) + 1);
|
||||
}
|
||||
if (quester.getQuestDataOrDefault(this) != null) {
|
||||
quester.getQuestDataOrDefault(this).setDelayStartTime(0);
|
||||
quester.getQuestDataOrDefault(this).setDelayTimeLeft(-1);
|
||||
if (quester.getQuestProgressOrDefault(this) != null) {
|
||||
quester.getQuestProgressOrDefault(this).setDelayStartTime(0);
|
||||
quester.getQuestProgressOrDefault(this).setDelayTimeLeft(-1);
|
||||
}
|
||||
|
||||
// Multiplayer
|
||||
@ -1082,7 +1082,7 @@ public class BukkitQuest implements Quest {
|
||||
if (allowMultiplayer && options.getShareProgressLevel() == 4) {
|
||||
final List<Quester> mq = quester.getMultiplayerQuesters(this);
|
||||
for (final Quester qq : mq) {
|
||||
if (qq.getQuestDataOrDefault(this) != null) {
|
||||
if (qq.getQuestProgressOrDefault(this) != null) {
|
||||
completeQuest(qq, false);
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (config == null) {
|
||||
return null;
|
||||
}
|
||||
final BukkitQuest quest = new BukkitQuest(plugin);
|
||||
final BukkitDependencies depends = plugin.getDependencies();
|
||||
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)
|
||||
throws QuestFormatException {
|
||||
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,
|
||||
final Quest quest, final String questKey) throws QuestFormatException {
|
||||
final BukkitRequirements requires = (BukkitRequirements) quest.getRequirements();
|
||||
@ -836,40 +837,38 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
final List<String> npcUuidsToKill;
|
||||
final List<Integer> npcIdsToKill;
|
||||
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
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run")) {
|
||||
if (plugin.getDependencies().getDenizenApi().containsScript(config.getString("quests." + questKey
|
||||
+ ".stages.ordered." + stageNum + ".script-to-run"))) {
|
||||
oStage.setScript(config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".script-to-run"));
|
||||
if (config.contains(ordered + ".script-to-run")) {
|
||||
if (plugin.getDependencies().getDenizenApi().containsScript(config.getString(ordered
|
||||
+ ".script-to-run"))) {
|
||||
oStage.setScript(config.getString(ordered + ".script-to-run"));
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".break-block-names"), String.class)) {
|
||||
breakNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".break-block-names");
|
||||
if (config.contains(ordered + ".break-block-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".break-block-names"), String.class)) {
|
||||
breakNames = config.getStringList(ordered + ".break-block-names");
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".break-block-amounts"), Integer.class)) {
|
||||
breakAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".break-block-amounts");
|
||||
if (config.contains(ordered + ".break-block-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".break-block-amounts"), Integer.class)) {
|
||||
breakAmounts = config.getIntegerList(ordered + ".break-block-amounts");
|
||||
} else {
|
||||
throw new StageFormatException("'break-block-amounts' is not a list of numbers", quest, stageNum);
|
||||
}
|
||||
} else {
|
||||
throw new StageFormatException("'break-block-amounts' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".break-block-durability"), Integer.class)) {
|
||||
breakDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".break-block-durability");
|
||||
if (config.contains(ordered + ".break-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".break-block-durability"), Integer.class)) {
|
||||
breakDurability = config.getShortList(ordered + ".break-block-durability");
|
||||
} else {
|
||||
throw new StageFormatException("'break-block-durability' is not a list of numbers", quest,
|
||||
stageNum);
|
||||
@ -878,35 +877,30 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'break-block-durability' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
int breakIndex = 0;
|
||||
for (final String s : breakNames) {
|
||||
for (int i = 0; i < breakNames.size(); i++) {
|
||||
final String name = breakNames.get(i);
|
||||
final ItemStack is;
|
||||
if (breakIndex < breakDurability.size() && breakDurability.get(breakIndex) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(s, breakAmounts.get(breakIndex), breakDurability.get(breakIndex));
|
||||
if (i < breakDurability.size() && breakDurability.get(i) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(name, breakAmounts.get(i), breakDurability.get(i));
|
||||
} else {
|
||||
// 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);
|
||||
} 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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-names"), String.class)) {
|
||||
damageNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-names");
|
||||
if (config.contains(ordered + ".damage-block-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".damage-block-names"), String.class)) {
|
||||
damageNames = config.getStringList(ordered + ".damage-block-names");
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-amounts"), Integer.class)) {
|
||||
damageAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-amounts");
|
||||
if (config.contains(ordered + ".damage-block-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".damage-block-amounts"), Integer.class)) {
|
||||
damageAmounts = config.getIntegerList(ordered + ".damage-block-amounts");
|
||||
} else {
|
||||
throw new StageFormatException("'damage-block-amounts' is not a list of numbers", quest,
|
||||
stageNum);
|
||||
@ -914,12 +908,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
throw new StageFormatException("'damage-block-amounts' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-durability"), Integer.class)) {
|
||||
damageDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".damage-block-durability");
|
||||
if (config.contains(ordered + ".damage-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".damage-block-durability"), Integer.class)) {
|
||||
damageDurability = config.getShortList(ordered + ".damage-block-durability");
|
||||
} else {
|
||||
throw new StageFormatException("'damage-block-durability' is not a list of numbers", quest,
|
||||
stageNum);
|
||||
@ -928,47 +919,40 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'damage-block-durability' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
int damageIndex = 0;
|
||||
for (final String s : damageNames) {
|
||||
for (int i = 0; i < damageNames.size(); i++) {
|
||||
final String name = damageNames.get(i);
|
||||
final ItemStack is;
|
||||
if (damageIndex < damageDurability.size() && damageDurability.get(damageIndex) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(s, damageAmounts.get(damageIndex),
|
||||
damageDurability.get(damageIndex));
|
||||
if (i < damageDurability.size() && damageDurability.get(i) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(name, damageAmounts.get(i),
|
||||
damageDurability.get(i));
|
||||
} else {
|
||||
// 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);
|
||||
} 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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".place-block-names"), String.class)) {
|
||||
placeNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".place-block-names");
|
||||
if (config.contains(ordered + ".place-block-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".place-block-names"), String.class)) {
|
||||
placeNames = config.getStringList(ordered + ".place-block-names");
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".place-block-amounts"), Integer.class)) {
|
||||
placeAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".place-block-amounts");
|
||||
if (config.contains(ordered + ".place-block-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".place-block-amounts"), Integer.class)) {
|
||||
placeAmounts = config.getIntegerList(ordered + ".place-block-amounts");
|
||||
} else {
|
||||
throw new StageFormatException("'place-block-amounts' is not a list of numbers", quest, stageNum);
|
||||
}
|
||||
} else {
|
||||
throw new StageFormatException("'place-block-amounts' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".place-block-durability"), Integer.class)) {
|
||||
placeDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".place-block-durability");
|
||||
if (config.contains(ordered + ".place-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".place-block-durability"), Integer.class)) {
|
||||
placeDurability = config.getShortList(ordered + ".place-block-durability");
|
||||
} else {
|
||||
throw new StageFormatException("'place-block-durability' is not a list of numbers", quest,
|
||||
stageNum);
|
||||
@ -977,46 +961,39 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'place-block-durability' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
int placeIndex = 0;
|
||||
for (final String s : placeNames) {
|
||||
for (int i = 0; i < placeNames.size(); i++) {
|
||||
final String name = placeNames.get(i);
|
||||
final ItemStack is;
|
||||
if (placeIndex < placeDurability.size() && placeDurability.get(placeIndex) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(s, placeAmounts.get(placeIndex), placeDurability.get(placeIndex));
|
||||
if (i < placeDurability.size() && placeDurability.get(i) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(name, placeAmounts.get(i), placeDurability.get(i));
|
||||
} else {
|
||||
// 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);
|
||||
} 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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".use-block-names"), String.class)) {
|
||||
useNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".use-block-names");
|
||||
if (config.contains(ordered + ".use-block-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".use-block-names"), String.class)) {
|
||||
useNames = config.getStringList(ordered + ".use-block-names");
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".use-block-amounts"),Integer.class)) {
|
||||
useAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".use-block-amounts");
|
||||
if (config.contains(ordered + ".use-block-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".use-block-amounts"),Integer.class)) {
|
||||
useAmounts = config.getIntegerList(ordered + ".use-block-amounts");
|
||||
} else {
|
||||
throw new StageFormatException("'use-block-amounts' is not a list of numbers", quest, stageNum);
|
||||
}
|
||||
} else {
|
||||
throw new StageFormatException("'use-block-amounts' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".use-block-durability"), Integer.class)) {
|
||||
useDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".use-block-durability");
|
||||
if (config.contains(ordered + ".use-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".use-block-durability"), Integer.class)) {
|
||||
useDurability = config.getShortList(ordered + ".use-block-durability");
|
||||
} else {
|
||||
throw new StageFormatException("'use-block-durability' is not a list of numbers", quest,
|
||||
stageNum);
|
||||
@ -1025,46 +1002,39 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'use-block-durability' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
int useIndex = 0;
|
||||
for (final String s : useNames) {
|
||||
for (int i = 0; i < useNames.size(); i++) {
|
||||
final String name = useNames.get(i);
|
||||
final ItemStack is;
|
||||
if (useIndex < useDurability.size() && useDurability.get(useIndex) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(s, useAmounts.get(useIndex), useDurability.get(useIndex));
|
||||
if (i < useDurability.size() && useDurability.get(i) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(name, useAmounts.get(i), useDurability.get(i));
|
||||
} else {
|
||||
// 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);
|
||||
} 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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cut-block-names"), String.class)) {
|
||||
cutNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cut-block-names");
|
||||
if (config.contains(ordered + ".cut-block-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".cut-block-names"), String.class)) {
|
||||
cutNames = config.getStringList(ordered + ".cut-block-names");
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cut-block-amounts"), Integer.class)) {
|
||||
cutAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cut-block-amounts");
|
||||
if (config.contains(ordered + ".cut-block-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".cut-block-amounts"), Integer.class)) {
|
||||
cutAmounts = config.getIntegerList(ordered + ".cut-block-amounts");
|
||||
} else {
|
||||
throw new StageFormatException("'cut-block-amounts' is not a list of numbers", quest, stageNum);
|
||||
}
|
||||
} else {
|
||||
throw new StageFormatException("'cut-block-amounts' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cut-block-durability"), Integer.class)) {
|
||||
cutDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cut-block-durability");
|
||||
if (config.contains(ordered + ".cut-block-durability")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".cut-block-durability"), Integer.class)) {
|
||||
cutDurability = config.getShortList(ordered + ".cut-block-durability");
|
||||
} else {
|
||||
throw new StageFormatException("'cut-block-durability' is not a list of numbers", quest,
|
||||
stageNum);
|
||||
@ -1073,25 +1043,23 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'cut-block-durability' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
int cutIndex = 0;
|
||||
for (final String s : cutNames) {
|
||||
for (int i = 0; i < cutNames.size(); i++) {
|
||||
final String name = cutNames.get(i);
|
||||
final ItemStack is;
|
||||
if (cutIndex < cutDurability.size() && cutDurability.get(cutIndex) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(s, cutAmounts.get(cutIndex), cutDurability.get(cutIndex));
|
||||
if (i < cutDurability.size() && cutDurability.get(i) != -1) {
|
||||
is = BukkitItemUtil.processItemStack(name, cutAmounts.get(i), cutDurability.get(i));
|
||||
} else {
|
||||
// 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);
|
||||
} 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")) {
|
||||
itemsToCraft = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".items-to-craft");
|
||||
if (config.contains(ordered + ".items-to-craft")) {
|
||||
itemsToCraft = (List<ItemStack>) config.get(ordered + ".items-to-craft");
|
||||
if (BukkitConfigUtil.checkList(itemsToCraft, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToCraft) {
|
||||
if (stack != null) {
|
||||
@ -1104,9 +1072,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'items-to-craft' is not formatted properly", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-smelt")) {
|
||||
itemsToSmelt = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".items-to-smelt");
|
||||
if (config.contains(ordered + ".items-to-smelt")) {
|
||||
itemsToSmelt = (List<ItemStack>) config.get(ordered + ".items-to-smelt");
|
||||
if (BukkitConfigUtil.checkList(itemsToSmelt, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToSmelt) {
|
||||
if (stack != null) {
|
||||
@ -1119,10 +1086,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'items-to-smelt' is not formatted properly", quest, stageNum);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-enchant")) {
|
||||
itemsToEnchant = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".items-to-enchant");
|
||||
if (config.contains(ordered + ".items-to-enchant")) {
|
||||
itemsToEnchant = (List<ItemStack>) config.get(ordered + ".items-to-enchant");
|
||||
if (BukkitConfigUtil.checkList(itemsToEnchant, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToEnchant) {
|
||||
if (stack != null) {
|
||||
@ -1136,11 +1101,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
final LinkedList<Material> types = new LinkedList<>();
|
||||
final LinkedList<Enchantment> enchs = new LinkedList<>();
|
||||
final LinkedList<Integer> amts;
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantments")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".enchantments"), String.class)) {
|
||||
for (final String enchant : config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".enchantments")) {
|
||||
if (config.contains(ordered + ".enchantments")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".enchantments"), String.class)) {
|
||||
for (final String enchant : config.getStringList(ordered + ".enchantments")) {
|
||||
final Enchantment e = BukkitItemUtil.getEnchantmentFromProperName(enchant);
|
||||
if (e != null) {
|
||||
enchs.add(e);
|
||||
@ -1150,13 +1113,13 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
}
|
||||
}
|
||||
} 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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".enchantment-item-names"), String.class)) {
|
||||
for (final String item : config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".enchantment-item-names")) {
|
||||
if (config.contains(ordered + ".enchantment-item-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".enchantment-item-names"),
|
||||
String.class)) {
|
||||
for (final String item : config.getStringList(ordered + ".enchantment-item-names")) {
|
||||
if (Material.matchMaterial(item) != null) {
|
||||
types.add(Material.matchMaterial(item));
|
||||
} else {
|
||||
@ -1165,18 +1128,19 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
}
|
||||
}
|
||||
} 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 {
|
||||
throw new StageFormatException("'enchantment-item-names' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
if (config.contains(ordered + ".enchantment-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered
|
||||
+ ".enchantment-amounts"), Integer.class)) {
|
||||
amts = new LinkedList<>(config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".enchantment-amounts"));
|
||||
amts = new LinkedList<>(config.getIntegerList(ordered + ".enchantment-amounts"));
|
||||
} 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 {
|
||||
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")) {
|
||||
itemsToBrew = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".items-to-brew");
|
||||
if (config.contains(ordered + ".items-to-brew")) {
|
||||
itemsToBrew = (List<ItemStack>) config.get(ordered + ".items-to-brew");
|
||||
if (BukkitConfigUtil.checkList(itemsToBrew, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToBrew) {
|
||||
if (stack != null) {
|
||||
@ -1206,9 +1169,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'items-to-brew' has invalid formatting", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-consume")) {
|
||||
itemsToConsume = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".items-to-consume");
|
||||
if (config.contains(ordered + ".items-to-consume")) {
|
||||
itemsToConsume = (List<ItemStack>) config.get(ordered + ".items-to-consume");
|
||||
if (BukkitConfigUtil.checkList(itemsToConsume, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToConsume) {
|
||||
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.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk", -999)
|
||||
!= -999) {
|
||||
oStage.setCowsToMilk(config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".cows-to-milk"));
|
||||
if (config.contains(ordered + ".cows-to-milk")) {
|
||||
if (config.getInt(ordered + ".cows-to-milk", -999) != -999) {
|
||||
oStage.setCowsToMilk(config.getInt(ordered + ".cows-to-milk"));
|
||||
} else {
|
||||
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.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch", -999)
|
||||
!= -999) {
|
||||
oStage.setFishToCatch(config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".fish-to-catch"));
|
||||
if (config.contains(ordered + ".fish-to-catch")) {
|
||||
if (config.getInt(ordered + ".fish-to-catch", -999) != -999) {
|
||||
oStage.setFishToCatch(config.getInt(ordered + ".fish-to-catch"));
|
||||
} else {
|
||||
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.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill", -999)
|
||||
!= -999) {
|
||||
oStage.setPlayersToKill(config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".players-to-kill"));
|
||||
if (config.contains(ordered + ".players-to-kill")) {
|
||||
if (config.getInt(ordered + ".players-to-kill", -999) != -999) {
|
||||
oStage.setPlayersToKill(config.getInt(ordered + ".players-to-kill"));
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-uuids-to-talk-to"), String.class)) {
|
||||
npcUuidsToTalkTo = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-uuids-to-talk-to");
|
||||
if (config.contains(ordered + ".npc-uuids-to-talk-to")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-uuids-to-talk-to"), String.class)) {
|
||||
npcUuidsToTalkTo = config.getStringList(ordered + ".npc-uuids-to-talk-to");
|
||||
for (final String s : npcUuidsToTalkTo) {
|
||||
final UUID uuid = UUID.fromString(s);
|
||||
oStage.addNpcToInteract(uuid);
|
||||
@ -1261,12 +1215,10 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
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
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-ids-to-talk-to"), Integer.class)) {
|
||||
npcIdsToTalkTo = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-ids-to-talk-to");
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-ids-to-talk-to"), Integer.class)) {
|
||||
npcIdsToTalkTo = config.getIntegerList(ordered + ".npc-ids-to-talk-to");
|
||||
for (final int i : npcIdsToTalkTo) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-deliver")) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-uuids")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
if (config.contains(ordered + ".items-to-deliver")) {
|
||||
if (config.contains(ordered + ".npc-delivery-uuids")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered
|
||||
+ ".npc-delivery-uuids"), String.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||
if (config.contains(ordered
|
||||
+ ".delivery-messages")) {
|
||||
itemsToDeliver = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".items-to-deliver");
|
||||
itemDeliveryTargetUuids = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".npc-delivery-uuids");
|
||||
deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".delivery-messages");
|
||||
itemsToDeliver = (List<ItemStack>) config.get(ordered + ".items-to-deliver");
|
||||
itemDeliveryTargetUuids = config.getStringList(ordered + ".npc-delivery-uuids");
|
||||
deliveryMessages = config.getStringList(ordered + ".delivery-messages");
|
||||
int index = 0;
|
||||
if (BukkitConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToDeliver) {
|
||||
@ -1323,26 +1272,19 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
throw new StageFormatException("'npc-delivery-uuids' is not a list of numbers", quest, stageNum);
|
||||
}
|
||||
} else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-delivery-ids")) {
|
||||
} else if (config.contains(ordered + ".npc-delivery-ids")) {
|
||||
// Legacy
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-delivery-ids"), Integer.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".delivery-messages")) {
|
||||
itemsToDeliver = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered."
|
||||
+ 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");
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-delivery-ids"), Integer.class)) {
|
||||
if (config.contains(ordered + ".delivery-messages")) {
|
||||
itemsToDeliver = (List<ItemStack>) config.get(ordered + ".items-to-deliver");
|
||||
itemDeliveryTargetIds = config.getIntegerList(ordered + ".npc-delivery-ids");
|
||||
deliveryMessages = config.getStringList(ordered + ".delivery-messages");
|
||||
int index = 0;
|
||||
if (BukkitConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
|
||||
for (final ItemStack stack : itemsToDeliver) {
|
||||
if (stack != null) {
|
||||
final int npcId = itemDeliveryTargetIds.get(index);
|
||||
final String msg = deliveryMessages.size() > index
|
||||
? deliveryMessages.get(index)
|
||||
final String msg = deliveryMessages.size() > index ? deliveryMessages.get(index)
|
||||
: deliveryMessages.get(deliveryMessages.size() - 1);
|
||||
index++;
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
@ -1373,16 +1315,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'npc-delivery-uuid' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-uuids-to-kill"), String.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-kill-amounts"), Integer.class)) {
|
||||
npcUuidsToKill = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-uuids-to-kill");
|
||||
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".npc-kill-amounts");
|
||||
if (config.contains(ordered + ".npc-uuids-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-uuids-to-kill"), String.class)) {
|
||||
if (config.contains(ordered + ".npc-kill-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-kill-amounts"), Integer.class)) {
|
||||
npcUuidsToKill = config.getStringList(ordered + ".npc-uuids-to-kill");
|
||||
npcAmountsToKill = config.getIntegerList(ordered + ".npc-kill-amounts");
|
||||
for (final String s : npcUuidsToKill) {
|
||||
final UUID npcUuid = UUID.fromString(s);
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-ids-to-kill"), Integer.class)) {
|
||||
} else if (config.contains(ordered + ".npc-ids-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-ids-to-kill"), Integer.class)) {
|
||||
// Legacy
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-kill-amounts"), Integer.class)) {
|
||||
npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".npc-ids-to-kill");
|
||||
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".npc-kill-amounts");
|
||||
if (config.contains(ordered + ".npc-kill-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".npc-kill-amounts"), Integer.class)) {
|
||||
npcIdsToKill = config.getIntegerList(ordered + ".npc-ids-to-kill");
|
||||
npcAmountsToKill = config.getIntegerList(ordered + ".npc-kill-amounts");
|
||||
for (final int i : npcIdsToKill) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".mobs-to-kill"), String.class)) {
|
||||
final List<String> mobNames = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".mobs-to-kill");
|
||||
if (config.contains(ordered + ".mobs-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".mobs-to-kill"), String.class)) {
|
||||
final List<String> mobNames = config.getStringList(ordered + ".mobs-to-kill");
|
||||
for (final String mob : mobNames) {
|
||||
final EntityType type = BukkitMiscUtil.getProperMobType(mob);
|
||||
if (type != null) {
|
||||
@ -1464,11 +1396,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".mob-amounts"), Integer.class)) {
|
||||
mobNumsToKill.addAll(config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".mob-amounts"));
|
||||
if (config.contains(ordered + ".mob-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".mob-amounts"), Integer.class)) {
|
||||
mobNumsToKill.addAll(config.getIntegerList(ordered + ".mob-amounts"));
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".locations-to-kill"), String.class)) {
|
||||
final List<String> locations = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".locations-to-kill");
|
||||
if (config.contains(ordered + ".locations-to-kill")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".locations-to-kill"), String.class)) {
|
||||
final List<String> locations = config.getStringList(ordered + ".locations-to-kill");
|
||||
for (final String loc : locations) {
|
||||
if (BukkitConfigUtil.getLocation(loc) != null) {
|
||||
locationsToKillWithin.add(BukkitConfigUtil.getLocation(loc));
|
||||
@ -1492,11 +1420,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".kill-location-radii"), Integer.class)) {
|
||||
final List<Integer> radii = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".kill-location-radii");
|
||||
if (config.contains(ordered + ".kill-location-radii")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".kill-location-radii"), Integer.class)) {
|
||||
final List<Integer> radii = config.getIntegerList(ordered + ".kill-location-radii");
|
||||
radiiToKillWithin.addAll(radii);
|
||||
} else {
|
||||
throw new StageFormatException("'kill-location-radii' is not a list of numbers", quest, stageNum);
|
||||
@ -1504,11 +1430,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
throw new StageFormatException("'kill-location-radii' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".kill-location-names"), String.class)) {
|
||||
final List<String> locationNames = config.getStringList("quests." + questKey
|
||||
+ ".stages.ordered." + stageNum + ".kill-location-names");
|
||||
if (config.contains(ordered + ".kill-location-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".kill-location-names"), String.class)) {
|
||||
final List<String> locationNames = config.getStringList(ordered + ".kill-location-names");
|
||||
areaNames.addAll(locationNames);
|
||||
} else {
|
||||
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) {
|
||||
oStage.addKillName(killName);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-reach")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".locations-to-reach"), String.class)) {
|
||||
final List<String> locations = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".locations-to-reach");
|
||||
if (config.contains(ordered + ".locations-to-reach")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".locations-to-reach"), String.class)) {
|
||||
final List<String> locations = config.getStringList(ordered + ".locations-to-reach");
|
||||
for (final String loc : locations) {
|
||||
if (BukkitConfigUtil.getLocation(loc) != null) {
|
||||
oStage.addLocationToReach(BukkitConfigUtil.getLocation(loc));
|
||||
@ -1548,11 +1470,10 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
if (config.contains(ordered + ".reach-location-radii")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered
|
||||
+ ".reach-location-radii"), Integer.class)) {
|
||||
final List<Integer> radii = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".reach-location-radii");
|
||||
final List<Integer> radii = config.getIntegerList(ordered + ".reach-location-radii");
|
||||
for (Integer radius : radii) {
|
||||
oStage.addRadiusToReachWithin(radius);
|
||||
}
|
||||
@ -1563,11 +1484,9 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
} else {
|
||||
throw new StageFormatException("'reach-location-radii' is missing", quest, stageNum);
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".reach-location-names"), String.class)) {
|
||||
final List<String> locationNames = config.getStringList("quests." + questKey
|
||||
+ ".stages.ordered." + stageNum + ".reach-location-names");
|
||||
if (config.contains(ordered + ".reach-location-names")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".reach-location-names"), String.class)) {
|
||||
final List<String> locationNames = config.getStringList(ordered + ".reach-location-names");
|
||||
for (String locationName : locationNames) {
|
||||
oStage.addLocationName(locationName);
|
||||
}
|
||||
@ -1578,16 +1497,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'reach-location-names' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-tame")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".mobs-to-tame"), String.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-tame-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".mob-tame-amounts"), Integer.class)) {
|
||||
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");
|
||||
if (config.contains(ordered + ".mobs-to-tame")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".mobs-to-tame"), String.class)) {
|
||||
if (config.contains(ordered + ".mob-tame-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".mob-tame-amounts"), Integer.class)) {
|
||||
final List<String> mobs = config.getStringList(ordered + ".mobs-to-tame");
|
||||
final List<Integer> mobAmounts = config.getIntegerList(ordered + ".mob-tame-amounts");
|
||||
for (final String mob : mobs) {
|
||||
final EntityType type = BukkitMiscUtil.getProperMobType(mob);
|
||||
if (type != null) {
|
||||
@ -1600,7 +1515,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
quest, stageNum);
|
||||
}
|
||||
} 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 {
|
||||
@ -1614,16 +1530,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
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 (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".sheep-to-shear"), String.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".sheep-amounts"), Integer.class)) {
|
||||
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");
|
||||
if (config.contains(ordered + ".sheep-to-shear")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".sheep-to-shear"), String.class)) {
|
||||
if (config.contains(ordered + ".sheep-amounts")) {
|
||||
if (BukkitConfigUtil.checkList(config.getList(ordered + ".sheep-amounts"), Integer.class)) {
|
||||
final List<String> sheep = config.getStringList(ordered + ".sheep-to-shear");
|
||||
final List<Integer> shearAmounts = config.getIntegerList(ordered + ".sheep-amounts");
|
||||
for (String sheepColor : sheep) {
|
||||
final String originalColor = sheepColor;
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-displays")) {
|
||||
final List<String> displays = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".password-displays");
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-phrases")) {
|
||||
final List<String> phrases = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".password-phrases");
|
||||
if (config.contains(ordered + ".password-displays")) {
|
||||
final List<String> displays = config.getStringList(ordered + ".password-displays");
|
||||
if (config.contains(ordered + ".password-phrases")) {
|
||||
final List<String> phrases = config.getStringList(ordered + ".password-phrases");
|
||||
if (displays.size() == phrases.size()) {
|
||||
for (int passIndex = 0; passIndex < displays.size(); passIndex++) {
|
||||
oStage.addPasswordDisplay(displays.get(passIndex));
|
||||
@ -1716,24 +1626,20 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'password-phrases' is missing", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override")) {
|
||||
final Object o = config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".objective-override");
|
||||
if (config.contains(ordered + ".objective-override")) {
|
||||
final Object o = config.get(ordered + ".objective-override");
|
||||
if (o instanceof List) {
|
||||
for (String objectiveOverride : config.getStringList("quests." + questKey
|
||||
+ ".stages.ordered." + stageNum + ".objective-override")) {
|
||||
for (String objectiveOverride : config.getStringList(ordered + ".objective-override")) {
|
||||
oStage.addObjectiveOverride(objectiveOverride);
|
||||
}
|
||||
} else {
|
||||
// Legacy
|
||||
final String s = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".objective-override");
|
||||
final String s = config.getString(ordered + ".objective-override");
|
||||
oStage.addObjectiveOverride(s);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) {
|
||||
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".start-event");
|
||||
if (config.contains(ordered + ".start-event")) {
|
||||
final String actionName = config.getString(ordered + ".start-event");
|
||||
final Optional<Action> action = plugin.getLoadedActions().stream()
|
||||
.filter(a -> a.getName().equals(actionName)).findAny();
|
||||
if (action.isPresent()) {
|
||||
@ -1742,9 +1648,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'start-event' failed to load", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")) {
|
||||
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".finish-event");
|
||||
if (config.contains(ordered + ".finish-event")) {
|
||||
final String actionName = config.getString(ordered + ".finish-event");
|
||||
final Optional<Action> action = plugin.getLoadedActions().stream()
|
||||
.filter(a -> a.getName().equals(actionName)).findAny();
|
||||
if (action.isPresent()) {
|
||||
@ -1753,9 +1658,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'finish-event' failed to load", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fail-event")) {
|
||||
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".fail-event");
|
||||
if (config.contains(ordered + ".fail-event")) {
|
||||
final String actionName = config.getString(ordered + ".fail-event");
|
||||
final Optional<Action> action = plugin.getLoadedActions().stream()
|
||||
.filter(a -> a.getName().equals(actionName)).findAny();
|
||||
if (action.isPresent()) {
|
||||
@ -1764,9 +1668,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'fail-event' failed to load", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")) {
|
||||
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".death-event");
|
||||
if (config.contains(ordered + ".death-event")) {
|
||||
final String actionName = config.getString(ordered + ".death-event");
|
||||
final Optional<Action> action = plugin.getLoadedActions().stream()
|
||||
.filter(a -> a.getName().equals(actionName)).findAny();
|
||||
if (action.isPresent()) {
|
||||
@ -1775,9 +1678,8 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'death-event' failed to load", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")) {
|
||||
final String actionName = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".disconnect-event");
|
||||
if (config.contains(ordered + ".disconnect-event")) {
|
||||
final String actionName = config.getString(ordered + ".disconnect-event");
|
||||
final Optional<Action> action = plugin.getLoadedActions().stream()
|
||||
.filter(a -> a.getName().equals(actionName)).findAny();
|
||||
if (action.isPresent()) {
|
||||
@ -1786,16 +1688,12 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'disconnect-event' failed to load", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) {
|
||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".chat-event-triggers")) {
|
||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".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");
|
||||
if (config.contains(ordered + ".chat-events")) {
|
||||
if (config.isList(ordered + ".chat-events")) {
|
||||
if (config.contains(ordered + ".chat-event-triggers")) {
|
||||
if (config.isList(ordered + ".chat-event-triggers")) {
|
||||
final List<String> chatEvents = config.getStringList(ordered + ".chat-events");
|
||||
final List<String> chatEventTriggers = config.getStringList(ordered + ".chat-event-triggers");
|
||||
for (int i = 0; i < chatEvents.size(); i++) {
|
||||
final String actionName = chatEvents.get(i);
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) {
|
||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".command-event-triggers")) {
|
||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".command-event-triggers")) {
|
||||
final List<String> commandEvents = config.getStringList("quests." + questKey
|
||||
+ ".stages.ordered." + stageNum + ".command-events");
|
||||
final List<String> commandEventTriggers = config.getStringList("quests." + questKey
|
||||
+ ".stages.ordered." + stageNum + ".command-event-triggers");
|
||||
if (config.contains(ordered + ".command-events")) {
|
||||
if (config.isList(ordered + ".command-events")) {
|
||||
if (config.contains(ordered + ".command-event-triggers")) {
|
||||
if (config.isList(ordered + ".command-event-triggers")) {
|
||||
final List<String> commandEvents = config.getStringList(ordered + ".command-events");
|
||||
final List<String> commandEventTriggers = config.getStringList(ordered
|
||||
+ ".command-event-triggers");
|
||||
for (int i = 0; i < commandEvents.size(); i++) {
|
||||
final String actionName = commandEvents.get(i);
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".condition")) {
|
||||
final String conditionName = config.getString("quests." + questKey + ".stages.ordered."
|
||||
+ stageNum + ".condition");
|
||||
if (config.contains(ordered + ".condition")) {
|
||||
final String conditionName = config.getString(ordered + ".condition");
|
||||
final Optional<Condition> condition = plugin.getLoadedConditions().stream()
|
||||
.filter(c -> c.getName().equals(conditionName)).findAny();
|
||||
if (condition.isPresent()) {
|
||||
@ -1873,25 +1767,22 @@ public class BukkitQuestYamlStorage implements QuestStorageImpl {
|
||||
throw new StageFormatException("'condition' failed to load", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) {
|
||||
final int delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999);
|
||||
if (config.contains(ordered + ".delay")) {
|
||||
final int delay = config.getInt(ordered + ".delay", -999);
|
||||
if (delay > 0) {
|
||||
oStage.setDelay(delay * 1000L);
|
||||
} else if (delay != -999) {
|
||||
throw new StageFormatException("'delay' is not a positive number", quest, stageNum);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay-message")) {
|
||||
oStage.setDelayMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".delay-message"));
|
||||
if (config.contains(ordered + ".delay-message")) {
|
||||
oStage.setDelayMessage(config.getString(ordered + ".delay-message"));
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-message")) {
|
||||
oStage.setStartMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".start-message"));
|
||||
if (config.contains(ordered + ".start-message")) {
|
||||
oStage.setStartMessage(config.getString(ordered + ".start-message"));
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".complete-message")) {
|
||||
oStage.setCompleteMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||
+ ".complete-message"));
|
||||
if (config.contains(ordered + ".complete-message")) {
|
||||
oStage.setCompleteMessage(config.getString(ordered + ".complete-message"));
|
||||
}
|
||||
quest.getStages().add(oStage);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
|
||||
quester.setCurrentQuests(currentQuests);
|
||||
final ConfigurationSection dataSec = data.getConfigurationSection("questData");
|
||||
if (dataSec == null || dataSec.getKeys(false).isEmpty()) {
|
||||
return null;
|
||||
return quester;
|
||||
}
|
||||
final ConcurrentHashMap<Quest, BukkitQuestProgress> questProgress = new ConcurrentHashMap<>();
|
||||
for (final String key : dataSec.getKeys(false)) {
|
||||
@ -172,100 +172,100 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
|
||||
if (questSec == null) {
|
||||
continue;
|
||||
}
|
||||
final BukkitQuestProgress bukkitQuestData = (BukkitQuestProgress) quester.getQuestDataOrDefault(quest);
|
||||
final BukkitQuestProgress bukkitQuestProgress = (BukkitQuestProgress) quester.getQuestProgressOrDefault(quest);
|
||||
if (questSec.contains("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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
// Legacy
|
||||
final List<Integer> npcAmounts = questSec.getIntegerList("citizen-amounts-killed");
|
||||
bukkitQuestData.setNpcsNumKilled(new LinkedList<>(npcAmounts));
|
||||
bukkitQuestProgress.setNpcsNumKilled(new LinkedList<>(npcAmounts));
|
||||
}
|
||||
if (questSec.contains("cows-milked")) {
|
||||
bukkitQuestData.setCowsMilked(questSec.getInt("cows-milked"));
|
||||
bukkitQuestProgress.setCowsMilked(questSec.getInt("cows-milked"));
|
||||
}
|
||||
if (questSec.contains("fish-caught")) {
|
||||
bukkitQuestData.setFishCaught(questSec.getInt("fish-caught"));
|
||||
bukkitQuestProgress.setFishCaught(questSec.getInt("fish-caught"));
|
||||
}
|
||||
if (questSec.contains("players-killed")) {
|
||||
bukkitQuestData.setPlayersKilled(questSec.getInt("players-killed"));
|
||||
bukkitQuestProgress.setPlayersKilled(questSec.getInt("players-killed"));
|
||||
}
|
||||
if (questSec.contains("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")) {
|
||||
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")) {
|
||||
final List<Integer> tameAmounts = questSec.getIntegerList("mob-tame-amounts");
|
||||
bukkitQuestData.setMobsTamed(new LinkedList<>(tameAmounts));
|
||||
bukkitQuestProgress.setMobsTamed(new LinkedList<>(tameAmounts));
|
||||
}
|
||||
if (questSec.contains("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")) {
|
||||
final List<Boolean> passAmounts = questSec.getBooleanList("passwords-said");
|
||||
bukkitQuestData.setPasswordsSaid(new LinkedList<>(passAmounts));
|
||||
bukkitQuestProgress.setPasswordsSaid(new LinkedList<>(passAmounts));
|
||||
}
|
||||
if (questSec.contains("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")) {
|
||||
bukkitQuestData.setDelayTimeLeft(questSec.getLong("stage-delay"));
|
||||
bukkitQuestProgress.setDelayTimeLeft(questSec.getLong("stage-delay"));
|
||||
}
|
||||
questProgress.put(quest, bukkitQuestData);
|
||||
questProgress.put(quest, bukkitQuestProgress);
|
||||
}
|
||||
quester.setQuestProgress(questProgress);
|
||||
}
|
||||
|
@ -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> oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
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());
|
||||
oldQuestData.removeAll(questData);
|
||||
oldQuestData.removeAll(questProgress);
|
||||
|
||||
try (final Connection c = connectionFactory.getConnection()) {
|
||||
if (oldLastKnownName != null && lastKnownName != null && !lastKnownName.equals(oldLastKnownName)) {
|
||||
|
@ -31,7 +31,7 @@ public class BukkitStageTimer implements Runnable {
|
||||
if (quester == null) {
|
||||
return;
|
||||
}
|
||||
if (quester.getQuestDataOrDefault(quest) == null) {
|
||||
if (quester.getQuestProgressOrDefault(quest) == null) {
|
||||
return;
|
||||
}
|
||||
if (quester.getCurrentStage(quest) == null) {
|
||||
@ -50,8 +50,8 @@ public class BukkitStageTimer implements Runnable {
|
||||
quest.completeQuest(quester);
|
||||
} else {
|
||||
final int stageNum = quester.getCurrentQuests().get(quest) + 1;
|
||||
quester.getQuestDataOrDefault(quest).setDelayStartTime(0);
|
||||
quester.getQuestDataOrDefault(quest).setDelayTimeLeft(-1);
|
||||
quester.getQuestProgressOrDefault(quest).setDelayStartTime(0);
|
||||
quester.getQuestProgressOrDefault(quest).setDelayTimeLeft(-1);
|
||||
try {
|
||||
quest.setStage(quester, stageNum);
|
||||
} catch (final IndexOutOfBoundsException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user