p.setHealth(0.0D); Help

Discussion in 'Plugin Development' started by glasseater, Nov 27, 2014.

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

    glasseater

    Hey,

    So I am creating a plugin where if someone steps on bedrock they will die. It works however, it spams the chat like this: http://gyazo.com/c95bd1cc5b52087864884b9c4d95ebb2
    Here is my code:
    Code:java
    1. else if (b.getType() == (Material.BEDROCK)) {
    2. p.setHealth(0.0D);
    3. Bukkit.broadcastMessage(ChatColor.BLUE + "GLASSEATER" + ChatColor.GRAY + " HAS DIED" + ChatColor.BLUE + "!");
    4. }
    5. return;
    6. }
    7. }
     
  2. Offline

    Dudemister1999

    glasseater Try adding a health check. Check if his health is greater than 0, if not then kill & broadcast. Because PlayerMoveEvent fires about 3-4 times every time you walk across a block. At least, that's from my testings.
     
  3. Offline

    glasseater

    Dudemister1999 Almost worked. Now its only broadcasting the message 3-4 times.
     
  4. Offline

    Skionz

    glasseater Only execute your code if the player moves an entire block.
     
  5. Offline

    glasseater

    Skionz But I would want it so it kills them the second they walk on it... Would that cause problems?
     
  6. Offline

    Skionz

    glasseater I would use a scheduler. Personally I never use the PlayerMoveEvent just because of performance issues as it is called every time your yaw or pitch changes.
     
  7. Offline

    glasseater

    Skionz I will have to do some more research. I am not to familiar with them. Any resources recommended?
     
  8. Offline

    mythbusterma

  9. Offline

    Skionz

Thread Status:
Not open for further replies.

Share This Page