// Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
// 	
//   	private static ItemJoin instance;
//   	private boolean isStarted = false;
//   	
//    /**
//     * Called when the plugin is loaded.
//     * 
//     */
//     @Override
//     public void onLoad() {
//     	instance = this;
//     }
//     
//    /**
//     * Called when the plugin is enabled.
//     * 
//     */
//   	@Override
// 	public void onEnable() {
//         ConfigHandler.getConfig().registerEvents();
//         SchedulerUtils.runAsync(() -> {
//         	UpdateHandler.getUpdater(true); {
//         		ServerUtils.logDebug("has been Enabled.");
//         	}
//         });
//   	}
//   	
//    /**
//     * Called when the plugin is disabled.
//     * 
//     */
//   	@Override
// 	public void onDisable() {
//   		Bukkit.getScheduler().cancelTasks(this);
//   		Menu.closeMenu();
//   		ItemHandler.saveCooldowns();
//   		ItemHandler.purgeCraftItems(true);
// 	  	Database.getDatabase().closeConnection(true);
// 	  	ProtocolManager.closeProtocol();
// 	  	ItemUtilities.getUtilities().clearItems();
//   		ServerUtils.logDebug("has been Disabled.");
//   	}
//   	
//    /**
// 	* Checks if the plugin has fully loaded.
// 	* 
// 	*/
// 	public boolean isStarted() {
// 		return this.isStarted;
// 	}
// 	
//    /**
// 	* Sets the plugin as fully loaded.
// 	* 
// 	*/
// 	public void setStarted(final boolean bool) {
// 		this.isStarted = bool;
// 	}
//   	
//    /**
//     * Gets the Plugin File.
//     * 
//     * @return The Plugin File.
//     */
//   	public File getPlugin() {
//   		return this.getFile();
//   	}
// 
//    /**
//     * Gets the static instance of the main class for ItemJoin. 
//     * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin. 
//     * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
//     *
//     * @return ItemJoin instance.
//     */  	
//   	public static ItemJoin getInstance() {
//   		return instance;
//   	}
// }


import java.util.Objects;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import me.RockinChaos.itemjoin.ItemJoin;
/*
 * ItemJoin
 * Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package me.RockinChaos.itemjoin.utils.interfaces;




public class Button {
	
    private int counter;
    private final int ID = counter++;
    private ItemStack itemStack;
    private Consumer<InventoryClickEvent> clickAction;
    private Consumer<AsyncPlayerChatEvent> chatAction;

   /**
    * Creates a new button instance.
    * There is no click event or chat event.
    * 
    * @param itemStack - The ItemStack the button is to be placed as.
    */
    public Button(ItemStack itemStack) {
    	this(itemStack, event -> {});
    }
    
   /**
    * Creates a new button instance.
    * There is no chat event.
    * 
    * @param itemStack - The ItemStack the button is to be placed as.
    * @param clickAction - The method to be executed upon clicking the button.
    */
    public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction) {
    	this.itemStack = itemStack;
    	this.clickAction = clickAction;
    }
    
   /**
    * Creates a new button instance.
    * 
    * @param itemStack - The ItemStack the button is to be placed as.
    * @param clickAction - The method to be executed upon clicking the button.
    * @param chatAction - The method to be executed upon chatting after clicking the button.
    */
    public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction, Consumer < AsyncPlayerChatEvent > chatAction) {
    	this.itemStack = itemStack;
    	this.clickAction = clickAction;
    	this.chatAction = chatAction;
    }
    
   /**
    * Gets the ItemStack for the button.
    * 
    * @return The buttons ItemStack.
    */
    public ItemStack getItemStack() {
    	return this.itemStack;
    }
    
   /**
    * Sets the click action method to be executed.
    * 
    * @param clickAction - The click action method to be executed.
    */
    public void setClickAction(Consumer < InventoryClickEvent > clickAction) {
    	this.clickAction = clickAction;
    }
    
   /**
    * Sets the chat action method to be executed.
    * 
    * @param chatAction - The chat action method to be executed.
    */
    public void setChatAction(Consumer < AsyncPlayerChatEvent > chatAction) {
    	this.chatAction = chatAction;
    }
    
   /**
	* Called on player inventory click.
	* Executes the pending click actions.
    * 
    * @param event - InventoryClickEvent
    */
    public void onClick(InventoryClickEvent event) {
// Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
// 	
//   	private static ItemJoin instance;
//   	private boolean isStarted = false;
//   	
//    /**
//     * Called when the plugin is loaded.
//     * 
//     */
//     @Override
//     public void onLoad() {
//     	instance = this;
//     }
//     
//    /**
//     * Called when the plugin is enabled.
//     * 
//     */
//   	@Override
// 	public void onEnable() {
//         ConfigHandler.getConfig().registerEvents();
//         SchedulerUtils.runAsync(() -> {
//         	UpdateHandler.getUpdater(true); {
//         		ServerUtils.logDebug("has been Enabled.");
//         	}
//         });
//   	}
//   	
//    /**
//     * Called when the plugin is disabled.
//     * 
//     */
//   	@Override
// 	public void onDisable() {
//   		Bukkit.getScheduler().cancelTasks(this);
//   		Menu.closeMenu();
//   		ItemHandler.saveCooldowns();
//   		ItemHandler.purgeCraftItems(true);
// 	  	Database.getDatabase().closeConnection(true);
// 	  	ProtocolManager.closeProtocol();
// 	  	ItemUtilities.getUtilities().clearItems();
//   		ServerUtils.logDebug("has been Disabled.");
//   	}
//   	
//    /**
// 	* Checks if the plugin has fully loaded.
// 	* 
// 	*/
// 	public boolean isStarted() {
// 		return this.isStarted;
// 	}
// 	
//    /**
// 	* Sets the plugin as fully loaded.
// 	* 
// 	*/
// 	public void setStarted(final boolean bool) {
// 		this.isStarted = bool;
// 	}
//   	
//    /**
//     * Gets the Plugin File.
//     * 
//     * @return The Plugin File.
//     */
//   	public File getPlugin() {
//   		return this.getFile();
//   	}
// 
//    /**
//     * Gets the static instance of the main class for ItemJoin. 
//     * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin. 
//     * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
//     *
//     * @return ItemJoin instance.
//     */  	
//   	public static ItemJoin getInstance() {
//   		return instance;
//   	}
// }


// Path: src/me/RockinChaos/itemjoin/utils/interfaces/Button.java
import java.util.Objects;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import me.RockinChaos.itemjoin.ItemJoin;

/*
 * ItemJoin
 * Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package me.RockinChaos.itemjoin.utils.interfaces;




public class Button {
	
    private int counter;
    private final int ID = counter++;
    private ItemStack itemStack;
    private Consumer<InventoryClickEvent> clickAction;
    private Consumer<AsyncPlayerChatEvent> chatAction;

   /**
    * Creates a new button instance.
    * There is no click event or chat event.
    * 
    * @param itemStack - The ItemStack the button is to be placed as.
    */
    public Button(ItemStack itemStack) {
    	this(itemStack, event -> {});
    }
    
   /**
    * Creates a new button instance.
    * There is no chat event.
    * 
    * @param itemStack - The ItemStack the button is to be placed as.
    * @param clickAction - The method to be executed upon clicking the button.
    */
    public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction) {
    	this.itemStack = itemStack;
    	this.clickAction = clickAction;
    }
    
   /**
    * Creates a new button instance.
    * 
    * @param itemStack - The ItemStack the button is to be placed as.
    * @param clickAction - The method to be executed upon clicking the button.
    * @param chatAction - The method to be executed upon chatting after clicking the button.
    */
    public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction, Consumer < AsyncPlayerChatEvent > chatAction) {
    	this.itemStack = itemStack;
    	this.clickAction = clickAction;
    	this.chatAction = chatAction;
    }
    
   /**
    * Gets the ItemStack for the button.
    * 
    * @return The buttons ItemStack.
    */
    public ItemStack getItemStack() {
    	return this.itemStack;
    }
    
   /**
    * Sets the click action method to be executed.
    * 
    * @param clickAction - The click action method to be executed.
    */
    public void setClickAction(Consumer < InventoryClickEvent > clickAction) {
    	this.clickAction = clickAction;
    }
    
   /**
    * Sets the chat action method to be executed.
    * 
    * @param chatAction - The chat action method to be executed.
    */
    public void setChatAction(Consumer < AsyncPlayerChatEvent > chatAction) {
    	this.chatAction = chatAction;
    }
    
   /**
	* Called on player inventory click.
	* Executes the pending click actions.
    * 
    * @param event - InventoryClickEvent
    */
    public void onClick(InventoryClickEvent event) {
		if (ItemJoin.getInstance().isEnabled()) {