Check if a helmet is broken and find out if a player is in a region

Discussion in 'Plugin Development' started by Zero9195, Jul 21, 2011.

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


    Hi Guys,
    I know this Question seems stupid, but I really need this. I made a plugin which damages a helmet the hole time a player wears it.
    1. Stupid thing is, that this
    helmet.setDurability(helmet.getDurability() - 10);
    will INCREASE the durability of the helmet. I thought "ok, change it to a plus" and it worked. But now, if the durability is "0" (i don't know i it's really 0). The item does not disappear, it just is there in the slot with negative durability. Then I wanted to check if the durability is 0, but it deleted the helmt all the time I waer it. So I'm asking, is there any way I can check if the helmet is broken? Or some other methods you use to decrease durability of an item? Thanks for helping ;)

    I just remembered the other Issue I have. I want to create a region (via a given radius) and then check if the player is in this region. I don't knwo how to do this, so can anyone please drop a bit of code to show me? Thanks you all for helping :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 17, 2016
  2. Offline


    Use extras, It has a region event in which you can do all this region creating shinanigans with lol.
    And as for the helmet durability, instead of deducting from it, just try and set it at certain variables E.g 0.
  3. Offline


    Thanks for the help, but what is extras? I don't know what you mean.
  4. Offline


    Radius checking ? Did you ever heard the name Pythagoras ?
  5. Offline


    Durability works the other way round.
    When something has full durability, its data is 0, and it increases as it gets "damaged".
    To check if the item is about to break, Material has the method getMaxDurability(). So you'd go something like
    if(helmet.getDurability() >= helmet.getType().getMaxDurability())
  6. Offline


    Extras is a library I made for plugin developers :D
    It has functions you can hook into which'll help you check if a player is a cuboid, radius etc. Check it out here :
Thread Status:
Not open for further replies.

Share This Page