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.
- Plugin Support:
- Nexo
- Oraxen
- ItemsAdder
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>
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
git clone https://github.com/milkdrinkers/ItemUtils.git
cd itemutils
./gradlew publishToMavenLocal
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.
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.
Here is a list of known projects using ItemUtils:
- (Add your project here!)