Skip to content

A simple set of utility classes for working with custom item plugins like ItemsAdder and Nexo on PaperMC servers.

License

Notifications You must be signed in to change notification settings

milkdrinkers/ItemUtils

Repository files navigation

ItemUtils

GitHub License Maven Central Version Javadoc GitHub Actions Workflow Status GitHub Issues GitHub last commit Discord Server

ItemUtils is a simple set of utility classes for working with custom item plugins on PaperMC servers. It's intended purpose is to make adding custom item support to your plugins effortless.


🌟 Features

  • Plugin Support:
    • Nexo
    • Oraxen
    • ItemsAdder

📦 Installation

Add ItemUtils to your project with Maven or Gradle:

Gradle Kotlin DSL
repositories {
    mavenCentral()
}

dependencies {
    implementation("io.github.milkdrinkers:itemutils:LATEST_VERSION")
}
Maven
<project>
    <dependencies>
        <dependency>  
            <groupId>io.github.milkdrinkers</groupId>  
            <artifactId>itemutils</artifactId>  
            <version>LATEST_VERSION</version>  
        </dependency>  
    </dependencies>
</project>

Usage Example 🚀

import io.github.milkdrinkers.itemutil.ItemUtils;
import io.github.milkdrinkers.itemutil.InventoryUtils;

// Get item stack by item id

// Vanilla
ItemStack diamondSword1 = ItemUtils.parse("minecraft:diamond_sword");
ItemStack diamondSword2 = ItemUtils.parse("diamond_sword"); // By default assumes using "minecraft:" namespace
ItemStack diamondSword3 = ItemUtils.parseOptional("diamond_sword"); // Same as #parse(String), but returns an optional

// Custom items from plugins
ItemStack nexoItem = ItemUtils.parse("nexo:custom_item_name"); // Nexo
ItemStack oraxenItem = ItemUtils.parse("oraxen:custom_item_name"); // Oraxen
ItemStack itemsAdderItem = ItemUtils.parse("itemsadder:custom_item_name"); // ItemsAdder

player.getInventory().addItem(diamondSword1);

// Get item id from item stack
String itemId1 = ItemUtils.parse(diamondSword1); // Returns "minecraft:diamond_sword"
String itemId2 = ItemUtils.parse(nexoItem); // Returns "nexo:custom_item_name"

// Check if an item/materials exists with this item id
boolean doesExist = ItemUtils.exists("itemsadder:some_randon_item_name");

// Check if player has custom item in their inventory
boolean hasEnough = InventoryUtils.contains(player, "nexo:custom_item_name", 1); // Check if player has at least 1 of the custom item

// Remove custom items from player's inventory
InventoryUtils.removeItem(player, "nexo:custom_item_name", 5); // Remove 5 of the custom item from player's inventory

📚 Documentation


🔨 Building from Source

git clone https://github.com/milkdrinkers/ItemUtils.git
cd itemutils
./gradlew publishToMavenLocal

🔧 Contributing

Contributions are always welcome! Please make sure to read our Contributor's Guide for standards and our Contributor License Agreement (CLA) before submitting any pull requests.

We also ask that you adhere to our Contributor Code of Conduct to ensure this community remains a place where all feel welcome to participate.


📝 Licensing

You can find the license the source code and all assets are under here. Additionally, contributors agree to the Contributor License Agreement (CLA) found here.


🔥 Consuming Projects

Here is a list of known projects using ItemUtils:

  • (Add your project here!)