ItemRepair Plugin: All, but the held Item is getting repaired

Discussion in 'Plugin Development' started by VoLLi, Dec 8, 2011.

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

    VoLLi

    We're working on a ItemRepair plugin which has 3 different blocks to repair your stuff for Iconomy currency.
    - Iron Block --> repairs a single item
    - Gold Block --> repairs all items
    - Diamond Block --> repairs a single item for a cheaper price with a chance to break it

    Source available @ GitHub

    The problem atm is that it doesn't repair the item held in the active slot. We couldn't figure out yet, whats going wrong there.
    Any help would be appreciated.
     
  2. Offline

    Ninjokin

    @VoLLi What class is that code in?
     
  3. Offline

    VoLLi

  4. Offline

    Ninjokin

    @VoLLi Does it repair all items in the inventory or does it not repair anything.

    If it doesn't repair anything, where the repair code is, just put player.sendMessage("REPAIR CODE -- WORKING"); and replace player with your player variable. If that works its your repair code.

    Sorry if it doesn't make much sense...
     
  5. Offline

    VoLLi

    @Ninjokin: for the Gold block it does repair all except the active item slot, for the other 2 blocks it doesn't repair at all since it fails for the active item slot...
     
  6. Offline

    CptSausage

    Does the player get any of your error messages?
     
  7. Offline

    VoLLi

    Player gets "sucessfully repaired" message as intended.
     
  8. Offline

    Quick_Wango

    Hi, I'm the main developer of the plugin.

    Here is how the plugin basicly works:
    1. player rightclicks a repair block (eg a gold block to repair all items)
    2. onPlayerInteract (ItemRepairPlayerListener.java) calls the requestRepair method of the repair block (eg RepairBlocks/CompleteRepair.java)
    3. requestRepair collects the items to repair, calculates the price and returns a RepairRequest (RepairRequest.java) instance which contains all the data
    4. rightclicks again
    5. onPlayerInteract (ItemRepairPlayerListener.java) calls the repair method of the repair block with the repair request as parameter
    6. repair then checks whether the player has enough money and repairs the items stored as a ArrayList in the request
    The problem is:
    when I rightclick a gold block with a damaged pickaxe, change the item slot and rightclick again, every item except the previously selected pickaxe get repaired

    debug output shows that everything gets executed as it should

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

    Nekpek

    what piece of code is supposed to repair the held item?
     
  10. Offline

    -_Husky_-

    @Quick_Wango
    where you had that, add
    player.getItemInHand().setDurability((short) 0);
    worked for me (replace player with your Player Variable)
     
  11. Offline

    Quick_Wango

  12. Offline

    Quick_Wango

    So I found the problem: The request somehow takes a copy of the held item instead of a reference.

    Does anyone know how to avoid copies?
     
  13. Offline

    Quick_Wango

    Nobody can help? :(

    If I try to repair the items in the first step, everything works fine, but when I do it in the second step, nothing happens.
    I store the RepairRequests inside a HashMap<Player, RepairRequest> to bring them from step to step
     
  14. Offline

    VoLLi

    It's a fail of Bukkit, not your plugin... Keep cool. :)
     
Thread Status:
Not open for further replies.

Share This Page