@@ -33,7 +33,6 @@ public abstract class GUI extends SpigotModule {
33
33
private final HashMap <String , String > placeholders ;
34
34
private final Player player ;
35
35
private HashMap <Integer , GUIButton > buttons ;
36
- private List <GUIButton > extraButtons ;
37
36
38
37
/**
39
38
* Creates a new GUI
@@ -45,7 +44,6 @@ public GUI(SpigotPlugin plugin, Player player){
45
44
this .player = player ;
46
45
this .placeholders = new HashMap <>();
47
46
this .buttons = new HashMap <>();
48
- this .extraButtons = new ArrayList <>();
49
47
}
50
48
51
49
/**
@@ -104,36 +102,6 @@ public void clear(){
104
102
this .inventory .clear ();
105
103
}
106
104
107
- /**
108
- * Adds a new GUIButton to the GUI
109
- * @param guiButton the button
110
- */
111
- public void addButton (GUIButton guiButton ){
112
- if (guiButton .getSlot () == -1 ){
113
- if (this .inventory != null ){
114
- this .extraButtons .add (guiButton .setSlot (this .inventory .firstEmpty ()));
115
- }else {
116
- for (int i = 0 ; i < this .getRows ().getSize (); ++i ){
117
- if (!this .buttons .containsKey (i )){
118
- this .extraButtons .add (guiButton .setSlot (i ));
119
- return ;
120
- }
121
- }
122
- }
123
- }else {
124
- this .extraButtons .add (guiButton );
125
- }
126
- }
127
-
128
- /**
129
- * Removes a button from the GUI
130
- * @param slot the slot
131
- */
132
- public void remButton (int slot ){
133
- this .buttons .remove (slot );
134
- this .extraButtons .removeIf (b -> b .getSlot () == slot );
135
- }
136
-
137
105
/**
138
106
* Used to know if the GUI title should be centered
139
107
* @return if the GUI title should be centered
@@ -319,7 +287,9 @@ private void loadGUIItemsAndSyncItems(){
319
287
List <GUIButton > buttons = new ArrayList <>();
320
288
GUIButton [] array = this .getButtons ();
321
289
if (array != null ) buttons .addAll (Utils .toList (array ));
322
- buttons .addAll (this .extraButtons );
290
+ array = this .getExtraButtons ();
291
+ if (array != null ) buttons .addAll (Utils .toList (array ));
292
+
323
293
for (GUIButton b : buttons ) {
324
294
int slot = b .getSlot ();
325
295
if (slot == -1 ) {
@@ -348,4 +318,12 @@ private void loadGUIItemsAndSyncItems(){
348
318
}
349
319
}
350
320
321
+ /**
322
+ * Gets the extra items that will be placed inside the GUI
323
+ * @return the buttons to place inside the GUI
324
+ */
325
+ protected GUIButton [] getExtraButtons (){
326
+ return new GUIButton [0 ];
327
+ }
328
+
351
329
}
0 commit comments