I am trying to create a KillerHealth plugin.

Discussion in 'Plugin Development' started by MCraftGamer35, Aug 22, 2014.

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

    MCraftGamer35

    So, I am creating a killer health plugin, and everything works, except on playerdeath, in the chat it says there health was "0.0" rather than there real health. Here is my code.

    package me.Alex.FrostHealth;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class FrostHealth extends JavaPlugin implements Listener {

    public void onEnable(){
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerKill(PlayerDeathEvent e) {
    Player p = e.getEntity();
    p.sendMessage("§aYour killers health was §7" + p.getHealth() + "§a." + "\n§aYou were killed by " + p.getDisplayName() + "§a.");
    }
    }
     
  2. Offline

    Forseth11

    You are messaging the player their own information. Create a player killer and then get their health and name and send it to the person who died.
     
  3. Offline

    MCraftGamer35

    Ok, now it says, 3.299959259 health, how can I make it so it would round the number, to lets say, 3.29. Thanks
    Forseth11
     
  4. Offline

    Forseth11

    I am on my phone and can't explain that atm. Just cast it to an int and it will go from that double to 3.
     
  5. Offline

    MCraftGamer35

    But, I am kinda a noob, I really haven't gotten into doubles and ints yet, the most advanced plugin I coded was a kit plugin, with events, etc. Forseth11
     
  6. Offline

    Konkz

    Learn Java first, these are basics of Java.
     
  7. Offline

    stoneminer02

    1. Learn java a bit.
    2. Try to put it in [ syntax=java ] Code [ /syntax ].
    Remove the spaces inside the [ & ].
     
Thread Status:
Not open for further replies.

Share This Page