Minepacks/Minepacks-API
GeorgH93 a4148d5772
Remove useless curly braces
2024-01-23 22:11:33 +01:00
..
src/at/pcgamingfreaks/Minepacks/Bukkit/API Remove useless curly braces 2024-01-23 22:11:33 +01:00
README.md Update README.md 2020-04-19 17:46:27 +02:00
pom.xml Build API with current version of PluginLib 2024-01-19 00:45:23 +01:00

README.md

Logo

This branch holds the API for the Minepacks plugin.

ciImg apiVersionImg licenseImg

Adding it to your plugin:

Maven:

The API is available through maven.

Repository:

<repository>
	<id>pcgf-repo</id>
	<url>https://repo.pcgamingfreaks.at/repository/maven-everything</url>
</repository>

Dependency:

<!-- Minepacks API -->
<dependency>
    <groupId>at.pcgamingfreaks</groupId>
    <artifactId>Minepacks-API</artifactId>
    <version>2.2</version><!-- Check api-version shield for newest version -->
</dependency>

Build from source:

git clone https://github.com/GeorgH93/Minepacks.git
cd Minepacks
mvn -pl Minepacks-API

Usage:

Get access to the API:

public static MinepacksPlugin getMinepacks() {
    Plugin bukkitPlugin = Bukkit.getPluginManager().getPlugin("Minepacks");
    if(!(bukkitPlugin instanceof MinepacksPlugin)) {
    	// Do something if Minepacks is not available
        return null;
    }
    return (MinepacksPlugin) bukkitPlugin;
}

You can now use the returned MinepacksPlugin object to interact with the Minepacks plugin.

Access a players backpack inventory:

public static Inventory getPlayerBackpackInventory(Player player) {
    Backpack bp = getMinepacks().getBackpackCachedOnly(player);
    if(bp == null) return null; //Backpack not loaded (retry later)
    return bp.getInventory();
}

This will return null if the backpack is not loaded or the inventory of the backpack if the backpack is already loaded.