Hooking after item in hand gets damaged

Discussion in 'Plugin Development' started by bitfreeze, Dec 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    bitfreeze

    Hello!
    I'm writing a plugin that requires to know what's the damage value on the tool/weapon in hand after it gets damaged by its use.
    Searched trough the CraftBukkit code but found only events related to player hitting something or interacting with another entity or block, no event call after the item durability value is updated.
    Any clues?
     
  2. Offline

    ItsHarry

    Can't you just -1 the damage? o-o
     
  3. Offline

    Taco

    item.getDamage()-event.getDamage() ?
     
  4. Don't think it's possible other than saving the tool when the player switches (track via onPlayerItemHeld) and when the player breaks a block (track via onBlockBreak).

    Or you will have to used scheduled tasks.
     
  5. Offline

    bitfreeze

    Hey mates, thanks for the replies!

    @ItsHarry:
    Some improper actions, like Sword against a Block (not against a living creature), apply 2 damage points to the item. Anyways, that could be treated and the damage count of my routine be reduced accordingly, foreseeing the correct damage that would be applied. However, we can guarantee no more that the action will actually cause damage to the item, now that enchanted items have a random chance not to cause damage at all. That's the main issue.
    @Taco:
    BlockBreakEvent event does not have a getDamage() method, I guess. And I found no call to events after the tool is damaged by the routine, in the source code of CraftBukkit.

    @Pandemoneus:
    Sadly, that must be the only current way to solve my problem. Thank you for the suggestion :) If I have the patience to do that workaround, your name shall be mentioned on the credits.
     
Thread Status:
Not open for further replies.

Share This Page