mirror of
https://github.com/PikaMug/Quests.git
synced 2024-09-09 14:08:02 +02:00
Call password objective event on sync to prevent exception
This commit is contained in:
parent
0c4b103db6
commit
b313adff9e
@ -2615,45 +2615,47 @@ public class Quester implements Comparable<Quester> {
|
|||||||
*/
|
*/
|
||||||
public void sayPassword(final Quest quest, final AsyncPlayerChatEvent evt) {
|
public void sayPassword(final Quest quest, final AsyncPlayerChatEvent evt) {
|
||||||
final ObjectiveType type = ObjectiveType.PASSWORD;
|
final ObjectiveType type = ObjectiveType.PASSWORD;
|
||||||
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||||
new Objective(type, 1, 1));
|
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
new Objective(type, 1, 1));
|
||||||
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
boolean done = false;
|
|
||||||
for (final LinkedList<String> passes : getCurrentStage(quest).passwordPhrases) {
|
boolean done = false;
|
||||||
done = false;
|
for (final LinkedList<String> passes : getCurrentStage(quest).passwordPhrases) {
|
||||||
for (final String pass : passes) {
|
done = false;
|
||||||
if (pass.equalsIgnoreCase(evt.getMessage())) {
|
for (final String pass : passes) {
|
||||||
evt.setCancelled(true);
|
if (pass.equalsIgnoreCase(evt.getMessage())) {
|
||||||
final String display = getCurrentStage(quest).passwordDisplays.get(getCurrentStage(quest)
|
evt.setCancelled(true);
|
||||||
.passwordPhrases.indexOf(passes));
|
final String display = getCurrentStage(quest).passwordDisplays.get(getCurrentStage(quest)
|
||||||
getQuestData(quest).passwordsSaid.put(display, true);
|
.passwordPhrases.indexOf(passes));
|
||||||
done = true;
|
getQuestData(quest).passwordsSaid.put(display, true);
|
||||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
done = true;
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, null, null, display, null);
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
|
|
||||||
// Multiplayer
|
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
|
||||||
q.getQuestData(quest).passwordsSaid.put(display, true);
|
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, null, null, display, null);
|
new ItemStack(Material.AIR, 1)), null, null, null, null, null, null, display, null);
|
||||||
return null;
|
|
||||||
|
// Multiplayer
|
||||||
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
|
q.getQuestData(quest).passwordsSaid.put(display, true);
|
||||||
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
|
new ItemStack(Material.AIR, 1)), null, null, null, null, null, null, display, null);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (done) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
break;
|
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
||||||
|
new Objective(type, 1, 1));
|
||||||
|
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (done) {
|
|
||||||
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
|
||||||
new Objective(type, 1, 1));
|
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user