Problem With Armor Durability

Discussion in 'Plugin Development' started by GoldenWrapper, Jul 29, 2013.

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

    GoldenWrapper

    Currently, someone is helping me with a plugin with setting leather armor to the same as durability and strength as diamond armor. I have strength, but we've come to a problem with armor durability.
    With this code, it checks for every time the armor is put on. So that means the user could just reapply the armor and have full durability again. How could we work around this?
    Code:
     @EventHandler
    public void onInvClick(InventoryClickEvent ice){
      ItemStack helmet = ice.getInventory().getItem(39);
     
      if(helmet.getType() == Material.LEATHER_HELMET){
      helmet.setDurability((short) 363);
      }
     
  2. Offline

    xxMOxMOxx

    Try setting it so that the durability is set upon crafting
     
  3. Offline

    GoldenWrapper

    I'm planning to give it to them in kits, sorry I forgot to add this.
     
  4. Offline

    xxMOxMOxx

    GoldenWrapper
    Are the kits in a config file? Set the item in kit to be {Leather armor ID}:durability
     
  5. Offline

    GoldenWrapper

    Is this possible with CobraKits?


    Code:
          type: LEATHER_CHESTPLATE
          meta:
            ==: ItemMeta
            meta-type: LEATHER_ARMOR
            display-name: Member
            enchants:
              PROTECTION_ENVIRONMENTAL: 7
              PROTECTION_EXPLOSIONS: 3
            repair-cost: 2
            color:
              ==: Color
              RED: 229
              BLUE: 51
              GREEN: 229
     
  6. Offline

    xxMOxMOxx

    Not sure if its possible as I've never used it, but try setting line 1 to
    Code:
    type: LEATHER_CHESTPLATE:363
    Edit: Idea - If that doesn't work, change the event listener in your plugin to a command listener so it changes the durability when the command to obtain the kit is run
     
  7. Offline

    GoldenWrapper

    There's actually a damage option you can add, but it can't go negative (instead of 363 it's -363 in the damage category, positive would mean it would have damage). And good idea on the edit, but I'm not sure it would work with kit signs, since the signs don't issue a command.

    I can't do the command, because the base command is /kit name. so if I had
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            if (sender instanceof Player){
                Player player = (Player) sender;
                if(cmd.getName().equalsIgnoreCase("kit")){
    Then they could just keep running /kit.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  8. Offline

    xxMOxMOxx

    GoldenWrapper You could try adding metadata to the armor after increasing durability and then check that something like "increasedDurability" metadata does not exist before increasing
     
  9. Offline

    GoldenWrapper

    Dang, how would I go about doing this? I started this because I'm new to bukkit, so I thought it would be a simple little plugin :$
     
  10. Offline

    xxMOxMOxx

    GoldenWrapper Personally I'm not very good with metadata but if no one can answer your question by tomorrow I'l see if I can help
     
  11. Offline

    GoldenWrapper

    Thanks a lot!
     
Thread Status:
Not open for further replies.

Share This Page