Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java
T

178 lines
5.0 KiB
Java
Raw Normal View History

2022-01-12 04:44:08 -06:00
package noppes.npcs.scripted.event;
2022-06-18 12:52:23 -05:00
import cpw.mods.fml.common.eventhandler.Cancelable;
2023-03-18 15:52:50 -05:00
import net.minecraft.item.ItemStack;
2023-01-12 21:33:06 -05:00
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.event.ICustomGuiEvent;
2022-11-15 15:25:53 -05:00
import noppes.npcs.api.gui.ICustomGui;
2023-03-18 03:04:46 -05:00
import noppes.npcs.api.gui.IItemSlot;
2022-11-15 15:25:53 -05:00
import noppes.npcs.api.item.IItemStack;
2022-11-24 16:46:20 -06:00
import noppes.npcs.constants.EnumScriptType;
2023-03-18 15:52:50 -05:00
import noppes.npcs.scripted.NpcAPI;
2022-01-12 04:44:08 -06:00
2022-11-24 16:46:20 -06:00
public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent {
2022-01-12 04:44:08 -06:00
public final IPlayer player;
public final ICustomGui gui;
public CustomGuiEvent(IPlayer player, ICustomGui gui) {
this.player = player;
this.gui = gui;
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_EVENT.function;
}
public IPlayer getPlayer() {
return this.player;
}
public ICustomGui getGui() {
return gui;
}
public int getId() {
return -1;
}
public static class ButtonEvent extends CustomGuiEvent implements ICustomGuiEvent.ButtonEvent {
2022-01-12 04:44:08 -06:00
public final int buttonId;
public ButtonEvent(IPlayer player, ICustomGui gui, int buttonId) {
super(player, gui);
this.buttonId = buttonId;
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_BUTTON.function;
}
public int getId() {
return this.buttonId;
}
2022-01-12 04:44:08 -06:00
}
public static class UnfocusedEvent extends CustomGuiEvent implements ICustomGuiEvent.UnfocusedEvent {
2022-01-14 16:09:27 -06:00
public final int textfieldId;
public UnfocusedEvent(IPlayer player, ICustomGui gui, int textfieldId) {
super(player, gui);
this.textfieldId = textfieldId;
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_TEXTFIELD.function;
}
public int getId() {
return this.textfieldId;
}
2022-01-14 16:09:27 -06:00
}
public static class CloseEvent extends CustomGuiEvent implements ICustomGuiEvent.CloseEvent {
2022-01-12 04:44:08 -06:00
public CloseEvent(IPlayer player, ICustomGui gui) {
super(player, gui);
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_CLOSED.function;
}
2022-01-12 04:44:08 -06:00
}
public static class ScrollEvent extends CustomGuiEvent implements ICustomGuiEvent.ScrollEvent {
2022-01-12 04:44:08 -06:00
public final int scrollId;
public final String[] selection;
public final boolean doubleClick;
public final int scrollIndex;
public ScrollEvent(IPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
super(player, gui);
this.scrollId = scrollId;
this.selection = selection;
this.doubleClick = doubleClick;
this.scrollIndex = scrollIndex;
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_SCROLL.function;
}
public int getId() {
return this.scrollId;
}
public String[] getSelection() {
return selection;
}
public boolean doubleClick() {
return doubleClick;
}
public int getScrollIndex() {
return scrollIndex;
}
2022-01-12 04:44:08 -06:00
}
public static class SlotEvent extends CustomGuiEvent implements ICustomGuiEvent.SlotEvent {
2022-01-12 04:44:08 -06:00
public final int slotId;
public final IItemStack stack;
2023-03-18 03:04:46 -05:00
public final IItemSlot slot;
2022-01-12 04:44:08 -06:00
2023-03-18 15:52:50 -05:00
public SlotEvent(IPlayer player, ICustomGui gui, int slotId, ItemStack stack, IItemSlot slot) {
2022-01-12 04:44:08 -06:00
super(player, gui);
this.slotId = slotId;
2023-03-18 15:52:50 -05:00
this.stack = NpcAPI.Instance().getIItemStack(stack);
this.slot = slot;
2022-01-12 04:44:08 -06:00
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_SLOT.function;
}
public int getId() {
return this.slotId;
}
public IItemStack getStack() {
return stack;
}
2022-01-12 04:44:08 -06:00
}
2022-06-18 12:52:23 -05:00
@Cancelable
public static class SlotClickEvent extends CustomGuiEvent implements ICustomGuiEvent.SlotClickEvent {
2022-06-18 12:52:23 -05:00
public final int slotId;
public final IItemStack stack;
public final int dragType;
2023-03-18 03:04:46 -05:00
public final IItemSlot slot;
2022-06-18 12:52:23 -05:00
/**
*
*/
public final int clickType;
2023-03-18 15:52:50 -05:00
public SlotClickEvent(IPlayer player, ICustomGui gui, int slotId, IItemSlot slot, IItemStack stack, int dragType, int clickType) {
2022-06-18 12:52:23 -05:00
super(player,gui);
this.slotId = slotId;
this.stack = stack;
this.dragType = dragType;
this.clickType = clickType;
2023-03-18 15:52:50 -05:00
this.slot = slot;
2022-06-18 12:52:23 -05:00
}
2022-11-24 16:46:20 -06:00
public String getHookName() {
return EnumScriptType.CUSTOM_GUI_SLOT_CLICKED.function;
}
public int getId() {
return this.slotId;
}
public IItemStack getStack() {
return stack;
}
public int getDragType() {
return dragType;
}
2022-06-18 12:52:23 -05:00
}
2022-01-12 04:44:08 -06:00
}