11package net .swofty .type .skyblockgeneric .gui .inventories .abiphone ;
22
3+ import lombok .Setter ;
34import net .kyori .adventure .text .Component ;
45import net .minestom .server .MinecraftServer ;
56import net .minestom .server .component .DataComponents ;
910import net .minestom .server .item .ItemStack ;
1011import net .minestom .server .item .Material ;
1112import net .minestom .server .timer .TaskSchedule ;
12- import net .swofty .type .generic .gui .inventory .HypixelInventoryGUI ;
13+ import net .swofty .type .generic .gui .inventory .HypixelPaginatedGUI ;
1314import net .swofty .type .generic .gui .inventory .ItemStackCreator ;
1415import net .swofty .type .generic .gui .inventory .item .GUIClickableItem ;
1516import net .swofty .type .generic .gui .inventory .item .GUIItem ;
1617import net .swofty .type .generic .user .HypixelPlayer ;
18+ import net .swofty .type .generic .utility .PaginationList ;
1719import net .swofty .type .skyblockgeneric .abiphone .AbiphoneNPC ;
1820import net .swofty .type .skyblockgeneric .abiphone .AbiphoneRegistry ;
1921import net .swofty .type .skyblockgeneric .item .SkyBlockItem ;
2022
2123import java .util .List ;
2224
23- public class GUIAbiphone extends HypixelInventoryGUI {
24-
25+ public class GUIAbiphone extends HypixelPaginatedGUI <AbiphoneNPC > {
26+ @ Setter
27+ private SortType sortType = SortType .ALPHABETICAL ;
2528 private final SkyBlockItem abiphone ;
2629
2730 public GUIAbiphone (SkyBlockItem abiphone ) {
28- super (abiphone . getCleanName (), InventoryType .CHEST_6_ROW );
31+ super (InventoryType .CHEST_6_ROW );
2932 this .abiphone = abiphone ;
3033 }
3134
3235 @ Override
33- public void onOpen (InventoryGUIOpenEvent e ) {
34- border (FILLER_ITEM );
35- List <AbiphoneNPC > contacts = abiphone .getAttributeHandler ().getAbiphoneNPCs ();
36+ protected int [] getPaginatedSlots () {
37+ return new int []{
38+ 10 , 11 , 12 , 13 , 14 , 15 , 16 ,
39+ 19 , 20 , 21 , 22 , 23 , 24 , 25 ,
40+ 28 , 29 , 30 , 31 , 32 , 33 , 34 ,
41+ 37 , 38 , 39 , 40 , 41 , 42 , 43
42+ };
43+ }
3644
37- int [] slots = new int []{10 , 11 , 12 , 13 , 14 , 15 , 16 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 28 , 29 , 30 , 31 , 32 , 33 , 34 };
38- for (int i = 0 ; i < contacts .size () && i < slots .length ; i ++) {
39- AbiphoneNPC npc = contacts .get (i );
40- set (new GUIClickableItem (slots [i ]) {
41- @ Override
42- public void run (InventoryPreClickEvent e , HypixelPlayer player ) {
43- Click click = e .getClick ();
44- if (click instanceof Click .Left ) {
45- player .closeInventory ();
46- player .sendMessage (Component .text ("§e✆ RING..." ));
47- MinecraftServer .getSchedulerManager ().buildTask (() -> {
48- player .sendMessage (Component .text ("§e✆ RING... RING..." ));
49- MinecraftServer .getSchedulerManager ().buildTask (() -> {
50- player .sendMessage (Component .text ("§e✆ RING... RING... RING..." ));
51- MinecraftServer .getSchedulerManager ().buildTask (() -> {
52- npc .onCall (player );
53- }).delay (TaskSchedule .seconds (1 )).schedule ();
54- }).delay (TaskSchedule .seconds (1 )).schedule ();
55- }).delay (TaskSchedule .seconds (1 )).schedule ();
56- } else if (click instanceof Click .Right ) {
57- new GUIContactManagement (abiphone , npc ).open (player );
58- }
59- }
45+ @ Override
46+ protected PaginationList <AbiphoneNPC > fillPaged (HypixelPlayer player , PaginationList <AbiphoneNPC > paged ) {
47+ paged .addAll (abiphone .getAttributeHandler ().getAbiphoneNPCs ());
48+ return paged ;
49+ }
6050
61- @ Override
62- public ItemStack .Builder getItem (HypixelPlayer player ) {
63- return ItemStackCreator .updateLore (
64- npc .getIcon ().set (DataComponents .CUSTOM_NAME , Component .text ("§f" + npc .getName ())),
65- List .of (
66- "§7" + npc .getDescription (),
67- "" ,
68- "§8Right-click to manage!" ,
69- "§eLeft-click to call!"
70- )
71- );
72- }
51+ @ Override
52+ protected boolean shouldFilterFromSearch (String query , AbiphoneNPC item ) {
53+ return false ;
54+ }
7355
74- });
75- }
56+ @ Override
57+ protected void performSearch (HypixelPlayer player , String query , int page , int maxPage ) {
58+ border (FILLER_ITEM );
59+ List <AbiphoneNPC > contacts = abiphone .getAttributeHandler ().getAbiphoneNPCs ();
7660
7761 set (GUIClickableItem .getCloseItem (49 ));
7862 set (new GUIItem (50 ) {
@@ -111,7 +95,57 @@ public ItemStack.Builder getItem(HypixelPlayer player) {
11195 );
11296 }
11397 });
114- updateItemStacks (getInventory (), getPlayer ());
98+
99+ if (page > 1 ) {
100+ set (createNavigationButton (this , 45 , query , page , false ));
101+ }
102+ if (page < maxPage ) {
103+ set (createNavigationButton (this , 53 , query , page , true ));
104+ }
105+ }
106+
107+ @ Override
108+ protected String getTitle (HypixelPlayer player , String query , int page , PaginationList <AbiphoneNPC > paged ) {
109+ return abiphone .getCleanName ();
110+ }
111+
112+ @ Override
113+ protected GUIClickableItem createItemFor (AbiphoneNPC npc , int slot , HypixelPlayer player ) {
114+ return new GUIClickableItem (slot ) {
115+ @ Override
116+ public void run (InventoryPreClickEvent e , HypixelPlayer player ) {
117+ Click click = e .getClick ();
118+ if (click instanceof Click .Left ) {
119+ player .closeInventory ();
120+ player .sendMessage (Component .text ("§e✆ RING..." ));
121+ MinecraftServer .getSchedulerManager ().buildTask (() -> {
122+ player .sendMessage (Component .text ("§e✆ RING... RING..." ));
123+ MinecraftServer .getSchedulerManager ().buildTask (() -> {
124+ player .sendMessage (Component .text ("§e✆ RING... RING... RING..." ));
125+ MinecraftServer .getSchedulerManager ().buildTask (() -> {
126+ npc .onCall (player );
127+ }).delay (TaskSchedule .seconds (1 )).schedule ();
128+ }).delay (TaskSchedule .seconds (1 )).schedule ();
129+ }).delay (TaskSchedule .seconds (1 )).schedule ();
130+ } else if (click instanceof Click .Right ) {
131+ new GUIContactManagement (abiphone , npc ).open (player );
132+ }
133+ }
134+
135+ @ Override
136+ public ItemStack .Builder getItem (HypixelPlayer player ) {
137+ return ItemStackCreator .updateLore (
138+ npc .getIcon ().set (DataComponents .CUSTOM_NAME , Component .text ("§f" + npc .getName ())),
139+ List .of (
140+ "§7" + npc .getDescription (),
141+ "" ,
142+ "§8Right-click to manage!" ,
143+ "§eLeft-click to call!"
144+ )
145+ );
146+ }
147+
148+ };
115149 }
116150
117151 @ Override
@@ -123,5 +157,13 @@ public boolean allowHotkeying() {
123157 public void onBottomClick (InventoryPreClickEvent e ) {
124158 e .setCancelled (true );
125159 }
160+
161+ public enum SortType {
162+ FIRST_ADDED ,
163+ ALPHABETICAL ,
164+ LAST_CALLED ,
165+ MOST_CALLED ,
166+ DO_NOT_DISTURB_FIRST
167+ }
126168}
127169
0 commit comments