mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 00:12:29 +00:00
Add PlayerCompleteQuestEvent
This commit is contained in:
parent
bdd3cbbcd9
commit
9b84deaab3
@ -12,13 +12,15 @@ import emu.grasscutter.game.quest.enums.*;
|
|||||||
import emu.grasscutter.net.proto.ChapterStateOuterClass;
|
import emu.grasscutter.net.proto.ChapterStateOuterClass;
|
||||||
import emu.grasscutter.net.proto.QuestOuterClass.Quest;
|
import emu.grasscutter.net.proto.QuestOuterClass.Quest;
|
||||||
import emu.grasscutter.scripts.data.SceneGroup;
|
import emu.grasscutter.scripts.data.SceneGroup;
|
||||||
|
import emu.grasscutter.server.event.player.PlayerCompleteQuestEvent;
|
||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
|
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
|
||||||
import java.util.*;
|
|
||||||
import javax.script.Bindings;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.script.Bindings;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class GameQuest {
|
public class GameQuest {
|
||||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||||
@ -195,6 +197,10 @@ public class GameQuest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
|
// Call PlayerCompleteQuestEvent.
|
||||||
|
var event = new PlayerCompleteQuestEvent(this.getOwner(), this);
|
||||||
|
if (!event.call()) return;
|
||||||
|
|
||||||
// Check if the quest has been finished.
|
// Check if the quest has been finished.
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (this.state == QuestState.QUEST_STATE_FINISHED) {
|
if (this.state == QuestState.QUEST_STATE_FINISHED) {
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package emu.grasscutter.server.event.player;
|
||||||
|
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.quest.GameQuest;
|
||||||
|
import emu.grasscutter.server.event.Cancellable;
|
||||||
|
import emu.grasscutter.server.event.types.PlayerEvent;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public final class PlayerCompleteQuestEvent extends PlayerEvent implements Cancellable {
|
||||||
|
@Getter private final GameQuest quest;
|
||||||
|
|
||||||
|
public PlayerCompleteQuestEvent(Player player, GameQuest quest) {
|
||||||
|
super(player);
|
||||||
|
|
||||||
|
this.quest = quest;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user