Custom Items API
WHAT CAN THIS API DO?
Commands:
- /ci help - Shows some help about this API
- /ci list - Lists all registered custom items
- /ci give [id] - Gives an item with the given ID to you.
- /ci give [player] [id] <amount> - Gives <amount> items with the given ID to the player
HOW TO USE THIS API
What is this API doing?
With this API everybody can easily create more or less complex new items. Obviously you cannot really create new Items but you can give every existing item a buch of new functions.
So, how do I use this?
First you should add the .jar-file of this API as a plugin to your server. This is needed so your plugin, extending CustomItemsAPI will work.
Now you can add this API to your project's build path just like you added your spigot/bukkit file before.
Dont forget to depend CustomItemsAPI in your plugin.yml using
depend: CustomItemsAPI
That's it! Now you can start coding!
Fine, but how do I create new items now?
Creating a new CustomItem is quite simple:
CustomItem item = new CustomItem(Material.STICK);
This just creates a simple stick which can actually do nothing.
Let's add some listeners to it:
item.setItemCollectListener((ItemCollectEventArgs args); { args.getPlayer().sendMessage("You just collected an awesome item!"); }); item.setItemEntityBeatListener((ItemEntityBeatEventArgs args); { args.getEntity().damage(42); });
If you collect our cool new item now, you will get a message. If you hit a monster, a player or any other living creature with it, that creature will get 42 damage!
But...
To make it working you need to register this item:
item.register();
This finds automatically a unique and unused ID and registeres the item.
What if I have more questions?
There will be a wikia-page soon...
Everybody is allowed to use this API as a dependency for his/her own plugins.
I have gotten an error on this statement of code:
item.setItemCollectListener((ItemCollectEventArgs args); {
args.getPlayer().sendMessage("You just collected an awesome item!"); });
item.setItemEntityBeatListener((ItemEntityBeatEventArgs args); {
args.getEntity().damage(42);
});
This will continue with an error.
I will try to fix this with the quick-fix in eclipse but more errors are appearing.