File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
src/main/java/xyz/theprogramsrc/supercoreapi/spigot/guis Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 66
77 <groupId >xyz.theprogramsrc</groupId >
88 <artifactId >SuperCoreAPI</artifactId >
9- <version >3.2.1 </version >
9+ <version >3.2.2 </version >
1010 <packaging >jar</packaging >
1111
1212 <name >SuperCoreAPI</name >
Original file line number Diff line number Diff line change @@ -121,6 +121,14 @@ public String getCenteredTitle() {
121121 return result .append (title ).toString ();
122122 }
123123
124+ /**
125+ * Used to know if the GUI can be closed
126+ * @return true if can be closed, otherwise false
127+ */
128+ public boolean canCloseGUI (){
129+ return true ;
130+ }
131+
124132 /**
125133 * Adds a placeholder to the GUI (used on the title)
126134 * @param key The key of the placeholder
@@ -193,9 +201,13 @@ public void onClose(InventoryCloseEvent event){
193201 if (this .inventory != null ){
194202 if (event .getInventory ().equals (this .inventory )){
195203 if (event .getPlayer ().equals (this .player )){
196- this .getSpigotTasks ().runTask (()->{
197- HandlerList .unregisterAll (this );
198- this .inventory = null ;
204+ this .getSpigotTasks ().runTaskLater (5L ,()->{
205+ if (this .canCloseGUI ()){
206+ HandlerList .unregisterAll (this );
207+ this .inventory = null ;
208+ }else {
209+ this .open ();
210+ }
199211 });
200212 }
201213 }
@@ -292,4 +304,5 @@ protected void onEvent(GUIEvent event){}
292304 * @return the buttons to place inside the GUI
293305 */
294306 protected abstract GUIButton [] getButtons ();
307+
295308}
You can’t perform that action at this time.
0 commit comments