Multible Questions - Help with Doctor who style regeneration.

Discussion in 'Plugin Development' started by trg601, Sep 16, 2013.

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

    trg601

    All of these questions have to do with the same plugin.
    Well here is question #1:
    Is there a way to cancel death event? more like set their health to maximum right before they die.
    Well here is question #2:
    I am going to use tagApi to make the player change appearance and name (on command determining the player) But how do I make there name appear different when they chat?

    As for special effects and stuff I don't really need much help,
    Thanks for reading this :D
     
  2. Offline

    chasechocolate

    1: You can't cancel PlayerDeathEvent, but you could use EntityDamageByEntityEvent and check if they will die with the damage taken, or send a respawn packet.

    2: player.setDisplayName().
     
  3. Offline

    The_Doctor_123

    I might be of some assistance.

    Code:java
    1. @EventHandler
    2. public void onEntityDamage(EntityDamageEvent event)
    3. {
    4. if (event.getEntity() instanceof Player)
    5. {
    6. Player player = (Player) event.getEntity();
    7. if (player.getHealth() <= event.getDamage())
    8. {
    9. event.setCancelled(true);
    10. player.setHealth(player.getMaxHealth());
    11. // Other special effects like explosions and junk if you'd like
    12. }
    13. }
    14. }
     
  4. Offline

    trg601

    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page