publicclassExecutableItemsAPI { /** Get the ExecutableItems Manager **/publicstaticExecutableItemsManagerInterfacegetExecutableItemsManager() {returnExecutableItemsManager.getInstance(); }}
The static method to have access to the manager of the ExecutableItems.
publicinterfaceExecutableItemsManagerInterface { /** Verify if id is a valid ExecutableItem ID * @param id The ID to verify * @return true if it is a valid ID, false otherwise * **/booleanisValidID(String id); /** Get an ExecutableItem from its ID * @param id The ID of the ExecutableItem * @return The ExecutableItem or an empty optional * **/Optional<ExecutableItemInterface> getExecutableItem(String id); /** Get an ExecutableItem from its itemStack form * @param itemStack The itemStack to get the ExecutableItem from * @return The ExecutableItem or an empty optional * **/Optional<ExecutableItemInterface> getExecutableItem(ItemStack itemStack); /** Get all ExecutableItems Ids * @return All ExecutableItems ids * **/List<String> getExecutableItemIdsList();}
The methods of the manager.
publicinterfaceExecutableItemInterfaceextendsSObject { /** To place at the end of your itemBuilder , it adds infos for item to be recognized as an ExecutableItem * It will take the lore / name of the ExecutableItems and Override yours (But it doesn't override the customModeldata tag) * @param item The item to add the ExecutableItem infos to * @param creator The optional creator of the ExecutableItem * */ItemStackaddExecutableItemInfos(ItemStack item,Optional<Player> creator); /** * @param player The player to whom you want to check the possession of the permission * @param showError true if you want to show an error message to the player if he doesn't have the permission * @return The name of the ExecutableItem */booleanhasItemPerm(@NotNullPlayer player,boolean showError); /** * Build the ExecutableItem * @param amount The amount of the ExecutableItem * @param usage The optional custom usage of the ExecutableItem, otherwise it will use the default one * @param creator The optional creator of the ExecutableItem * @return The ExecutableItem */ItemStackbuildItem(int amount,Optional<Integer> usage,Optional<Player> creator);}
The methods of the ExecutableItem
Example
/** Exemple you decide to support ExecutableItems in your shop plugin **/publicvoidgiveExecutableItem(Player player,String executableItemId,int amount){ItemStack item =null;Optional<ExecutableItemInterface> eiOpt =ExecutableItemsAPI.getExecutableItemsManager().getExecutableItem(executableItemId);if(eiOpt.isPresent()) item =eiOpt.get().buildItem(amount,Optional.empty(),Optional.of(player));if(item !=null)player.getInventory().addItem(item);/* else Your error message here */}
Event to call when you add an ExecutableItem in a player inventory
Since SCore 3.4.7, Please when you add an ExecutableItem in a player inventory call the following event: