Heal Player on Health Scale, help?

Discussion in 'Plugin Development' started by Nachoman44, Mar 12, 2014.

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

    Nachoman44

    Whats happening is i've got users on a 40.0 health scale, and when they right click an iron_hoe i'm wanting it to heal them 2 hearts but it keeps throwing an error "Health must be between 0 and 20.0", so how do i successfully heal a player a certain amount thats on a health scale?
    here's the code i'm executing:
    Code:
    if (h == Material.IRON_HOE){
                    if (p.getHealthScale() == 40.0){
                        if (p.getHealth() < 35.0){
                            p.setHealth(p.getHealth() + 4.0);
                            return;
                        }
                        p.setHealth(p.getHealthScale());
                    }
                }
    Here's the error it's throwing:
    Code:
    [16:20:29 ERROR]: Could not pass event PlayerInteractEvent to NachoPlugs v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:195) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:165) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:604) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.a(SourceFile:60) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.handle(SourceFile:9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
    Caused by: java.lang.IllegalArgumentException: Health must be between 0 and 20.0
        at org.bukkit.craftbukkit.v1_7_R1.entity.CraftLivingEntity.setHealth(CraftLivingEntity.java:81) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        at nachoPlugs.plugs.nachoPlugsListeners.onPlayerInteract(nachoPlugsListeners.java:122) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3023jnks]
        ... 15 more
    >
    
    Any help appreciated!
     
  2. Offline

    Mathias Eklund

    health must be between 0 and 20.
     
  3. Offline

    Nachoman44

    I figured... but I need the player to be healed even if it's higher than 20..
     
  4. Offline

    Mathias Eklund

    Nachoman44 Well, I don't see how thats gonna work if maximum health is 20.
     
  5. Offline

    Nachoman44

    So what do you recommend I do for a solution? is there another way I can create this ?
     
  6. Offline

    Mathias Eklund

    Nachoman44 I'm not really 100% on what it is you are trying to accomplish with this. So sadly I can't answer that question.
     
  7. Offline

    Nachoman44

    A player has a health scale of 40.0 right? if they use it when their health is less than 35.0 then heal them for 2 hearts... surely this is manageable?
     
  8. Offline

    Mathias Eklund

    They can't have 35 health.
     
  9. Offline

    bennie3211

    Nachoman44 the max of healt is just 20, or you have to set the maxhealth of a player, but i don't know if you did. Each heart is 2 health, so if you set it to 20, you will have 10 hearts.
     
Thread Status:
Not open for further replies.

Share This Page