mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 01:57:34 +00:00
Changed Player Dialog Events to work like NPC Dialog Events
This commit is contained in:
1 parent
9ebaf780e1
commit
92e69bb270
3 files changed
+23
-12
No files matched your search
@@ -306,18 +306,18 @@ public class NoppesUtilPlayer {
|
||||
if (dialog == null)
|
||||
return;
|
||||
DialogOption option = dialog.options.get(optionId);
|
||||
if (EventHooks.onDialogOption(player, new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)))
|
||||
if (EventHooks.onDialogOption(player, new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialogId, optionId, dialog)))
|
||||
return;
|
||||
|
||||
if (!npc.isRemote()) {
|
||||
EventHooks.onNPCDialogClosed(npc, player, dialogId, optionId + 1, dialog);
|
||||
|
||||
if (!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
||||
EventHooks.onDialogClosed(player, new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
|
||||
EventHooks.onDialogClosed(player, new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialogId, optionId, dialog));
|
||||
return;
|
||||
}
|
||||
if (option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) {
|
||||
EventHooks.onDialogClosed(player, new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
|
||||
EventHooks.onDialogClosed(player, new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialogId, optionId, dialog));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class NoppesUtilServer {
|
||||
if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) {
|
||||
return;
|
||||
}
|
||||
if (EventHooks.onDialogOpen(player, new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) {
|
||||
if (EventHooks.onDialogOpen(player, new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog.id, optionId, dialog))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,24 +8,36 @@ import noppes.npcs.constants.EnumScriptType;
|
||||
|
||||
public class DialogEvent extends PlayerEvent implements IDialogEvent {
|
||||
public final IDialog dialog;
|
||||
public final int dialogId;
|
||||
public final int optionId;
|
||||
|
||||
public DialogEvent(IPlayer player, IDialog dialog) {
|
||||
public DialogEvent(IPlayer player, int id, int optionId, IDialog dialog) {
|
||||
super(player);
|
||||
this.dialog = dialog;
|
||||
this.dialogId = id;
|
||||
this.optionId = optionId;
|
||||
}
|
||||
|
||||
public IDialog getDialog() {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public int getDialogId() {
|
||||
return dialogId;
|
||||
}
|
||||
|
||||
public int getOptionId() {
|
||||
return optionId;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.DIALOG_EVENT.function;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DialogOpen extends DialogEvent implements IDialogEvent.DialogOpen {
|
||||
public DialogOpen(IPlayer player, IDialog dialog) {
|
||||
super(player, dialog);
|
||||
public DialogOpen(IPlayer player, int id, int optionId, IDialog dialog) {
|
||||
super(player, id, optionId, dialog);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
@@ -35,8 +47,8 @@ public class DialogEvent extends PlayerEvent implements IDialogEvent {
|
||||
|
||||
@Cancelable
|
||||
public static class DialogOption extends DialogEvent implements IDialogEvent.DialogOption {
|
||||
public DialogOption(IPlayer player, IDialog dialog) {
|
||||
super(player, dialog);
|
||||
public DialogOption(IPlayer player, int id, int optionId, IDialog dialog) {
|
||||
super(player, id, optionId, dialog);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
@@ -46,13 +58,12 @@ public class DialogEvent extends PlayerEvent implements IDialogEvent {
|
||||
}
|
||||
|
||||
public static class DialogClosed extends DialogEvent implements IDialogEvent.DialogClosed {
|
||||
public DialogClosed(IPlayer player, IDialog dialog) {
|
||||
super(player, dialog);
|
||||
public DialogClosed(IPlayer player, int id, int optionId, IDialog dialog) {
|
||||
super(player, id, optionId, dialog);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.DIALOG_CLOSE.function;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user