Skip to content

Commit ba7c31a

Browse files
author
TheProgramSrc
committed
Change Log:
• Bug Fixes NOTE: THIS IS A BETA, IS NOT RECOMMENDED TO USE IN PRODUCTION OR RELEASES
1 parent df499b9 commit ba7c31a

File tree

2 files changed

+12
-34
lines changed

2 files changed

+12
-34
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>3.6.1</version>
9+
<version>3.6.1_BETA1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/guis/GUI.java

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public abstract class GUI extends SpigotModule {
3333
private final HashMap<String, String> placeholders;
3434
private final Player player;
3535
private HashMap<Integer, GUIButton> buttons;
36-
private List<GUIButton> extraButtons;
3736

3837
/**
3938
* Creates a new GUI
@@ -45,7 +44,6 @@ public GUI(SpigotPlugin plugin, Player player){
4544
this.player = player;
4645
this.placeholders = new HashMap<>();
4746
this.buttons = new HashMap<>();
48-
this.extraButtons = new ArrayList<>();
4947
}
5048

5149
/**
@@ -104,36 +102,6 @@ public void clear(){
104102
this.inventory.clear();
105103
}
106104

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-
137105
/**
138106
* Used to know if the GUI title should be centered
139107
* @return if the GUI title should be centered
@@ -319,7 +287,9 @@ private void loadGUIItemsAndSyncItems(){
319287
List<GUIButton> buttons = new ArrayList<>();
320288
GUIButton[] array = this.getButtons();
321289
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+
323293
for (GUIButton b : buttons) {
324294
int slot = b.getSlot();
325295
if (slot == -1) {
@@ -348,4 +318,12 @@ private void loadGUIItemsAndSyncItems(){
348318
}
349319
}
350320

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+
351329
}

0 commit comments

Comments
 (0)