Sueta

Inventory API

1.0.0

Revolutionizing the spigot community with a simple yet efficient inventory api

·Plugin

Inventory API

Ever wanted a simple yet professional way to make your inventories without having to make individual events per item? Well here's your solution, in our custom inventory system we utilize item listeners per item and save your data per item dependent on click type.

Features

  • Inventories of any inventory type.
  • Customization size from multiples of 9.
  • Built in item builder with support for enchantments and lore.
  • Click Types for different click types.

Examples of API

package com.asylumdevs.inventoryapi.example; 

import java.util.Arrays; 

import org.bukkit.ChatColor; 
import org.bukkit.Material; 
import org.bukkit.entity.Player; 
import org.bukkit.event.inventory.ClickType; 
import org.bukkit.event.inventory.InventoryType; 
import org.bukkit.inventory.ItemStack; 

import com.asylumdevs.inventoryapi.Inventory; 
import com.asylumdevs.inventoryapi.InventoryAPI; 
import com.asylumdevs.inventoryapi.ItemListener; 

public class Example { 

    // Opening a blank inventory named "Example" with 1 row. 

    public void openBlank(Player p) { 
        Inventory inv = InventoryAPI.createInventory1(ChatColor.translateAlternateColorCodes('&', "Example"), 9); 

        inv.open(p); 
    } 

    // Opening a inventory with a inventort type named "HOPPER" for the item 
    // hopper. 

    public void openHopper(Player p) { 
        Inventory inv = InventoryAPI.createInventory(ChatColor.translateAlternateColorCodes('&', "Example"), 
                InventoryType.HOPPER); 

        inv.open(p); 
    } 
  
    // Opening a inventory with a custom item using our item builder. 

    public void openBuilder(Player p) { 
        Inventory inv = InventoryAPI.createInventory1(ChatColor.translateAlternateColorCodes('&', "Example"), 9); 

        inv.setSlot(4, InventoryAPI.createItem("&aClick here!", null, Material.DIRT, 
                null, 1), new ItemListener() { 
            public void onItemClick(Player p, ClickType click) { 
                // Empty doesn't do anything when clicked. 
            } 
        }); 
      
        inv.open(p); 
    } 
  
    // Opening a inventory that replies back with the player's name. 

    public void openPlayerName(Player p) { 
        Inventory inv = InventoryAPI.createInventory1(ChatColor.translateAlternateColorCodes('&', "Example"), 9); 

        inv.setSlot(4, InventoryAPI.createItem("&dClick here!", null, Material.HOPPER, 
                null, 1), new ItemListener() { 
            public void onItemClick(Player p, ClickType click) { 
                p.sendMessage(p.getName()); 
            } 
        }); 
      
        inv.open(p); 
    } 

    // Opening a custom inventory created 

    public void openCustom(Player p) { 
        Inventory inv = InventoryAPI.createInventory1(ChatColor.translateAlternateColorCodes('&', "Example"), 9); 

        inv.setSlot(4, InventoryAPI.createItem("&dClick here!", Arrays.asList("&fHey!", "&fIf you click here you'll be given one dirt."), Material.HOPPER, 
                null, 1), new ItemListener() { 
            public void onItemClick(Player p, ClickType click) { 
                p.getInventory().addItem(new ItemStack(Material.DIRT)); 
            } 
        }); 
      
        inv.open(p); 
    } 
}

Problems/Concerns

If you have problems or issues, you can send me a private message, or add me over on discord at ASD#4102.

Similar projects

Plugin →