Quest compass improvements, fixes #1872

This commit is contained in:
PikaMug 2022-02-04 06:41:23 -05:00
parent dc406ce60f
commit 63a6456d80
16 changed files with 227 additions and 103 deletions

View File

@ -52,8 +52,9 @@ public interface IQuester extends Comparable<IQuester> {
* Get compass target quest. Returns null if not set * Get compass target quest. Returns null if not set
* *
* @return Quest or null * @return Quest or null
* @deprecated Do not use
*/ */
IQuest getCompassTarget(); IQuest getCompassTargetTemp();
/** /**
* Set compass target quest. Does not update in-game * Set compass target quest. Does not update in-game
@ -75,7 +76,10 @@ public interface IQuester extends Comparable<IQuester> {
void setCurrentQuests(final ConcurrentHashMap<IQuest, Integer> currentQuests); void setCurrentQuests(final ConcurrentHashMap<IQuest, Integer> currentQuests);
ConcurrentSkipListSet<IQuest> getCompletedQuests(); /**
* @deprecated Do not use
*/
ConcurrentSkipListSet<IQuest> getCompletedQuestsTemp();
void setCompletedQuests(final ConcurrentSkipListSet<IQuest> completedQuests); void setCompletedQuests(final ConcurrentSkipListSet<IQuest> completedQuests);

View File

@ -305,6 +305,13 @@ public interface IStage {
*/ */
boolean hasObjective(); boolean hasObjective();
/**
* Check if stage has at least one objective of which the target can be located easily<p>
*
* @return true if stage contains a locatable objective
*/
boolean hasLocatableObjective();
/** /**
* Check if stage has the specified type of objective<p> * Check if stage has the specified type of objective<p>
* *

View File

@ -420,13 +420,13 @@ public class Quest implements IQuest {
} }
/** /**
* Set location-objective target for compass.<p> * Attempt to set location-objective target for compass.<p>
* *
* Method may be called as often as needed. * Method may be called as often as needed.
* *
* @param quester The online quester to have their compass updated * @param quester The online quester to have their compass updated
* @param stage The stage to process for targets * @param stage The stage to process for targets
* @return true if an attempt was made successfully * @return true if quester is online and has permission
*/ */
public boolean updateCompass(final IQuester quester, final IStage stage) { public boolean updateCompass(final IQuester quester, final IStage stage) {
if (quester == null) { if (quester == null) {
@ -551,6 +551,7 @@ public class Quest implements IQuest {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
quester.setCompassTarget(this);
quester.getPlayer().setCompassTarget(lockedTarget); quester.getPlayer().setCompassTarget(lockedTarget);
} }
} }
@ -588,11 +589,11 @@ public class Quest implements IQuest {
if (quester.getQuestPoints() < requirements.getQuestPoints()) { if (quester.getQuestPoints() < requirements.getQuestPoints()) {
return false; return false;
} }
if (!quester.getCompletedQuests().containsAll(requirements.getNeededQuests())) { if (!quester.getCompletedQuestsTemp().containsAll(requirements.getNeededQuests())) {
return false; return false;
} }
for (final IQuest q : requirements.getBlockQuests()) { for (final IQuest q : requirements.getBlockQuests()) {
if (quester.getCompletedQuests().contains(q) || quester.getCurrentQuestsTemp().containsKey(q)) { if (quester.getCompletedQuestsTemp().contains(q) || quester.getCurrentQuestsTemp().containsKey(q)) {
return false; return false;
} }
} }
@ -697,7 +698,7 @@ public class Quest implements IQuest {
return; return;
} }
quester.hardQuit(this); quester.hardQuit(this);
quester.getCompletedQuests().add(this); quester.getCompletedQuestsTemp().add(this);
for (final Map.Entry<Integer, IQuest> entry : quester.getTimers().entrySet()) { for (final Map.Entry<Integer, IQuest> entry : quester.getTimers().entrySet()) {
if (entry.getValue().getName().equals(getName())) { if (entry.getValue().getName().equals(getName())) {
plugin.getServer().getScheduler().cancelTask(entry.getKey()); plugin.getServer().getScheduler().cancelTask(entry.getKey());

View File

@ -303,25 +303,37 @@ public class Quester implements IQuester {
public void setQuestPoints(final int questPoints) { public void setQuestPoints(final int questPoints) {
this.questPoints = questPoints; this.questPoints = questPoints;
} }
/** /**
* Get compass target quest. Returns null if not set * Get compass target quest. Returns null if not set
* *
* @return Quest or null * @return Quest or null
*/ */
@Override public Quest getCompassTarget() {
public IQuest getCompassTarget() {
return compassTargetQuestId != null ? plugin.getQuestById(compassTargetQuestId) : null; return compassTargetQuestId != null ? plugin.getQuestById(compassTargetQuestId) : null;
} }
/**
* Get compass target quest. Returns null if not set
*
* @return Quest or null
* @deprecated Do not use
*/
@Override
public IQuest getCompassTargetTemp() {
return compassTargetQuestId != null ? plugin.getQuestByIdTemp(compassTargetQuestId) : null;
}
/** /**
* Set compass target quest. Does not update in-game * Set compass target quest. Does not update in-game
* *
* @param quest The target quest * @param quest The target quest
*/ */
@Override @Override
public void setCompassTarget(final IQuest quest) { public void setCompassTarget(final IQuest quest) {
compassTargetQuestId = quest.getId(); if (quest != null) {
compassTargetQuestId = quest.getId();
}
} }
@Override @Override
@ -361,8 +373,20 @@ public class Quester implements IQuester {
this.currentQuests = currentQuests; this.currentQuests = currentQuests;
} }
public ConcurrentSkipListSet<Quest> getCompletedQuests() {
final ConcurrentSkipListSet<Quest> set = new ConcurrentSkipListSet<>();
for (IQuest iq : completedQuests) {
final Quest q = (Quest) iq;
set.add(q);
}
return set;
}
/**
* @deprecated Do not use
*/
@Override @Override
public ConcurrentSkipListSet<IQuest> getCompletedQuests() { public ConcurrentSkipListSet<IQuest> getCompletedQuestsTemp() {
return completedQuests; return completedQuests;
} }
@ -554,7 +578,7 @@ public class Quester implements IQuester {
sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (getCompletedQuests().contains(quest) && quest.getPlanner().getCooldown() < 0) { } else if (getCompletedQuestsTemp().contains(quest) && quest.getPlanner().getCooldown() < 0) {
if (giveReason) { if (giveReason) {
final String msg = Lang.get(getPlayer(), "questAlreadyCompleted") final String msg = Lang.get(getPlayer(), "questAlreadyCompleted")
.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); .replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW);
@ -582,7 +606,7 @@ public class Quester implements IQuester {
sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (getCompletedQuests().contains(quest) && getRemainingCooldown(quest) > 0 } else if (getCompletedQuestsTemp().contains(quest) && getRemainingCooldown(quest) > 0
&& !quest.getPlanner().getOverride()) { && !quest.getPlanner().getOverride()) {
if (giveReason) { if (giveReason) {
final String msg = Lang.get(getPlayer(), "questTooEarly").replace("<quest>", ChatColor.AQUA final String msg = Lang.get(getPlayer(), "questTooEarly").replace("<quest>", ChatColor.AQUA
@ -833,8 +857,9 @@ public class Quester implements IQuester {
if (stage.getStartAction() != null) { if (stage.getStartAction() != null) {
stage.getStartAction().fire(this, quest); stage.getStartAction().fire(this, quest);
} }
quest.updateCompass(this, stage);
saveData(); saveData();
setCompassTarget(quest);
quest.updateCompass(this, stage);
} else { } else {
if (offlinePlayer.isOnline()) { if (offlinePlayer.isOnline()) {
sendMessage(ChatColor.DARK_AQUA + Lang.get("requirements")); sendMessage(ChatColor.DARK_AQUA + Lang.get("requirements"));
@ -972,7 +997,7 @@ public class Quester implements IQuester {
} }
for (final IQuest q : requirements.getNeededQuests()) { for (final IQuest q : requirements.getNeededQuests()) {
if (q != null) { if (q != null) {
if (getCompletedQuests().contains(q)) { if (getCompletedQuestsTemp().contains(q)) {
finishedRequirements.add(ChatColor.GREEN + q.getName()); finishedRequirements.add(ChatColor.GREEN + q.getName());
} else { } else {
unfinishedRequirements.add(ChatColor.GRAY + q.getName()); unfinishedRequirements.add(ChatColor.GRAY + q.getName());
@ -4149,7 +4174,13 @@ public class Quester implements IQuester {
} }
for (final IQuest quest : currentQuests.keySet()) { for (final IQuest quest : currentQuests.keySet()) {
final IStage stage = getCurrentStage(quest); final IStage stage = getCurrentStage(quest);
if (stage != null && quest.updateCompass(this, stage)) { if (stage != null) {
if (stage.hasLocatableObjective()) {
quest.updateCompass(this, stage);
} else {
resetCompass();
setCompassTarget(quest);
}
break; break;
} }
} }
@ -4179,14 +4210,23 @@ public class Quester implements IQuester {
} }
} }
if (list.size() > 0) { if (list.size() > 0) {
final IQuest quest = plugin.getQuestById(list.get(index)); final IQuest quest = plugin.getQuestByIdTemp(list.get(index));
compassTargetQuestId = quest.getId(); compassTargetQuestId = quest.getId();
final IStage stage = getCurrentStage(quest); final IStage stage = getCurrentStage(quest);
if (stage != null) { if (stage != null) {
quest.updateCompass(Quester.this, stage); if (stage.hasLocatableObjective()) {
if (notify) { quest.updateCompass(Quester.this, stage);
sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "compassSet") if (notify) {
.replace("<quest>", ChatColor.GOLD + quest.getName() + ChatColor.YELLOW)); sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "compassSet")
.replace("<quest>", ChatColor.GOLD + quest.getName() + ChatColor.YELLOW));
}
} else {
resetCompass();
setCompassTarget(quest);
if (notify) {
sendMessage(ChatColor.RED + Lang.get(getPlayer(), "compassNone")
.replace("<quest>", ChatColor.GRAY + quest.getName() + ChatColor.RED));
}
} }
} }
} else { } else {

View File

@ -693,13 +693,13 @@ public class Quests extends JavaPlugin implements QuestsAPI {
} }
final String questIdToTake = quester.getQuestIdToTake(); final String questIdToTake = quester.getQuestIdToTake();
try { try {
if (getQuestById(questIdToTake) == null) { if (getQuestByIdTemp(questIdToTake) == null) {
getLogger().info(player.getName() + " attempted to take quest ID \"" + questIdToTake getLogger().info(player.getName() + " attempted to take quest ID \"" + questIdToTake
+ "\" but something went wrong"); + "\" but something went wrong");
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "Something went wrong! Please report issue to an administrator."); + "Something went wrong! Please report issue to an administrator.");
} else { } else {
getQuester(player.getUniqueId()).takeQuest(getQuestById(questIdToTake), false); getQuester(player.getUniqueId()).takeQuest(getQuestByIdTemp(questIdToTake), false);
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -934,7 +934,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
for (final String questKey : questsSection.getKeys(false)) { for (final String questKey : questsSection.getKeys(false)) {
try { try {
if (config.contains("quests." + questKey)) { if (config.contains("quests." + questKey)) {
loadCustomSections(getQuestById(questKey), config, questKey); loadCustomSections(getQuestByIdTemp(questKey), config, questKey);
} else { } else {
throw new QuestFormatException("Unable to load custom sections", questKey); throw new QuestFormatException("Unable to load custom sections", questKey);
} }
@ -1596,7 +1596,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
if (getSettings().canIgnoreLockedQuests()) { if (getSettings().canIgnoreLockedQuests()) {
final LinkedList<IQuest> available = new LinkedList<>(); final LinkedList<IQuest> available = new LinkedList<>();
for (final IQuest q : quests) { for (final IQuest q : quests) {
if (!quester.getCompletedQuests().contains(q)) { if (!quester.getCompletedQuestsTemp().contains(q)) {
if (q.testRequirements(player)) { if (q.testRequirements(player)) {
available.add(q); available.add(q);
} }
@ -2167,10 +2167,10 @@ public class Quests extends JavaPlugin implements QuestsAPI {
final String node2 = config.getString("quests." + id + ".name"); final String node2 = config.getString("quests." + id + ".name");
if (node2 != null && (id.equals(node) || node2.equalsIgnoreCase(node) if (node2 != null && (id.equals(node) || node2.equalsIgnoreCase(node)
|| ChatColor.stripColor(node2).equalsIgnoreCase(ChatColor.stripColor(node)))) { || ChatColor.stripColor(node2).equalsIgnoreCase(ChatColor.stripColor(node)))) {
if (getQuest(node) != null) { if (getQuestTemp(node) != null) {
temp.add(getQuest(node)); temp.add(getQuestTemp(node));
} else if (getQuestById(node) != null) { } else if (getQuestByIdTemp(node) != null) {
temp.add(getQuestById(node)); temp.add(getQuestByIdTemp(node));
} else { } else {
throw new QuestFormatException("Requirement quest-blocks has unknown quest name/id " throw new QuestFormatException("Requirement quest-blocks has unknown quest name/id "
+ node + ", place it earlier in file so it loads first", questKey); + node + ", place it earlier in file so it loads first", questKey);
@ -2206,10 +2206,10 @@ public class Quests extends JavaPlugin implements QuestsAPI {
final String node2 = config.getString("quests." + id + ".name"); final String node2 = config.getString("quests." + id + ".name");
if (node2 != null && (id.equals(node) || node2.equalsIgnoreCase(node) if (node2 != null && (id.equals(node) || node2.equalsIgnoreCase(node)
|| ChatColor.stripColor(node2).equalsIgnoreCase(ChatColor.stripColor(node)))) { || ChatColor.stripColor(node2).equalsIgnoreCase(ChatColor.stripColor(node)))) {
if (getQuest(node) != null) { if (getQuestTemp(node) != null) {
temp.add(getQuest(node)); temp.add(getQuestTemp(node));
} else if (getQuestById(node) != null) { } else if (getQuestByIdTemp(node) != null) {
temp.add(getQuestById(node)); temp.add(getQuestByIdTemp(node));
} else { } else {
throw new QuestFormatException("Requirement quests has unknown quest name " throw new QuestFormatException("Requirement quests has unknown quest name "
+ node + ", place it earlier in file so it loads first", questKey); + node + ", place it earlier in file so it loads first", questKey);
@ -4225,15 +4225,36 @@ public class Quests extends JavaPlugin implements QuestsAPI {
} }
return player.hasPermission("quests.mode.trial"); return player.hasPermission("quests.mode.trial");
} }
/**
* Get a Quest by ID
*
* @param id ID of the quest
* @return Exact match or null if not found
* @since 3.8.6
*/
public Quest getQuestById(final String id) {
if (id == null) {
return null;
}
for (final IQuest iq : quests) {
final Quest q = (Quest) iq;
if (q.getId().equals(id)) {
return q;
}
}
return null;
}
/** /**
* Get a Quest by ID * Get a Quest by ID
* *
* @param id ID of the quest * @param id ID of the quest
* @return Exact match or null if not found * @return Exact match or null if not found
* @since 3.8.6 * @since 3.8.6
* @deprecated Do not use
*/ */
public IQuest getQuestById(final String id) { public IQuest getQuestByIdTemp(final String id) {
if (id == null) { if (id == null) {
return null; return null;
} }
@ -4244,6 +4265,37 @@ public class Quests extends JavaPlugin implements QuestsAPI {
} }
return null; return null;
} }
/**
* Get a Quest by name
*
* @param name Name of the quest
* @return Closest match or null if not found
*/
public Quest getQuest(final String name) {
if (name == null) {
return null;
}
for (final IQuest iq : quests) {
final Quest q = (Quest) iq;
if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
return q;
}
}
for (final IQuest iq : quests) {
final Quest q = (Quest) iq;
if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return q;
}
}
for (final IQuest iq : quests) {
final Quest q = (Quest) iq;
if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return q;
}
}
return null;
}
/** /**
* Get a Quest by name * Get a Quest by name
@ -4251,7 +4303,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
* @param name Name of the quest * @param name Name of the quest
* @return Closest match or null if not found * @return Closest match or null if not found
*/ */
public IQuest getQuest(final String name) { public IQuest getQuestTemp(final String name) {
if (name == null) { if (name == null) {
return null; return null;
} }
@ -4338,7 +4390,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
*/ */
public boolean hasQuest(final NPC npc, final IQuester quester) { public boolean hasQuest(final NPC npc, final IQuester quester) {
for (final IQuest q : quests) { for (final IQuest q : quests) {
if (q.getNpcStart() != null && !quester.getCompletedQuests().contains(q)) { if (q.getNpcStart() != null && !quester.getCompletedQuestsTemp().contains(q)) {
if (q.getNpcStart().getId() == npc.getId()) { if (q.getNpcStart().getId() == npc.getId()) {
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
if (!ignoreLockedQuests || q.testRequirements(quester)) { if (!ignoreLockedQuests || q.testRequirements(quester)) {
@ -4360,7 +4412,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
*/ */
public boolean hasCompletedQuest(final NPC npc, final IQuester quester) { public boolean hasCompletedQuest(final NPC npc, final IQuester quester) {
for (final IQuest q : quests) { for (final IQuest q : quests) {
if (q.getNpcStart() != null && quester.getCompletedQuests().contains(q)) { if (q.getNpcStart() != null && quester.getCompletedQuestsTemp().contains(q)) {
if (q.getNpcStart().getId() == npc.getId()) { if (q.getNpcStart().getId() == npc.getId()) {
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
if (!ignoreLockedQuests || q.testRequirements(quester)) { if (!ignoreLockedQuests || q.testRequirements(quester)) {
@ -4381,7 +4433,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
*/ */
public boolean hasCompletedRedoableQuest(final NPC npc, final IQuester quester) { public boolean hasCompletedRedoableQuest(final NPC npc, final IQuester quester) {
for (final IQuest q : quests) { for (final IQuest q : quests) {
if (q.getNpcStart() != null && quester.getCompletedQuests().contains(q) if (q.getNpcStart() != null && quester.getCompletedQuestsTemp().contains(q)
&& q.getPlanner().getCooldown() > -1) { && q.getPlanner().getCooldown() > -1) {
if (q.getNpcStart().getId() == npc.getId()) { if (q.getNpcStart().getId() == npc.getId()) {
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();

View File

@ -763,11 +763,29 @@ public class Stage implements IStage {
if (!citizensToInteract.isEmpty()) { return true; } if (!citizensToInteract.isEmpty()) { return true; }
if (!citizensToKill.isEmpty()) { return true; } if (!citizensToKill.isEmpty()) { return true; }
if (!locationsToReach.isEmpty()) { return true; } if (!locationsToReach.isEmpty()) { return true; }
if (!mobsToKill.isEmpty()) {return true; }
if (!mobsToTame.isEmpty()) { return true; } if (!mobsToTame.isEmpty()) { return true; }
if (!sheepToShear.isEmpty()) { return true; } if (!sheepToShear.isEmpty()) { return true; }
if (!passwordDisplays.isEmpty()) { return true; } if (!passwordDisplays.isEmpty()) { return true; }
return !customObjectives.isEmpty(); return !customObjectives.isEmpty();
} }
/**
* Check if stage has at least one objective of which the target can be easily located<p>
*
* @return true if stage contains a locatable objective
*/
public boolean hasLocatableObjective() {
if (!citizensToInteract.isEmpty()) { return true; }
if (!citizensToKill.isEmpty()) { return true; }
if (!locationsToReach.isEmpty()) { return true; }
if (!itemDeliveryTargets.isEmpty()) { return true; }
if (playersToKill != null) { return true; }
if (!mobsToKill.isEmpty()) {return true; }
if (!mobsToTame.isEmpty()) { return true; }
if (!sheepToShear.isEmpty()) { return true; }
return false;
}
/** /**
* Check if stage has the specified type of objective<p> * Check if stage has the specified type of objective<p>

View File

@ -71,7 +71,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
if (quests != null && number > 0) { if (quests != null && number > 0) {
if (number < (quests.size() + 1)) { if (number < (quests.size() + 1)) {
final IQuest quest = quests.get(number - 1); final IQuest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuestsTemp().contains(quest)) {
return ChatColor.GREEN; return ChatColor.GREEN;
} else { } else {
return ChatColor.GOLD; return ChatColor.GOLD;
@ -94,7 +94,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
if (quests != null && number > 0) { if (quests != null && number > 0) {
if (number < (quests.size() + 1)) { if (number < (quests.size() + 1)) {
final IQuest quest = quests.get(number - 1); final IQuest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuestsTemp().contains(quest)) {
return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName(); return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName();
} else { } else {
return ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName(); return ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName();
@ -116,7 +116,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
if (quests != null && number > 0) { if (quests != null && number > 0) {
if (number < (quests.size() + 1)) { if (number < (quests.size() + 1)) {
final IQuest quest = quests.get(number - 1); final IQuest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuestsTemp().contains(quest)) {
return ChatColor.GREEN + "" + Lang.get("redoCompleted"); return ChatColor.GREEN + "" + Lang.get("redoCompleted");
} }
} }
@ -240,7 +240,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
} }
private String extracted(final Quests plugin, final IQuester quester) { private String extracted(final Quests plugin, final IQuester quester) {
final IQuest quest = plugin.getQuestById(quester.getQuestIdToTake()); final IQuest quest = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription()); quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
} }

View File

@ -107,7 +107,7 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
} }
final String questIdToQuit = quester.getQuestIdToQuit(); final String questIdToQuit = quester.getQuestIdToQuit();
try { try {
IQuest quest = plugin.getQuestById(questIdToQuit); IQuest quest = plugin.getQuestByIdTemp(questIdToQuit);
if (quest == null) { if (quest == null) {
plugin.getLogger().info(player.getName() + " attempted to quit quest ID \"" + questIdToQuit plugin.getLogger().info(player.getName() + " attempted to quit quest ID \"" + questIdToQuit
+ "\" but something went wrong"); + "\" but something went wrong");
@ -116,7 +116,7 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
} else { } else {
final String msg = ChatColor.YELLOW + Lang.get("questQuit").replace("<quest>", final String msg = ChatColor.YELLOW + Lang.get("questQuit").replace("<quest>",
ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW);
quester.quitQuest(plugin.getQuestById(questIdToQuit), msg); quester.quitQuest(plugin.getQuestByIdTemp(questIdToQuit), msg);
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -231,7 +231,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final IQuest q = plugin.getQuest(input); final IQuest q = plugin.getQuestTemp(input);
if (q != null) { if (q != null) {
plugin.getQuestFactory().loadQuest(context, q); plugin.getQuestFactory().loadQuest(context, q);
return new QuestMainPrompt(context); return new QuestMainPrompt(context);
@ -275,7 +275,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<>(); final LinkedList<String> used = new LinkedList<>();
final IQuest found = plugin.getQuest(input); final IQuest found = plugin.getQuestTemp(input);
if (found != null) { if (found != null) {
for (final IQuest q : plugin.getLoadedQuests()) { for (final IQuest q : plugin.getLoadedQuests()) {
if (q.getRequirements().getNeededQuests().contains(q) if (q.getRequirements().getNeededQuests().contains(q)

View File

@ -222,8 +222,8 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
final List<String> questReq = (List<String>) context.getSessionData(CK.REQ_QUEST); final List<String> questReq = (List<String>) context.getSessionData(CK.REQ_QUEST);
if (questReq != null) { if (questReq != null) {
for (String s : questReq) { for (String s : questReq) {
if (plugin.getQuestById(s) != null) { if (plugin.getQuestByIdTemp(s) != null) {
s = plugin.getQuestById(s).getName(); s = plugin.getQuestByIdTemp(s).getName();
} }
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s); text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s);
} }
@ -238,8 +238,8 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
final List<String> questBlockReq = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK); final List<String> questBlockReq = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
if (questBlockReq != null) { if (questBlockReq != null) {
for (String s : questBlockReq) { for (String s : questBlockReq) {
if (plugin.getQuestById(s) != null) { if (plugin.getQuestByIdTemp(s) != null) {
s = plugin.getQuestById(s).getName(); s = plugin.getQuestByIdTemp(s).getName();
} }
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s); text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s);
} }
@ -877,17 +877,17 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
final String[] args = input.split(Lang.get("charSemi")); final String[] args = input.split(Lang.get("charSemi"));
final LinkedList<String> questIds = new LinkedList<>(); final LinkedList<String> questIds = new LinkedList<>();
for (final String s : args) { for (final String s : args) {
if (plugin.getQuest(s) == null) { if (plugin.getQuestTemp(s) == null) {
String text = Lang.get("reqNotAQuestName"); String text = Lang.get("reqNotAQuestName");
text = text.replace("<quest>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED); text = text.replace("<quest>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
context.getForWhom().sendRawMessage(text); context.getForWhom().sendRawMessage(text);
return new RequirementsQuestListPrompt(context, isRequiredQuest); return new RequirementsQuestListPrompt(context, isRequiredQuest);
} }
if (questIds.contains(plugin.getQuest(s).getId())) { if (questIds.contains(plugin.getQuestTemp(s).getId())) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listDuplicate")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listDuplicate"));
return new RequirementsQuestListPrompt(context, isRequiredQuest); return new RequirementsQuestListPrompt(context, isRequiredQuest);
} }
questIds.add(plugin.getQuest(s).getId()); questIds.add(plugin.getQuestTemp(s).getId());
} }
if (isRequiredQuest) { if (isRequiredQuest) {
context.setSessionData(CK.REQ_QUEST, questIds); context.setSessionData(CK.REQ_QUEST, questIds);

View File

@ -344,7 +344,7 @@ public class CmdExecutor implements CommandExecutor {
index++; index++;
} }
} }
final IQuest q = plugin.getQuest(name.toString()); final IQuest q = plugin.getQuestTemp(name.toString());
if (q != null) { if (q != null) {
final Player player = (Player) cs; final Player player = (Player) cs;
final IQuester quester = plugin.getQuester(player.getUniqueId()); final IQuester quester = plugin.getQuester(player.getUniqueId());
@ -437,7 +437,7 @@ public class CmdExecutor implements CommandExecutor {
} }
if (!reqs.getNeededQuests().isEmpty()) { if (!reqs.getNeededQuests().isEmpty()) {
for (final IQuest quest : reqs.getNeededQuests()) { for (final IQuest quest : reqs.getNeededQuests()) {
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuestsTemp().contains(quest)) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " "
+ ChatColor.ITALIC + quest.getName()); + ChatColor.ITALIC + quest.getName());
} else { } else {
@ -448,7 +448,7 @@ public class CmdExecutor implements CommandExecutor {
} }
if (!reqs.getBlockQuests().isEmpty()) { if (!reqs.getBlockQuests().isEmpty()) {
for (final IQuest quest : reqs.getBlockQuests()) { for (final IQuest quest : reqs.getBlockQuests()) {
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuestsTemp().contains(quest)) {
String msg = Lang.get("haveCompleted"); String msg = Lang.get("haveCompleted");
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
+ quest.getName() + ChatColor.RED); + quest.getName() + ChatColor.RED);
@ -630,18 +630,18 @@ public class CmdExecutor implements CommandExecutor {
} }
cs.sendMessage(ChatColor.YELLOW + Lang.get("completedQuest")); cs.sendMessage(ChatColor.YELLOW + Lang.get("completedQuest"));
if (quester.getCompletedQuests().isEmpty()) { if (quester.getCompletedQuestsTemp().isEmpty()) {
cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none")); cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none"));
} else { } else {
final StringBuilder completed = new StringBuilder(" "); final StringBuilder completed = new StringBuilder(" ");
int index = 1; int index = 1;
for (final IQuest q : quester.getCompletedQuests()) { for (final IQuest q : quester.getCompletedQuestsTemp()) {
completed.append(ChatColor.DARK_PURPLE).append(q.getName()); completed.append(ChatColor.DARK_PURPLE).append(q.getName());
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) { if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted() completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
.get(q)).append(")"); .get(q)).append(")");
} }
if (index < (quester.getCompletedQuests().size())) { if (index < (quester.getCompletedQuestsTemp().size())) {
completed.append(", "); completed.append(", ");
} }
index++; index++;
@ -698,7 +698,7 @@ public class CmdExecutor implements CommandExecutor {
} }
final IQuester quester = plugin.getQuester(player.getUniqueId()); final IQuester quester = plugin.getQuester(player.getUniqueId());
if (!quester.getCurrentQuestsTemp().isEmpty()) { if (!quester.getCurrentQuestsTemp().isEmpty()) {
final IQuest quest = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' ')); final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
if (quest != null) { if (quest != null) {
if (quest.getOptions().canAllowQuitting()) { if (quest.getOptions().canAllowQuitting()) {
final String msg = ChatColor.YELLOW + Lang.get("questQuit").replace("<quest>", final String msg = ChatColor.YELLOW + Lang.get("questQuit").replace("<quest>",
@ -724,7 +724,7 @@ public class CmdExecutor implements CommandExecutor {
if (args.length == 1) { if (args.length == 1) {
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE")); Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
} else { } else {
final IQuest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' ')); final IQuest questToFind = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
final IQuester quester = plugin.getQuester(player.getUniqueId()); final IQuester quester = plugin.getQuester(player.getUniqueId());
if (questToFind != null) { if (questToFind != null) {
for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) { for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) {
@ -1049,7 +1049,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
} }
questToGive = plugin.getQuest(name.toString()); questToGive = plugin.getQuestTemp(name.toString());
if (questToGive == null) { if (questToGive == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound")); cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
} else { } else {
@ -1160,7 +1160,7 @@ public class CmdExecutor implements CommandExecutor {
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final IQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1212,7 +1212,7 @@ public class CmdExecutor implements CommandExecutor {
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final IQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' ')); final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 2, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1248,7 +1248,7 @@ public class CmdExecutor implements CommandExecutor {
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final IQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1289,7 +1289,7 @@ public class CmdExecutor implements CommandExecutor {
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final IQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1325,6 +1325,7 @@ public class CmdExecutor implements CommandExecutor {
plugin.setOfflineQuesters(temp); plugin.setOfflineQuesters(temp);
IQuester quester = plugin.getQuester(id); IQuester quester = plugin.getQuester(id);
try { try {
quester.resetCompass();
quester.hardClear(); quester.hardClear();
quester.saveData(); quester.saveData();
quester.updateJournal(); quester.updateJournal();
@ -1370,7 +1371,7 @@ public class CmdExecutor implements CommandExecutor {
return; return;
} }
} }
final IQuest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final IQuest toRemove = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
if (toRemove == null) { if (toRemove == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;

View File

@ -202,7 +202,7 @@ public class NpcListener implements Listener {
continue; continue;
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) { if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
if (plugin.getSettings().canIgnoreLockedQuests() if (plugin.getSettings().canIgnoreLockedQuests()
&& (!quester.getCompletedQuests().contains(q) && (!quester.getCompletedQuestsTemp().contains(q)
|| q.getPlanner().getCooldown() > -1)) { || q.getPlanner().getCooldown() > -1)) {
if (q.testRequirements(quester)) { if (q.testRequirements(quester)) {
npcQuests.add(q); npcQuests.add(q);
@ -210,7 +210,7 @@ public class NpcListener implements Listener {
hasAtLeastOneGUI = true; hasAtLeastOneGUI = true;
} }
} }
} else if (!quester.getCompletedQuests().contains(q) || q.getPlanner().getCooldown() > -1) { } else if (!quester.getCompletedQuestsTemp().contains(q) || q.getPlanner().getCooldown() > -1) {
npcQuests.add(q); npcQuests.add(q);
if (q.getGUIDisplay() != null) { if (q.getGUIDisplay() != null) {
hasAtLeastOneGUI = true; hasAtLeastOneGUI = true;
@ -313,7 +313,7 @@ public class NpcListener implements Listener {
} }
private String extracted(final IQuester quester) { private String extracted(final IQuester quester) {
final IQuest quest = plugin.getQuestById(quester.getQuestIdToTake()); final IQuest quest = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription()); quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
} }

View File

@ -374,7 +374,7 @@ public class PlayerListener implements Listener {
.valueOf(plugin.getSettings().getMaxQuests())); .valueOf(plugin.getSettings().getMaxQuests()));
Lang.send(player, ChatColor.YELLOW + msg); Lang.send(player, ChatColor.YELLOW + msg);
} else { } else {
if (quester.getCompletedQuests().contains(q)) { if (quester.getCompletedQuestsTemp().contains(q)) {
if (q.getPlanner().getCooldown() > -1 if (q.getPlanner().getCooldown() > -1
&& (quester.getRemainingCooldown(q)) > 0) { && (quester.getRemainingCooldown(q)) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
@ -385,7 +385,7 @@ public class PlayerListener implements Listener {
+ ChatColor.YELLOW); + ChatColor.YELLOW);
Lang.send(player, ChatColor.YELLOW + early); Lang.send(player, ChatColor.YELLOW + early);
continue; continue;
} else if (quester.getCompletedQuests().contains(q) } else if (quester.getCompletedQuestsTemp().contains(q)
&& q.getPlanner().getCooldown() < 0) { && q.getPlanner().getCooldown() < 0) {
String completed = Lang.get(player, "questAlreadyCompleted"); String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replace("<quest>", ChatColor.AQUA completed = completed.replace("<quest>", ChatColor.AQUA
@ -398,7 +398,7 @@ public class PlayerListener implements Listener {
if (!plugin.getSettings().canAskConfirmation()) { if (!plugin.getSettings().canAskConfirmation()) {
quester.takeQuest(q, false); quester.takeQuest(q, false);
} else { } else {
final IQuest quest = plugin.getQuestById(quester.getQuestIdToTake()); final IQuest quest = plugin.getQuestByIdTemp(quester.getQuestIdToTake());
final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE
+ quest.getName() + ChatColor.GOLD + " -\n" + "\n" + quest.getName() + ChatColor.GOLD + " -\n" + "\n"
+ ChatColor.RESET + quest.getDescription() + "\n"; + ChatColor.RESET + quest.getDescription() + "\n";
@ -878,7 +878,7 @@ public class PlayerListener implements Listener {
if (quester == null) { if (quester == null) {
return; return;
} }
for (final IQuest q : quester.getCompletedQuests()) { for (final IQuest q : quester.getCompletedQuestsTemp()) {
if (q != null) { if (q != null) {
if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) { if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) {
quester.getCompletedTimes().put(q, System.currentTimeMillis()); quester.getCompletedTimes().put(q, System.currentTimeMillis());
@ -898,7 +898,7 @@ public class PlayerListener implements Listener {
quester.updateJournal(); quester.updateJournal();
} }
if (quester.canUseCompass()) { if (quester.canUseCompass()) {
quester.resetCompass(); quester.findCompassTarget();
} }
}, 40L); }, 40L);
} catch (final Exception e) { } catch (final Exception e) {

View File

@ -90,11 +90,11 @@ public class SeparatedYamlStorage implements StorageImplementation {
final List<Long> questTimes = data.getLongList("completedQuestTimes"); final List<Long> questTimes = data.getLongList("completedQuestTimes");
final ConcurrentHashMap<IQuest, Long> completedTimes = quester.getCompletedTimes(); final ConcurrentHashMap<IQuest, Long> completedTimes = quester.getCompletedTimes();
for (int i = 0; i < questIds.size(); i++) { for (int i = 0; i < questIds.size(); i++) {
if (plugin.getQuestById(questIds.get(i)) != null) { if (plugin.getQuestByIdTemp(questIds.get(i)) != null) {
completedTimes.put(plugin.getQuestById(questIds.get(i)), questTimes.get(i)); completedTimes.put(plugin.getQuestByIdTemp(questIds.get(i)), questTimes.get(i));
} else if (plugin.getQuest(questIds.get(i)) != null) { } else if (plugin.getQuestTemp(questIds.get(i)) != null) {
// Legacy // Legacy
completedTimes.put(plugin.getQuest(questIds.get(i)), questTimes.get(i)); completedTimes.put(plugin.getQuestTemp(questIds.get(i)), questTimes.get(i));
} }
} }
quester.setCompletedTimes(completedTimes); quester.setCompletedTimes(completedTimes);
@ -104,29 +104,29 @@ public class SeparatedYamlStorage implements StorageImplementation {
final List<Integer> questAmounts = data.getIntegerList("amountsCompleted"); final List<Integer> questAmounts = data.getIntegerList("amountsCompleted");
final ConcurrentHashMap<IQuest, Integer> amountsCompleted = quester.getAmountsCompleted(); final ConcurrentHashMap<IQuest, Integer> amountsCompleted = quester.getAmountsCompleted();
for (int i = 0; i < questIds.size(); i++) { for (int i = 0; i < questIds.size(); i++) {
if (plugin.getQuestById(questIds.get(i)) != null) { if (plugin.getQuestByIdTemp(questIds.get(i)) != null) {
amountsCompleted.put(plugin.getQuestById(questIds.get(i)), questAmounts.get(i)); amountsCompleted.put(plugin.getQuestByIdTemp(questIds.get(i)), questAmounts.get(i));
} else if (plugin.getQuest(questIds.get(i)) != null) { } else if (plugin.getQuestTemp(questIds.get(i)) != null) {
// Legacy // Legacy
amountsCompleted.put(plugin.getQuest(questIds.get(i)), questAmounts.get(i)); amountsCompleted.put(plugin.getQuestTemp(questIds.get(i)), questAmounts.get(i));
} }
} }
quester.setAmountsCompleted(amountsCompleted); quester.setAmountsCompleted(amountsCompleted);
} }
quester.setLastKnownName(data.getString("lastKnownName")); quester.setLastKnownName(data.getString("lastKnownName"));
quester.setQuestPoints(data.getInt("quest-points")); quester.setQuestPoints(data.getInt("quest-points"));
final ConcurrentSkipListSet<IQuest> completedQuests = quester.getCompletedQuests(); final ConcurrentSkipListSet<IQuest> completedQuests = quester.getCompletedQuestsTemp();
if (data.isList("completed-Quests")) { if (data.isList("completed-Quests")) {
for (final String s : data.getStringList("completed-Quests")) { for (final String s : data.getStringList("completed-Quests")) {
for (final IQuest q : plugin.getLoadedQuests()) { for (final IQuest q : plugin.getLoadedQuests()) {
if (q.getId().equals(s)) { if (q.getId().equals(s)) {
if (!quester.getCompletedQuests().contains(q)) { if (!quester.getCompletedQuestsTemp().contains(q)) {
completedQuests.add(q); completedQuests.add(q);
} }
break; break;
} else if (q.getName().equalsIgnoreCase(s)) { } else if (q.getName().equalsIgnoreCase(s)) {
// Legacy // Legacy
if (!quester.getCompletedQuests().contains(q)) { if (!quester.getCompletedQuestsTemp().contains(q)) {
completedQuests.add(q); completedQuests.add(q);
} }
break; break;
@ -141,11 +141,11 @@ public class SeparatedYamlStorage implements StorageImplementation {
final int maxSize = Math.min(questIds.size(), questStages.size()); final int maxSize = Math.min(questIds.size(), questStages.size());
final ConcurrentHashMap<IQuest, Integer> currentQuests = quester.getCurrentQuestsTemp(); final ConcurrentHashMap<IQuest, Integer> currentQuests = quester.getCurrentQuestsTemp();
for (int i = 0; i < maxSize; i++) { for (int i = 0; i < maxSize; i++) {
if (plugin.getQuestById(questIds.get(i)) != null) { if (plugin.getQuestByIdTemp(questIds.get(i)) != null) {
currentQuests.put(plugin.getQuestById(questIds.get(i)), questStages.get(i)); currentQuests.put(plugin.getQuestByIdTemp(questIds.get(i)), questStages.get(i));
} else if (plugin.getQuest(questIds.get(i)) != null) { } else if (plugin.getQuestTemp(questIds.get(i)) != null) {
// Legacy // Legacy
currentQuests.put(plugin.getQuest(questIds.get(i)), questStages.get(i)); currentQuests.put(plugin.getQuestTemp(questIds.get(i)), questStages.get(i));
} }
} }
quester.setCurrentQuests(currentQuests); quester.setCurrentQuests(currentQuests);
@ -155,7 +155,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
} }
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 IQuest quest = plugin.getQuestById(key) != null ? plugin.getQuestById(key) : plugin.getQuest(key); final IQuest quest = plugin.getQuestByIdTemp(key) != null ? plugin.getQuestByIdTemp(key) : plugin.getQuestTemp(key);
if (quest == null || !quester.getCurrentQuestsTemp().containsKey(quest)) { if (quest == null || !quester.getCurrentQuestsTemp().containsKey(quest)) {
continue; continue;
} }

View File

@ -255,7 +255,7 @@ public class SqlStorage implements StorageImplementation {
final Set<String> currentQuests = quester.getCurrentQuestsTemp().keySet().stream().map(IQuest::getId).collect(Collectors.toSet()); final Set<String> currentQuests = quester.getCurrentQuestsTemp().keySet().stream().map(IQuest::getId).collect(Collectors.toSet());
final Set<String> oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(IQuest::getId).collect(Collectors.toSet()); final Set<String> oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(IQuest::getId).collect(Collectors.toSet());
oldCurrentQuests.removeAll(currentQuests); oldCurrentQuests.removeAll(currentQuests);
final Set<String> completedQuests = quester.getCompletedQuests().stream().map(IQuest::getId).collect(Collectors.toSet()); final Set<String> completedQuests = quester.getCompletedQuestsTemp().stream().map(IQuest::getId).collect(Collectors.toSet());
final Set<String> oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(IQuest::getId).collect(Collectors.toSet()); final Set<String> oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(IQuest::getId).collect(Collectors.toSet());
oldCompletedQuests.removeAll(completedQuests); oldCompletedQuests.removeAll(completedQuests);
final Set<String> redoableQuests = quester.getCompletedTimes().keySet().stream().map(IQuest::getId).collect(Collectors.toSet()); final Set<String> redoableQuests = quester.getCompletedTimes().keySet().stream().map(IQuest::getId).collect(Collectors.toSet());
@ -309,7 +309,7 @@ public class SqlStorage implements StorageImplementation {
} }
} }
} else { } else {
for (final IQuest quest : quester.getCompletedQuests()) { for (final IQuest quest : quester.getCompletedQuestsTemp()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_INSERT))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_INSERT))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
ps.setString(2, quest.getId()); ps.setString(2, quest.getId());
@ -439,7 +439,7 @@ public class SqlStorage implements StorageImplementation {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final IQuest quest = plugin.getQuestById(rs.getString("questid")); final IQuest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
if (quest != null) { if (quest != null) {
currentQuests.put(quest, rs.getInt("stageNum")); currentQuests.put(quest, rs.getInt("stageNum"));
} }
@ -458,7 +458,7 @@ public class SqlStorage implements StorageImplementation {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final IQuest quest = plugin.getQuestById(rs.getString("quest_id")); final IQuest quest = plugin.getQuestByIdTemp(rs.getString("quest_id"));
final QuestData data = new QuestData(quester); final QuestData data = new QuestData(quester);
if (quest != null && quester.getCurrentStage(quest) != null) { if (quest != null && quester.getCurrentStage(quest) != null) {
data.blocksBroken.addAll(deserializeItemStackProgress(rs.getString("blocks_broken"), data.blocksBroken.addAll(deserializeItemStackProgress(rs.getString("blocks_broken"),
@ -512,7 +512,7 @@ public class SqlStorage implements StorageImplementation {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final IQuest quest = plugin.getQuestById(rs.getString("questid")); final IQuest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
if (quest != null) { if (quest != null) {
completedQuests.add(quest); completedQuests.add(quest);
} }
@ -530,7 +530,7 @@ public class SqlStorage implements StorageImplementation {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final IQuest quest = plugin.getQuestById(rs.getString("questid")); final IQuest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
if (quest != null) { if (quest != null) {
completedTimes.put(quest, rs.getLong("lasttime")); completedTimes.put(quest, rs.getLong("lasttime"));
} }
@ -548,7 +548,7 @@ public class SqlStorage implements StorageImplementation {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final IQuest quest = plugin.getQuestById(rs.getString("questid")); final IQuest quest = plugin.getQuestByIdTemp(rs.getString("questid"));
if (quest != null) { if (quest != null) {
amountsCompleted.put(quest, rs.getInt("amount")); amountsCompleted.put(quest, rs.getInt("amount"));
} }

View File

@ -737,6 +737,7 @@ journalNoRoom: "You have no room in your inventory for your <journal>!"
journalNoQuests: "You have no accepted quests!" journalNoQuests: "You have no accepted quests!"
journalDenied: "You cannot do that with your <journal>." journalDenied: "You cannot do that with your <journal>."
compassSet: "Set compass target to quest <quest>." compassSet: "Set compass target to quest <quest>."
compassNone: "No compass target for quest <quest>."
compassReset: "Reset compass target." compassReset: "Reset compass target."
timeZone: "Time zone" timeZone: "Time zone"
timeDay: "Day" timeDay: "Day"