get/setMaxHealth error

Discussion in 'Spigot Plugin Development' started by JakeQuin0113, Apr 18, 2017.

Thread Status:
Not open for further replies.
  1. I haven't touched minecraft, or Java in general in about a year or so., but recently I've decided to "update" my old 1.7 plugins to 1.11, but it seems some of the code are outdated(?) since this used to work.

    Code (Text):
    [06:56:35] [Server thread/ERROR]: Could not pass event CreatureSpawnEvent to 1-11TEST v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callCreatureSpawnEvent(CraftEventFactory.java:283) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.World.addEntity(World.java:1038) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.WorldServer.addEntity(WorldServer.java:1065) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.SpawnerCreature.a(SpawnerCreature.java:188) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.WorldServer.doTick(WorldServer.java:229) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:798) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
    Caused by: java.lang.IllegalArgumentException: Health must be between 0 and 40.0(80.0)
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftLivingEntity.setHealth(CraftLivingEntity.java:99) ~[spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        at me.Scraftyyy.event.Spawner.ZombieHandler(Spawner.java:42) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.11.2.jar:git-Spigot-54ec0b8-ac405c3]
        ... 13 more
    and the line 40 - 47.

    Code (Text):
            if (rand >= 56){
                e.getEntity().setMaxHealth(e.getEntity().getMaxHealth() * 2);
                e.getEntity().setHealth(e.getEntity().getMaxHealth() * 2);
                e.getEntity().setCanPickupItems(true);
                e.getEntity().setCustomName(ChatColor.WHITE + "Lacking Zombie");
                e.getEntity().setCustomNameVisible(true);
                return;
            }
    This is what stood out to me: "java.lang.IllegalArgumentException: Health must be between 0 and 40.0(80.0)" from my point of view (I am most likely wrong) but it states that the min and max hp for a particular mob/monster is now 0-40 (0-80)? or is there another reason why this isn't working?
     
  2. Look at the documentation.
     
Thread Status:
Not open for further replies.