Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit af2b86c

Browse files
ByDanam için yeniledim
iyi kullanmalar kadim dostum
1 parent f59e6f7 commit af2b86c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package tech.bingulhan.hanguiapi.gui;
2+
3+
import org.bukkit.entity.Player;
4+
5+
public interface CloseAttraction {
6+
7+
8+
public void run(Player player, HanGuiBuilder guiBuilder);
9+
}

src/main/java/tech/bingulhan/hanguiapi/gui/HanGuiBuilder.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public final class HanGuiBuilder implements Listener {
2929
private int id;
3030
private Inventory inventory;
3131

32+
private CloseAttraction closeAttraction;
33+
3234
private HashMap<Integer, GuiItem> itemHashMap;
3335

3436
private Random random;
@@ -47,6 +49,11 @@ public final class HanGuiBuilder implements Listener {
4749

4850
private List<GuiData> dataList;
4951

52+
53+
public final void setCloseAttraction(CloseAttraction attraction) {
54+
this.closeAttraction = attraction;
55+
}
56+
5057
public HanGuiBuilder(@NotNull HanGuiBuilder.Size size, @NotNull String guiTitle, @NotNull JavaPlugin pl) {
5158

5259
random = new Random();
@@ -57,6 +64,7 @@ public HanGuiBuilder(@NotNull HanGuiBuilder.Size size, @NotNull String guiTitle,
5764

5865
this.plugin = pl;
5966

67+
6068
dataList = new ArrayList<>();
6169

6270
}
@@ -225,7 +233,7 @@ public enum Size {
225233
}
226234

227235
@EventHandler
228-
public void onClick(@NotNull InventoryClickEvent event) {
236+
public void onClickEvent(@NotNull InventoryClickEvent event) {
229237
if (event.getInventory().getMaxStackSize() == id) {
230238

231239
if (!this.accessibleOnDragItems) {
@@ -242,14 +250,18 @@ public void onClick(@NotNull InventoryClickEvent event) {
242250
}
243251

244252
@EventHandler
245-
public void onClose(@NotNull InventoryCloseEvent event) {
253+
public void onCloseEvent(@NotNull InventoryCloseEvent event) {
246254

247255
if (event.getInventory().getMaxStackSize() == id) {
248256
players.remove(event.getPlayer());
249257

250258
if (players.size()<1) {
251259
HandlerList.unregisterAll(this);
252260
}
261+
262+
if (closeAttraction!=null) {
263+
closeAttraction.run(((Player) event.getPlayer()), this);
264+
}
253265
}
254266

255267
}

0 commit comments

Comments
 (0)