Track progress through int, part 4. See #2250

This commit is contained in:
PikaMug 2024-07-14 16:10:46 -04:00
parent 7e4f1ea561
commit c9c4979d60
2 changed files with 10 additions and 7 deletions

View File

@ -3476,17 +3476,17 @@ public class BukkitQuester implements Quester {
} }
if (!bukkitStage.getBlocksToCut().isEmpty()) { if (!bukkitStage.getBlocksToCut().isEmpty()) {
for (final ItemStack ignored : bukkitStage.getBlocksToCut()) { for (final ItemStack ignored : bukkitStage.getBlocksToCut()) {
data.blocksUsed.add(0); data.blocksCut.add(0);
} }
} }
if (!bukkitStage.getItemsToCraft().isEmpty()) { if (!bukkitStage.getItemsToCraft().isEmpty()) {
for (final ItemStack ignored : bukkitStage.getItemsToCraft()) { for (final ItemStack ignored : bukkitStage.getItemsToCraft()) {
data.blocksUsed.add(0); data.itemsCrafted.add(0);
} }
} }
if (!bukkitStage.getItemsToSmelt().isEmpty()) { if (!bukkitStage.getItemsToSmelt().isEmpty()) {
for (final ItemStack ignored : bukkitStage.getItemsToSmelt()) { for (final ItemStack ignored : bukkitStage.getItemsToSmelt()) {
data.blocksUsed.add(0); data.itemsSmelted.add(0);
} }
} }
if (!bukkitStage.getItemsToEnchant().isEmpty()) { if (!bukkitStage.getItemsToEnchant().isEmpty()) {
@ -3496,17 +3496,17 @@ public class BukkitQuester implements Quester {
} }
if (!bukkitStage.getItemsToBrew().isEmpty()) { if (!bukkitStage.getItemsToBrew().isEmpty()) {
for (final ItemStack ignored : bukkitStage.getItemsToBrew()) { for (final ItemStack ignored : bukkitStage.getItemsToBrew()) {
data.blocksUsed.add(0); data.itemsBrewed.add(0);
} }
} }
if (!bukkitStage.getItemsToConsume().isEmpty()) { if (!bukkitStage.getItemsToConsume().isEmpty()) {
for (final ItemStack ignored : bukkitStage.getItemsToConsume()) { for (final ItemStack ignored : bukkitStage.getItemsToConsume()) {
data.blocksUsed.add(0); data.itemsConsumed.add(0);
} }
} }
if (!bukkitStage.getItemsToDeliver().isEmpty()) { if (!bukkitStage.getItemsToDeliver().isEmpty()) {
for (final ItemStack ignored : bukkitStage.getItemsToDeliver()) { for (final ItemStack ignored : bukkitStage.getItemsToDeliver()) {
data.blocksUsed.add(0); data.itemsDelivered.add(0);
} }
} }
if (!quest.getStage(stage).getNpcsToInteract().isEmpty()) { if (!quest.getStage(stage).getNpcsToInteract().isEmpty()) {

View File

@ -62,7 +62,7 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
@Override @Override
public Quester loadQuester(final UUID uniqueId) throws IOException, InvalidConfigurationException { public Quester loadQuester(final UUID uniqueId) throws IOException, InvalidConfigurationException {
final FileConfiguration data = new YamlConfiguration(); final FileConfiguration data = new YamlConfiguration();
Quester quester = plugin.getQuester(uniqueId); BukkitQuester quester = plugin.getQuester(uniqueId);
if (quester != null) { if (quester != null) {
quester.hardClear(); quester.hardClear();
} else { } else {
@ -154,6 +154,7 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
if (dataSec == null || dataSec.getKeys(false).isEmpty()) { if (dataSec == null || dataSec.getKeys(false).isEmpty()) {
return null; return null;
} }
final ConcurrentHashMap<Quest, BukkitQuestProgress> questProgress = new ConcurrentHashMap<>();
for (final String key : dataSec.getKeys(false)) { for (final String key : dataSec.getKeys(false)) {
final ConfigurationSection questSec = dataSec.getConfigurationSection(key); final ConfigurationSection questSec = dataSec.getConfigurationSection(key);
final Quest quest = plugin.getQuestById(key) != null ? plugin.getQuestById(key) : plugin.getQuest(key); final Quest quest = plugin.getQuestById(key) != null ? plugin.getQuestById(key) : plugin.getQuest(key);
@ -264,7 +265,9 @@ public class BukkitQuesterYamlStorage implements QuesterStorageImpl {
if (questSec.contains("stage-delay")) { if (questSec.contains("stage-delay")) {
quester.getQuestDataOrDefault(quest).setDelayTimeLeft(questSec.getLong("stage-delay")); quester.getQuestDataOrDefault(quest).setDelayTimeLeft(questSec.getLong("stage-delay"));
} }
questProgress.put(quest, bukkitQuestData);
} }
quester.setQuestProgress(questProgress);
} }
return quester; return quester;
} }