api
Maven repository
If you're using Maven, you'll be able to automatically download the JAR, JavaDoc and associated sources from the following repository:
<repositories> <repository> <id>comphenix-rep</id> <name>Comphenix Repository</name> <url>http://repo.comphenix.net/content/groups/public</url> </repository> <!-- And so on --> </repositories>
This repository contains ItemRenamer, along with ProtocolLib, TagHelper and BlockPatcher. You can add ItemRenamer and ProtocolLib like so:
<dependencies> <dependency> <groupId>org.shininet.bukkit</groupId> <artifactId>ItemRenamer</artifactId> <version>2.0.0</version> </dependency> <dependency> <groupId>com.comphenix.protocol</groupId> <artifactId>ProtocolLib</artifactId> <version>2.7.0</version> </dependency> </dependencies>
API
First, declare ItemRenamer as a dependency in plugin.yml:
depend: [ProtocolLib, ItemRenamer]
Then you'll be able to rename items in any way you wish (download)
@Override public void onEnable() { RenamerAPI.getAPI().addListener(this, RenamerPriority.POST_NORMAL, new ItemsListener() { @Override public void onItemsSending(Player player, RenamerSnapshot snapshot) { addGlow(snapshot); } }); } private void addGlow(RenamerSnapshot stacks) { for (ItemStack stack : stacks) { // Only update those stacks that have our flag lore if (stack != null && stack.hasItemMeta()) { List<String> lore = stack.getItemMeta().getLore(); if (Arrays.asList(EXAMPLE_MOD_GLOW).equals(lore)) { NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(stack); compound.put(NbtFactory.ofList("ench")); compound.getCompound("display").remove("Lore"); } } } }
JavaDoc
The JavaDoc can be accessed on my Jenkins server.
Comments