Hello everyone, my name is Poprit. I've been coding for a little over three years, and this is my first post on bukkit. I replied to a comment on an API called "GunsAPI." The OP of the comment was asking how to create gun 'clips' or 'magazines.' I told him ITEM DURABILITY. It's extremely simple and easy to use. I'm going to not be providing a full tutorial but, a mini one with a few methods. For a better idea on how to use these methods you can view my comment here. Methods Code: ItemStack is = e.getItem(); int uses = is.getDurability(); int full = 20; if(uses == 0) { // yay! Time to reload. if(e.getPlayer().getInventory.contains(Your ammo itemstack) { e.getPlayer.getInventory.remove(Your ammo itemstack); is.setDurability((short) 20); // send reloaded message } return; }else if(uses > 20) is.setDurability((short) 20); // Shoot code return; }else { // Shoot code return; } That is my first tutorial with some rough methods. Remember to view my comment to see how to use them! Sincerely - Poprit EDIT: You will have to put this in an interactevent and check if it's your item.
You should really format your code if you make a tutorial. And maybe correct it too. You don't tell the reader, to substract 1 from the current durability either. This tutorial is not usable.