Fastinv

Lightweight and easy-to-use inventory API for Bukkit plugins.
Alternatives To Fastinv
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Geyser3,941
a day ago355mitJava
A bridge/proxy allowing you to connect to Minecraft: Java Edition servers with Minecraft: Bedrock Edition.
Minestom1,886
a day ago167apache-2.0Java
1.19.3 Lightweight Minecraft server
Anvilgui373
19 days ago3mitJava
AnvilGUI is a library to capture user input in Minecraft through an anvil inventory
If281
717 hours ago57December 19, 202296unlicenseJava
An inventory framework for managing GUIs
Smartinvs179
82 years ago13March 14, 201938apache-2.0Java
Advanced Inventory API for your Minecraft Bukkit plugins.
Inventorygui152
2 months ago14mitJava
A library for Bukkit plugins to create GUIs with inventories
Beautyquests125
a month ago29mitJava
A quests plugin based on a simple-to-use graphical interface (Minecraft)
Invui109
5 days ago2mitJava
A spigot library for creating custom inventory-based GUIs.
Canvas84
9 months ago1mitJava
Canvas is a java library built for Bukkit to manage custom inventory based menus
Multiverse Inventories71
3 months ago74Java
Alternatives To Fastinv
Select To Compare


Alternative Project Comparisons
Readme

FastInv

JitPack Discord

Lightweight and easy-to-use inventory API for Bukkit plugins.

Features

  • Very small (less than 400 lines of code with the JavaDoc) and no dependencies
  • Works with all Bukkit versions from 1.7.10 to 1.19
  • Supports custom inventories (size, title and type)
  • Easy to use
  • Option to prevent a player from closing the inventory
  • The Bukkit inventory can still be directly used

Installation

Maven

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.3.0<</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <relocations>
                    <relocation>
                        <pattern>fr.mrmicky.fastinv</pattern>
                        <!-- Replace 'com.yourpackae' with the package of your plugin ! -->
                        <shadedPattern>com.yourpackage.fastinv</shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>fr.mrmicky</groupId>
        <artifactId>FastInv</artifactId>
        <version>3.0.3</version>
    </dependency>
</dependencies>

Gradle

plugins {
    id 'com.github.johnrengelman.shadow' version '7.1.2'
}

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'fr.mrmicky:FastInv:3.0.3'
}

shadowJar {
    // Replace 'com.yourpackage' with the package of your plugin 
    relocate 'fr.mrmicky.fastinv', 'com.yourpackage.fastinv'
}

Manual

Simply copy FastInv.java and FastInvManager.java in your plugin. You can also add ItemBuilder.java if you need.

Usage

Register FastInv

Before creating inventories, you just need to register your plugin by adding FastInvManager.register(this); in the onEnable() method of your plugin:

@Override
public void onEnable() {
    FastInvManager.register(this);
}

Creating an inventory class

Now you can create an inventory by make a class that extends FastInv, and add items in the constructor. You can also override onClick, onClose and onOpen if you need.

Small example inventory:

package fr.mrmicky.fastinv.test;

import fr.mrmicky.fastinv.FastInv;
import fr.mrmicky.fastinv.ItemBuilder;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.ItemStack;

public class ExampleInventory extends FastInv {

    private boolean preventClose = false;

    public ExampleInventory() {
        super(45, ChatColor.GOLD + "Example inventory");

        // Just add a random item
        setItem(22, new ItemStack(Material.IRON_SWORD), e -> e.getWhoClicked().sendMessage("You clicked on the sword"));

        // Add some blocks to the borders
        setItems(getBorders(), new ItemBuilder(Material.LAPIS_BLOCK).name(" ").build());

        // Add a simple item to prevent closing the inventory
        setItem(34, new ItemBuilder(Material.BARRIER).name(ChatColor.RED + "Prevent close").build(), e -> {
            this.preventClose = !this.preventClose;
        });

        // Prevent from closing when preventClose is to true
        setCloseFilter(p -> this.preventClose);
    }

    @Override
    public void onOpen(InventoryOpenEvent event) {
        event.getPlayer().sendMessage(ChatColor.GOLD + "You opened the inventory");
    }

    @Override
    public void onClose(InventoryCloseEvent event) {
        event.getPlayer().sendMessage(ChatColor.GOLD + "You closed the inventory");
    }

    @Override
    public void onClick(InventoryClickEvent event) {
        // do something
    }
}

Now you can open the inventory:

new ExampleInventory().open(player);

Creating a 'compact' inventory

If you prefer, you can create a 'compact' inventory that doesn't require an entire class, but this is not recommended.

FastInv inv = new FastInv(InventoryType.DISPENSER, "Example compact inventory");

inv.setItem(4, new ItemStack(Material.NAME_TAG), e -> e.getWhoClicked().sendMessage("You clicked on the name tag"));
inv.addClickHandler(e -> player.sendMessage("You clicked on slot " + e.getSlot()));
inv.addCloseHandler(e -> player.sendMessage(ChatColor.YELLOW + "Inventory closed"));
inv.open(player);

Get the FastInv instance

You can easily get the FastInv instance from a Bukkit inventory with the holder:

if (inventory.getHolder() instanceof FastInv) {
    FastInv fastInv = (FastInv) inventory.getHolder();
}
Popular Bukkit Projects
Popular Inventory Projects
Popular Games Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Java
Plugin
Gui
Minecraft
Menu
Inventory
Particles
Changelog
Spigot
Bukkit