ItemEditor
an Easier Item Edit API
Zero:what is it:
- It is an easier item edit API,it allows developer edit tag or other Item things with a easier way.
- it use ASM,According to your server to create ASMTool.jar to operate NMS directly.it has faster efficiency than reflexes.
- with it,when u want to edit nbt,you didn't need to use reflect,only some easy method,u can realize it.
How to use:
These two steps are necessary:
- First: u need download the plugin,and add it as external jars. like u deal with Server Core jar.
- Second: Determine whether ItemEditorAPI is installed
add
to your plugin.yml to make sure your plugin will enable after ItemEditorAPI.depend: [ItemEditorAPI]
Model Instduce:
chenji.itemeditor.util.NMSItem:
- It seems like a bridge of ItemStack to NMSItemStack,it allow u to set the NBTTagCompound.you can use
to get the instance of NMSItem.NMSItem nmsitem = NMSItem.getItem(item);
to get the instance of Bukkit ItemStack.nmsitem.getBukkitItem();
to set the NBTTagCompound instance to item.nmsitem.setTag(tag);
NOTICE it is chenji.itemeditor.nbt.base.NBTTagCompound! NOT NMS's NBTTagCompound. chenji.itemeditor.nbt.base.NBTTagCompound will be Instduced following....
- it is a nbt system,u can use it as same as NMS's NBT system.
- this is a simplely write example:
Create a NBTTagCompound instance:
put an int :key:testint value:233NBTTagCompound tag = new NBTTagCompound();
put a String :testString value:test
set the NBTTagCompound instance to item.tag.setInt("testint", 233); tag.setString("testString", "test");
now get your item,u can find it was saved in your item,Is it very simple?if u want to read,please look following...nmsitem.setTag(tag); - use
to get NBTTagCompound instance from nmsitem.NBTTagCompound tag = nmsitem.getTag();
use
to get the value.NBTBase base = tag.get(key);
use
to get Type of Value;base.getType();
if you know the type,u can cast the base to child.such as It is a String, cast it to NBTTagString and use getValue(); to get String result;
If you know exactly the type of the key,u can use exactly method such as getString(key);((NBTTagString)base).getValue();
so the above code can be simplified to:
or even:NBTTagCompound tag = nmsitem.getTag(); String result = tag.getString(key);
String result = nmsitem.getTag().getString(key);
ItemEditor Instduce:
- this API has a ItemEditor,it prefabricated some method.you can use these methods edit item quickly.Here are some demo:
- use
to create instance.after edit,you need usenew ItemEditor(item);
to get back Bukkit item.editor.getItem(); - There are some demo to operate the ItemEditor;
/**
* this demo tell u some common operation to operate the item with ItemEditor.
*
* @param editor
* the ItemEditor what u want to set
*/
public void setSomethings(ItemEditor editor) {
// Set the amount of item: 10
editor.setAmount(10);
// add an Attribute to item: Health up:10
editor.addAttrbute(new Attribute().setAttributeType(AttributeType.MAX_HEALTH).setAmount(10));
// add an lore line:testlore
editor.addLoreLine("testlore");
// set the display name: testdisplayname
editor.setDisplayName("testdisplayname");
// set the color with rgb if the type allowed:255 255 255
editor.setColor(255, 255, 255);
// add an enchantment :PROTECTION_FALL level:10
editor.addEnchantment(Enchantment.PROTECTION_FALL, 10);
}
/**
* this exam tell u some common operation to read the item with ItemEditor.
*
* @param editor
* the ItemEditor what u want to read
*/
@SuppressWarnings("unused")
public void readSomethings(ItemEditor editor) {
List<Attribute> attrs = editor.getAttirbutes();
List<String> lores = editor.getLore();
}
- Its functions are far less than these.Make good use of Ide's automatic complementing.find out the method u need.i think u can understand by the method name;
- The code is in here:https://gitee.com/ChenJi158/ItemEdi.../chenji/itemeditor/itemeditor/ItemEditor.java
- Due to the reason of time it's Javadoc and methods table is missing if i have time,i will perfect the Javadoc and update a methods table.
Finally:
The project is open source here: https://gitee.com/ChenJi158/ItemEditorAPI
my mother language is not English....
forgive my poor English... if this page have some syntax error.welcome u to send email to ( [email protected]) to report,thanks
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