Implemented event interfaces, made more events cancellable.

This commit is contained in:
Luis C.M committed 2022-11-24 14:36:09 -06:00
1 parent aa02e5dcc3
commit 0414817673
32 files changed
+1298 -175

No files matched your search

@@ -2,11 +2,12 @@ package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.api.event.ICustomGuiEvent;
import noppes.npcs.api.gui.ICustomGui;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.entity.IPlayer;
public class CustomGuiEvent extends Event {
public class CustomGuiEvent extends Event implements ICustomGuiEvent {
public final IPlayer player;
public final ICustomGui gui;
@@ -23,31 +24,43 @@ public class CustomGuiEvent extends Event {
return gui;
}
public static class ButtonEvent extends CustomGuiEvent {
public int getId() {
return -1;
}
public static class ButtonEvent extends CustomGuiEvent implements ICustomGuiEvent.ButtonEvent {
public final int buttonId;
public ButtonEvent(IPlayer player, ICustomGui gui, int buttonId) {
super(player, gui);
this.buttonId = buttonId;
}
public int getId() {
return this.buttonId;
}
}
public static class UnfocusedEvent extends CustomGuiEvent {
public static class UnfocusedEvent extends CustomGuiEvent implements ICustomGuiEvent.UnfocusedEvent {
public final int textfieldId;
public UnfocusedEvent(IPlayer player, ICustomGui gui, int textfieldId) {
super(player, gui);
this.textfieldId = textfieldId;
}
public int getId() {
return this.textfieldId;
}
}
public static class CloseEvent extends CustomGuiEvent {
public static class CloseEvent extends CustomGuiEvent implements ICustomGuiEvent.CloseEvent {
public CloseEvent(IPlayer player, ICustomGui gui) {
super(player, gui);
}
}
public static class ScrollEvent extends CustomGuiEvent {
public static class ScrollEvent extends CustomGuiEvent implements ICustomGuiEvent.ScrollEvent {
public final int scrollId;
public final String[] selection;
public final boolean doubleClick;
@@ -60,9 +73,25 @@ public class CustomGuiEvent extends Event {
this.doubleClick = doubleClick;
this.scrollIndex = scrollIndex;
}
public int getId() {
return this.scrollId;
}
public String[] getSelection() {
return selection;
}
public boolean doubleClick() {
return doubleClick;
}
public int getScrollIndex() {
return scrollIndex;
}
}
public static class SlotEvent extends CustomGuiEvent {
public static class SlotEvent extends CustomGuiEvent implements ICustomGuiEvent.SlotEvent {
public final int slotId;
public final IItemStack stack;
@@ -71,10 +100,18 @@ public class CustomGuiEvent extends Event {
this.slotId = slotId;
this.stack = stack;
}
public int getId() {
return this.slotId;
}
public IItemStack getStack() {
return stack;
}
}
@Cancelable
public static class SlotClickEvent extends CustomGuiEvent {
public static class SlotClickEvent extends CustomGuiEvent implements ICustomGuiEvent.SlotClickEvent {
public final int slotId;
public final IItemStack stack;
public final int dragType;
@@ -90,5 +127,17 @@ public class CustomGuiEvent extends Event {
this.dragType = dragType;
this.clickType = clickType;
}
public int getId() {
return this.slotId;
}
public IItemStack getStack() {
return stack;
}
public int getDragType() {
return dragType;
}
}
}