Sueta

ItemUtilAPI

2.5.2

API that makes the creation of custom ItemStacks easy

·Plugin

This API has only one goal: To make the creation and the interaction of ItemStacks easy. It has a class called ItemCreator, which lets you build your own ItemStack in just one line, and a special addition, which is an InteractionListener and a InventoryClickListener configured in the ItemCreator as well.

ItemCreator itemCreator = new ItemCreator(Material.DIAMOND); 

itemCreator.handleInteraction((event) -> { 
/*Allows you to put the same code you would put in the PlayerInteractEvent Handler*/ 
}); 
itemCreator.handleClick((event) -> { 
/*Allows you to put the same code you would put in the InventoryClickEvent Handler*/ 
});

All of the methods that the ItemCreator class provides can be found in the image below. Screenshot_6.png

Here is an example, it shows the creation of a simple BlazeRod, that pushes the player in the direction he is looking when the player rightclicks, that sends a message to the player when he clicks it in his inventory.

ItemCreator creator = new ItemCreator(Material.BLAZE_ROD); 
        creator.setDisplayName("§cFlying Staff") 
                .setGlow(true) 
                .addLore("Makes you fly! §7(Rightclick)") 
                .handleInteraction((event) -> { 
                    if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) { 
                        event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().multiply(5f)); 
                        event.getPlayer().sendMessage("§aYou have been pushed!"); 
                    } 
                }).handleClick((event) -> event.getWhoClicked().sendMessage("hey there")); 
        ItemStack stack = creator.build();

If you have any questions regarding the API, feel free to add me on Discord: OverDodo#1535 or start a conversation here!

IMPORTANT: If you want your Items to work with Actions after a restart, create and build the items in a method that is run when the plugin is getting enabled.

Similar projects

Plugin →