Hold Firework fall damage 3,5

Discussion in 'Plugin Development' started by Killercraftashuhaa, May 2, 2014.

Thread Status:
Not open for further replies.
  1. I need help with a plugin, that when you hold a firework, you get fall damage of 3,5 hearts (7)
     
  2. Offline

    BetrayedQU

    Code:java
    1.  
    2. @EventHander
    3. public void FireWork(EntityDamageEvent event) {
    4. if (event.getPlayer().getItemInHand().getType() == Material.FIREWORK)
    5. {
    6. if(event.getCause() == EntityDamageEvent.DamageCause.FALL)
    7. {
    8. event.setDamage(7);
    9. }
    10. }
    11. }
     
  3. Thank you, I will test this tomorow.
     
  4. Offline

    ZodiacTheories

    BetrayedQU likes this.
  5. I find a error in .getPlayer, I will pass my code:
    Code:java
    1. import java.util.ArrayList;
    2.  
    3. import org.bukkit.Material;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.entity.EntityDamageEvent;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class Main
    10. extends JavaPlugin
    11. implements Listener
    12. {
    13. public void onEnable()
    14. {
    15. System.out.println("NoFall habilitado!");
    16. }
    17.  
    18. public void onDisable()
    19. {
    20. System.out.println("NoFall desligado!");
    21. }
    22.  
    23. @EventHandler
    24. public void FireWork(EntityDamageEvent event) {
    25. if (event.getPlayer().getItemInHand().getType() == Material.FIREWORK)
    26. {
    27. if(event.getCause() == EntityDamageEvent.DamageCause.FALL)
    28. {
    29. event.setDamage(7);
    30. }
    31. }
    32. }
    33. }


    I find a error in: if (event.getPlayer().getItemInHand().getType() == Material.FIREWORK)
     
  6. Offline

    Iroh

    Removed to plugin dev.
     
  7. Offline

    BetrayedQU

  8. Offline

    GaaTavares

    There's no getPlayer() method, though there's getEntity(). You gotta check if the entity is a player, then cast it.
     
  9. Offline

    Niknea

    Just check if they have a firework in hand, then when they take damage cancel the event. And remove 3.5 hearts.
     
Thread Status:
Not open for further replies.

Share This Page