mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 05:04:20 +00:00
Add PlayerNpcTalkEvent
This commit is contained in:
parent
dbc45f36f0
commit
1ca451559c
@ -1,13 +1,14 @@
|
|||||||
package emu.grasscutter.game.talk;
|
package emu.grasscutter.game.talk;
|
||||||
|
|
||||||
import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_COMPLETE_TALK;
|
|
||||||
import static emu.grasscutter.game.quest.enums.QuestContent.*;
|
|
||||||
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.binout.MainQuestData.TalkData;
|
import emu.grasscutter.data.binout.MainQuestData.TalkData;
|
||||||
import emu.grasscutter.game.player.*;
|
import emu.grasscutter.game.player.*;
|
||||||
|
import emu.grasscutter.server.event.player.PlayerNpcTalkEvent;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_COMPLETE_TALK;
|
||||||
|
import static emu.grasscutter.game.quest.enums.QuestContent.*;
|
||||||
|
|
||||||
public final class TalkManager extends BasePlayerManager {
|
public final class TalkManager extends BasePlayerManager {
|
||||||
public TalkManager(@NonNull Player player) {
|
public TalkManager(@NonNull Player player) {
|
||||||
super(player);
|
super(player);
|
||||||
@ -23,6 +24,11 @@ public final class TalkManager extends BasePlayerManager {
|
|||||||
var player = this.getPlayer();
|
var player = this.getPlayer();
|
||||||
|
|
||||||
var talkData = GameData.getTalkConfigDataMap().get(talkId);
|
var talkData = GameData.getTalkConfigDataMap().get(talkId);
|
||||||
|
|
||||||
|
// Invoke PlayerNpcTalkEvent.
|
||||||
|
var event = new PlayerNpcTalkEvent(player, talkData, talkId, npcEntityId);
|
||||||
|
if (!event.call()) return;
|
||||||
|
|
||||||
if (talkData != null) {
|
if (talkData != null) {
|
||||||
// Check if the NPC id is valid.
|
// Check if the NPC id is valid.
|
||||||
var entity = player.getScene().getEntityById(npcEntityId);
|
var entity = player.getScene().getEntityById(npcEntityId);
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package emu.grasscutter.server.event.player;
|
||||||
|
|
||||||
|
import emu.grasscutter.data.excels.TalkConfigData;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.server.event.Cancellable;
|
||||||
|
import emu.grasscutter.server.event.types.PlayerEvent;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public final class PlayerNpcTalkEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private final TalkConfigData talk;
|
||||||
|
private final int talkId, npcEntityId;
|
||||||
|
|
||||||
|
public PlayerNpcTalkEvent(Player player,
|
||||||
|
@Nullable TalkConfigData talk,
|
||||||
|
int talkId,
|
||||||
|
int npcEntityId) {
|
||||||
|
super(player);
|
||||||
|
|
||||||
|
this.talk = talk;
|
||||||
|
this.talkId = talkId;
|
||||||
|
this.npcEntityId = npcEntityId;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user