Add PlayerCompleteQuestEvent

This commit is contained in:
KingRainbow44 2023-08-27 23:22:18 -04:00
parent bdd3cbbcd9
commit 9b84deaab3
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 25 additions and 2 deletions

View File

@ -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) {

View File

@ -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;
}
}