Filled [Request] =HealthDonor= Share your Health!

Discussion in 'Archived: Plugin Requests' started by Frostbreath, Sep 6, 2013.

  1. Offline

    Frostbreath

    I've done plenty of searching and I couldn't find any plugin that did this, so... Here we go!

    Plugin category: FUN(?)

    Suggested name: HealthDonor

    What I want: This plugin allows players to donate/transfer (a portion of) their health to another player. It can be especially useful with the natural regen off!

    Ideas for variations:
    - Health Penalties (configurable): When Player A donates, let's say, 4 hearts to Player B, B will only recieve 2 hearts (50%).
    - Certain item required to donate health to someone else (configurable)?

    Ideas for commands:
    /hdonor <amount of hearts> <player to donate to>
    Example: /hdonor 4 Frostbreath
    This will substract 4 hearts from the player using the command and give it to Frostbreath.

    Ideas for permissions:
    hdonor.transfer or something to allow players to use the health transfer commands
    hdonor.noitem to allow players to transfer health without the item set in the config (if any item was set!)

    When I'd like it by: Doesn't really matter. Within a month would be awesome though!
     
  2. Offline

    Sweatyyyy

    Frostbreath
    What do you mean by:
    They have to have an item in their inventory to use the command? And when they use the command the item dissapears?
     
  3. Offline

    Frostbreath

    Yes. Let's say they need a Blaze Rod to transfer health or something. The item disappearing could also be an option.
     
  4. Offline

    Sweatyyyy

    Frostbreath
    Plugin: https://www.dropbox.com/s/ezctvjx8lvut8wb/HealthDonor.jar
    Commands: /hdonor OR /healthd
    Permissions: hdonor.transfer
    Usage: /hdonor <amount of hearts> <player>
    Note: In "amount of hearts" 1 is equal to half a heart.
    Sorry I couldn't do the other features, if you REALLY need them desperately I can try, but I'm not sure if I could do them :p
     
  5. Offline

    Frostbreath

    Wow... That's so awesome! The item-only-transfer feature is not a top priority, so if you ever get to finish it, it'd be awesome. I'll use it right now and spread the word!
     
  6. Offline

    Sweatyyyy

    Frostbreath
    No Problem :) I will try to add the Item feature

    Also, tell me if you find any problems, or want anything modified (E.g the messages)
     
  7. Offline

    Frostbreath

    Bug: Transferring health doesn't give the other player health, but substracts it. :p
     
  8. Offline

    Sweatyyyy

    Frostbreath
    I just tested it and it gives the other player health :L
     
  9. Offline

    Frostbreath

    It may actually be a conflict with the UltraHardcore plugin. When I have that plugin, HealthDonor doesn't work properly for some reason...

    EDIT: It's with dev 36 of the UltraHardcore plugin of Ghowden (Not version 2.4.1!)

    EDIT 2: Same for MoreHearts.
     
  10. Offline

    Sweatyyyy

    Frostbreath
    I just tried the plugin with UTC and it still seems to work
     
  11. Offline

    Frostbreath

    Sweatyyyy

    It's so strange... Sometimes it just doesn't give hearts, it just takes away from both donator and reciever. Is it my server? >_<
     
  12. Offline

    Sweatyyyy

  13. Offline

    Frostbreath

    EDIT: It seems the plugin is not working properly yet. Sweaty and me have done a lot of testing and here's the issues:
    When donating health:
    - It substracts the amount of health from the donator and adds it to the reciever (this is what it should do)
    - It substracts the amount of health from the donator but also substracts the same amount from the reciever (not supposed to happen)
    - It substracts the amount of health from the donator and adds only a prt of it to the reciever (it shouldn't do so by default)
    - It substracts the amount of health from the donator and gives nothing to the reciever (wut, no D:)

    Anyone else can help us out? Sweaty sent me the code:
    http://pastebin.com/U270CgEQ

    Much appreciated!
     
  14. Offline

    JRL1004

    I'll do this. It seems simple and the concept is fairly straightforward. I will use my own code to make this as well so it will be easier for me to correct any unplanned bugs.
     
  15. Offline

    GeekyCompz

    I have spent all day coding this plugin, and I think I got exactly what you want, however I did not add in the penalty. It does support ITEM required and the option to remove the item after each use. I disabled donating to yourself due to a health glitch that allows you to infinitely gain health. It does not allow you to donate more than 19 hearts otherwise you die, also an option to enable the MAX number of hearts someone can donate and also the ability to not donate more than enough hearts to a player, example: target is on 18hearts and you donate 6half hearts, that would make them at 21 hearts, so it will STOP the donation and tell the donor that he is on 18/20 health. :D However I have not been able to test this thoroughly due to it only being me on the server so no one to donate to. So can you please test this for me :D. I think the part where it removes the item after each use, might fail. By the way if you have the item required set to true, the person MUST BE HOLDING the item.
    Download: https://dl.dropboxusercontent.com/u/66037398/HealthDonor.jar
     
  16. Offline

    Frostbreath

    I'm gonna test it right away! You're awesome, thanks so much! Will update this post when I'm done.
    Also a big thanks to everyone so willing to help this plugin become a reality! :D

    EDIT: I've etsted this plugin with a friend and we found the following things working fine:
    - Donating with the command works like a charm!
    - Donating over max health is indeed not possible!
    - You cannot give more than your own health!

    These were the issues:
    - Setting an item to be required to donate does not seem to work (unless reloading is the cause).
    - You cannot heal a player over 9.5 hearts for some reason.
    - It seems there are no permissions, or at least not to allow regular players to donate (hdonor.transfer or healthdonor.transfer won't work, healthdonor.* does work, but it also enables the suicide :p). So far, only Operators can use the command.
     
  17. Offline

    Sweatyyyy

    GeekyCompz
    Hey, could you post your code please? I would like to see what I've done wrong and how you did it
     
  18. Offline

    Slokh

    GeekyCompz and Frostbreath

    The issue with not being able to heal a player over 9.5 hearts is because of this:

    Code:java
    1. if (targetHealth + health >= 20.0D) {
    2. sender.sendMessage("§4[§cHealthDonor§4] §7The player '" + targetplayer.getName() + "' cannot obtain that much health. §2(Health = " + targetHealth + "/20.0).");
    3. return false;
    4. }

    You made it so a person cannot be healed to 20 Hearts. At least that is what I think the issue is.
    I think it should be
    Code:java
    1. if (targetHealth + health > 20.0D) {
    2. }
     
  19. Offline

    GeekyCompz

    Slokh I will change it so it so that it will be that.
    Frostbreath The required item works for me... If I am not HOLDING the item it will alert me to hold the ID, (reload must happen, if config changed whilst open). Also the permissions were different sorry. "healthdonor.donate" and "healthdonor.*", I spend some time from now adding the bypass permission for the item and also fixing the problem about getting someone to 20/20 health. :D
    Sweatyyyy I started my code nice and neat, but then I ran into errors with the positioning so I just cut and paste the code into the right spots. Therefore the code may be VERY MESSY. (lol) http://pastebin.com/6RghCC1q (this is before the fixes)

    ~Geeky

    Now I haven't been able to test the REMOVE-ITEM after donation, but I think I solved it all. Heres the file and permissions :D Also the command has aliases: /healthd, /hdonor, /healthdonor.

    PERMISSIONS:
    - healthdonor.* = ALL commands below
    - healthdonor.donate = /healthdonor <1-19> <player>
    - healhtdonor.bypassitem = No need for the required item if set to TRUE
    - healthdonor.bypassremoveitem = Doesn't remove the item after each use

    FILE:
    Dropbox Download: https://dl.dropboxusercontent.com/u/66037398/HealthDonor 1.1.jar

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

    Frostbreath

    GeekyCompz
    Permissions work, item works and you can now heal fully to 20 health! There is a small error when the plugin attempts to remove an item after command usage though:
    Show Spoiler
    2013-09-08 10:41:45 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'hdonor' in plugin HealthDonor v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:191)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.java:523)
    at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerConnection.java:962)
    at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.java:880)
    at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java:837)
    at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
    at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296)
    at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java:116)
    at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
    at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:30)
    at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:590)
    at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
    at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
    at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
    at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    Caused by: java.lang.ArrayIndexOutOfBoundsException


    I also announced this plugin yesterday to the UHC Reddit community, and they were excited and immediatly started to give some suggestions. I don't mind if you take your time with them or don't want to do it, but here they are nonetheless:
    - Compatibility with MoreHearts (so healing over 20 health is possible)?
    - "Perhaps you could have an option to set a certain distance the receiver needs to be to transfer hearts?
    Example:
    A wants to heal B but B needs to be within 32 blocks from A for A to be able to transfer hearts to B."(Configurable?)
    - "For ease of transfer, I would recommend some kind of right-click action to trigger the transfer, rather than having to type out a command. Hold down RMB to slowly transfer health etc." (Best to do with an item in hand only and optional?)
     
  21. Offline

    GeekyCompz

    Frostbreath Were you holding only one of the item when you went to share the health? Because my coding basically removes 1 item from the players HAND. I'll change it up so that it checks if the player has more than 1 first, then -1. Otherwise just remove the entire item from the players hand.

    Oh and sure, I can attempt to get the distance suggestion in. However the right-click action is possible but would require some way of how many hearts to donate, maybe half a heart every right-click with the item. (would make that configurable, but first I will fix the removing item problem first).

    ~Geeky
     
  22. Offline

    Frostbreath

    GeekyCompz
    Yes, I was holden the item and it gave the error when attempting to use the command.
    Thanks for trying to add some of the suggestions. Did you also see the MoreHearts compatibility? I'm not sure if it was very clear in my message that it was another suggestion.
     
  23. Offline

    GeekyCompz

    Frostbreath Yes, I saw the more hearts suggestion, however this would be very strange to add in the plugin. I think just eating the golden apple, will be good enough for the extra health. Now I did add some extra components and fixed stuff.
    - Solved removing item after each use. (1)
    - Added a PING SOUND to both donor and target on the donation.
    - Added the option to enable/disable the range between a donation.
    - And also added a configurable maximum range between donations.
    Now the right-click action would take longer to donate the health you want to donate. (is possible though), I probably won't add this feature in, sorry. I'll send you the next update of the plugin, as soon as I test the range between donations work.
    ~ Geeky
     
  24. Offline

    Frostbreath

    GeekyCompz
    Cheers! I don't really mind the right-click feature, I'm already happy the max distance feature is in. Thanks!
     
  25. Offline

    GeekyCompz

  26. Offline

    Frostbreath

    GeekyCompz
    Very awesome! I'll download it as soon as the link becomes available there. I think this topic can be locked now, so if any moderator sees this message: go ahead! :D
     
  27. Offline

    timtower Administrator Administrator Moderator

    Frostbreath Just mark the thread as filled, top right corner, thread tools, edit thread
     
  28. Offline

    Frostbreath

    timtower likes this.

Share This Page