@@ -29,6 +29,8 @@ public final class HanGuiBuilder implements Listener {
29
29
private int id ;
30
30
private Inventory inventory ;
31
31
32
+ private CloseAttraction closeAttraction ;
33
+
32
34
private HashMap <Integer , GuiItem > itemHashMap ;
33
35
34
36
private Random random ;
@@ -47,6 +49,11 @@ public final class HanGuiBuilder implements Listener {
47
49
48
50
private List <GuiData > dataList ;
49
51
52
+
53
+ public final void setCloseAttraction (CloseAttraction attraction ) {
54
+ this .closeAttraction = attraction ;
55
+ }
56
+
50
57
public HanGuiBuilder (@ NotNull HanGuiBuilder .Size size , @ NotNull String guiTitle , @ NotNull JavaPlugin pl ) {
51
58
52
59
random = new Random ();
@@ -57,6 +64,7 @@ public HanGuiBuilder(@NotNull HanGuiBuilder.Size size, @NotNull String guiTitle,
57
64
58
65
this .plugin = pl ;
59
66
67
+
60
68
dataList = new ArrayList <>();
61
69
62
70
}
@@ -225,7 +233,7 @@ public enum Size {
225
233
}
226
234
227
235
@ EventHandler
228
- public void onClick (@ NotNull InventoryClickEvent event ) {
236
+ public void onClickEvent (@ NotNull InventoryClickEvent event ) {
229
237
if (event .getInventory ().getMaxStackSize () == id ) {
230
238
231
239
if (!this .accessibleOnDragItems ) {
@@ -242,14 +250,18 @@ public void onClick(@NotNull InventoryClickEvent event) {
242
250
}
243
251
244
252
@ EventHandler
245
- public void onClose (@ NotNull InventoryCloseEvent event ) {
253
+ public void onCloseEvent (@ NotNull InventoryCloseEvent event ) {
246
254
247
255
if (event .getInventory ().getMaxStackSize () == id ) {
248
256
players .remove (event .getPlayer ());
249
257
250
258
if (players .size ()<1 ) {
251
259
HandlerList .unregisterAll (this );
252
260
}
261
+
262
+ if (closeAttraction !=null ) {
263
+ closeAttraction .run (((Player ) event .getPlayer ()), this );
264
+ }
253
265
}
254
266
255
267
}
0 commit comments