So I've been trying to make bows unbreakable, but it appears that although the server realizes the bow is still at the max durability, the client doesn't. The durability for the client only updates when there is an change in that person's inventory. EX: https://gyazo.com/0fbe3a98a9af26557de5d295c6af2a31 My current code is: Code: @EventHandler public void onItemDamage(PlayerItemDamageEvent e) { if(e.getItem().getType() == Material.BOW) { e.setCancelled(true); } }
maybe try Instanceof not sure how much difference there is btween == and instance but it did solve issues sometimes that ive had
As in the enchantment? Well, I didn't want it to appear enchanted, and since this is global, I still want people to be able to enchant it without an anvil. This works, but is there a quick flash of the durability bar before it switches back. Is it possible to do it without this flash?
@Javlin Perhaps try setting the item's durability? Code: e.getItem().setDurability(e.getItem().getType().getMaxDurability());
@Javlin No Give it the metadata Unbreakable. Unbreakable isn't an enchantment. And then using ItemFlags hide it.
Try without cancelling the event. If that doesn't work, I'd recommend @87pen 's suggestion, although I'm fairly sure hiding the ItemFlag will not hide the glow. Edit: I was thinking about unbreaking too, my bad
@Assist ... It won't glow because unbreakable is not an enchantment. Unbreakable is a metadata This is unbreakable tag, and it can be hidden with ItemFlags. Edit: nvm saw your edit.