ItemStackLib
2.0.3[1.8-1.13.2] Library to modify some ItemStack traits that Bukkit doesn't support
Usage
ItemStackLib provides methods to do two things that the Bukkit API still lacks: The possibility to apply attributes like attack damage or armor to ItemStacks and Base64 encoded texture values to player head ItemStacks. Values to use for heads can be found for example here included in commands, like:
/give @p player_head 1 {display:{Name:"Bread"},SkullOwner:{Id:" a75e3f60-2242-4429-8ece-bcde77",Properties:{textures:[{Value:" eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjM0ODdkNDU3ZjkwNjJkNzg3YTNlNmNlMWM0NjY0YmY3NDAyZWM2N2RkMTExMjU2ZjE5YjM4Y2U0ZjY3MCJ9fX0="}]}}}
UUID
Base64 texture value
Code example:
// Item attributes
ItemStack sword = new ItemStack(Material.IRON_SWORD);
sword = AttributeWrapper.builder()
.attribute(InternalAttribute.GENERIC_ATTACK_DAMAGE)
.name("myattribute")// Optional
.operation(InternalOperation.ADD_NUMBER)
.amount(10.35)
.slots(InternalSlot.HAND)// Optional
.build()
.applyTo(sword);
Collection<AttributeWrapper> modifiers = ItemUtil.getAttributes(sword);
// To remove all modifiers of a specific attribute:
ItemUtil.removeAttributeType(sword, InternalAttribute.GENERIC_ATTACK_DAMAGE);
// To remove all modifiers that have a specific name:
ItemUtil.removeAttribute(sword, "myattribute");
// Skulls with Base64 texture value
String texture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM2NDVhNDI1OTg3ZjNiN2MyZmFjMDIwNmNlOThiYTVlMjNiOWM0ODUyZmVhNWIxOTc4Zjc0NjdlOGQzMTMifX19";
ItemStack texturedSkull = ItemUtil.setSkullOwner(head, player.getUniqueId(), textureValue);
String textureFromSkull = ItemUtil.getTextureValue(head);
Maven
<dependencies>
<dependency>
<groupId>de.erethon</groupId>
<artifactId>itemstacklib</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>dre-repo</id>
<url>https://erethon.de/repo/</url>
</repository>
</repositories>
ItemStackLib is a library that developers can shade or copy into their own plugin. This is not a standalone plugin. Shading libraries can be done using Maven and its shade plugin:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>de.erethon:itemstacklib</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
License
Written in 2018 by Daniel Saukel
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.
(tl;dr; do whatever you want with this without asking)
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta