Solved All unbreakable items

Discussion in 'Spigot Plugin Development' started by ExpDev, May 16, 2017.

  1. Do anyone have an efficient way to make all items on the server unbreakable?

    I thought of listening to the EntityDamageByEntityEvent, loop through booth's inventory and set their items unbreakable if they already aren't (this worked, however it got a bit much?).

    I also tried ItemSpawnEvent, but the event is almost never called (not when new itemstacks are created). Anybody knows any different solution? thanks
  2. When a player open inventory check if all items are unbreakable if not set it unbreakable
  3. Use PlayerItemDamageEvent, set the item to unbreakable and it wont get called again for that item I don't think. So basically it would get called once for each object the first time it started to get damaged. Oh yea cancel the event after you modify the item ;)
  4. On PlayerBreakItemEvent e do e.setCancelled(true).
  5. I, mean could work, but don't wanna depend on inventory being opened.
  6. Create a BukkitRunnable and control all player inventories every 20/40 ticks
  7. W
    Was looking for this event. Tried ItemDamage but my IDE wouldn't show it, nor did any of my searches. Thanks!
  8. Whoa, that's a lot of overhead. You'd be iterating over 30-50 players' 36 inventory slots every second.
    This is much easier and more efficient.
  9. That would rape the server I guess.
  10. Players would see their items get low durability and start repairing them so your code would only fire when they accidentally broke something.