forked from Upstream/mmocore
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7efe989612
@ -150,7 +150,7 @@ public class PlayerQuests {
|
|||||||
|
|
||||||
// close current objective progress if quest is active
|
// close current objective progress if quest is active
|
||||||
if (hasCurrent())
|
if (hasCurrent())
|
||||||
current.closeObjectiveProgress();
|
current.getProgress().close();
|
||||||
|
|
||||||
// apply newer quest
|
// apply newer quest
|
||||||
current = quest == null ? null : quest.generateNewProgress(playerData);
|
current = quest == null ? null : quest.generateNewProgress(playerData);
|
||||||
|
@ -43,16 +43,12 @@ public class QuestProgress {
|
|||||||
return quest.getObjectives().get(objective);
|
return quest.getObjectives().get(objective);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeObjectiveProgress() {
|
|
||||||
objectiveProgress.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void completeObjective() {
|
public void completeObjective() {
|
||||||
objective++;
|
objective++;
|
||||||
closeObjectiveProgress();
|
objectiveProgress.close();
|
||||||
|
|
||||||
// apply triggers
|
// apply triggers
|
||||||
objectiveProgress.getObjective().getTriggers().forEach(trigger -> trigger.apply(getPlayer()));
|
objectiveProgress.getObjective().getTriggers().forEach(trigger -> trigger.schedule(getPlayer()));
|
||||||
|
|
||||||
// end quest
|
// end quest
|
||||||
if (objective >= quest.getObjectives().size())
|
if (objective >= quest.getObjectives().size())
|
||||||
|
@ -10,7 +10,7 @@ public abstract class Trigger {
|
|||||||
private final long delay;
|
private final long delay;
|
||||||
|
|
||||||
public Trigger(MMOLineConfig config) {
|
public Trigger(MMOLineConfig config) {
|
||||||
delay = config.contains("delay") ? (long) (config.getDouble("delay") * 20) : 0;
|
delay = config.contains("delay") ? (long) (config.getDouble("delay") * 20.) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDelay() {
|
public boolean hasDelay() {
|
||||||
@ -22,8 +22,16 @@ public abstract class Trigger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void schedule(PlayerData player) {
|
public void schedule(PlayerData player) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> apply(player), delay);
|
if (delay <= 0)
|
||||||
|
apply(player);
|
||||||
|
else
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> apply(player), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this method must not be used directly when executing triggers after quest
|
||||||
|
* objectives for example, because this method does NOT take into account
|
||||||
|
* trigger delay
|
||||||
|
*/
|
||||||
public abstract void apply(PlayerData player);
|
public abstract void apply(PlayerData player);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user