Fall Damage Event

Discussion in 'Plugin Development' started by stantheman68, Oct 13, 2012.

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

    stantheman68

    Hi,

    I'm wanting to change the fall damage where if the player has a certain permission node they will have a less fall damage then a player with the other permission node. This is what I have so far,
    Code:
    package me.stantheman68.sanctumcraft;
     
    import org.bukkit.entity.Entity;
    import org.bukkit.event.Cancellable;
    import org.bukkit.event.HandlerList;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityEvent;
     
    public class EntityDamageEvent<FALL> extends EntityEvent implements Cancellable, Listener {
    public static Main plugin;
    public int damage;
    public boolean cancelled;
    @SuppressWarnings("unused")
    private final DamageCause cause;
    @SuppressWarnings("unused")
    private static final HandlerList handlers = new HandlerList();
    public EntityDamageEvent(final Entity damagee, final DamageCause cause, final int damage) {
    super(damagee);
    this.cause = cause;
    this.damage = damage;
    }
     
    public boolean isCancelled() {
           return isCancelled();
       }
     
       public void setCancelled(boolean cancel) {
       }
     
       public int getDamage() {
           return getDamage();
       }
     
       public void setDamage(int damage) {
       }
     
       public DamageCause getCause() {
           return getCause();
       }
     
       public HandlerList getHandlers() {
           return getHandlers();
       }
     
       public HandlerList getHandlerList() {
           return getHandlers();
       }
     
       public enum DamageCause {
       }
                <p >
                void Damage (FALL; height - 3.0);
       FALL,
     
       }
    }
    Can you please tell me what I am doing wrong or how to continue my plugin?
    Thank You for you're time.
     
  2. Offline

    Tirelessly

  3. Offline

    stantheman68

    I have read it and it did not help. Instead of link's maybe you can explain a little to me.

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  4. Offline

    Tirelessly

    It is clearly documented there. If you can't understand that, anything I say won't help.
     
  5. Offline

    stantheman68

    May you please point me into the certain direction / code? I am still new to java.
     
  6. Offline

    Woobie

    Here's what i used
    Code:
    @EventHandler(priority = EventPriority.HIGHEST)
        public void onEntityDamageEvent(final EntityDamageEvent e) {
            if (!(e.getEntity() instanceof Player)) {
                return;
            }
            Player p = (Player) e.getEntity();
            if (e.getCause() == DamageCause.FALL) {
                    //do something here
     
    GrandmaJam and stantheman68 like this.
  7. Offline

    stantheman68

    Thanks!
     
  8. Offline

    TheRatCoder

    How would you cancel fall damage could I use this?
     
  9. Offline

    dsouzamatt

    @TheRatCoder After determining that the cause of the damage is falling, cancel the event.
     
  10. Offline

    TheRatCoder

    doesn't work

    nvm I'm so stupid
     
    Last edited by a moderator: Jan 13, 2015
  11. Offline

    dsouzamatt

    @TheRatCoder Really? Can you show me your code and a stacktrace?

    (btw, don't forget to tahg me in future)
     
  12. Offline

    iReD_xBlaDeZ

    @TheRatCoder
    Code:
    @EventHandler
    public void onCancelFallDamage(EntityDamageEvent e) {
        if(e.getEntity() instanceof Player) { //Checks to see if the entity that is taking damage is a player
            if(e.getCause() == DamageCause.FALL) { //if the cause of damage is fall damage
                e.setCancelled(true); //you cancel the event.
            }
        }
        }
     
    GrandmaJam likes this.
  13. Offline

    eyamaz

    sigh.

    Thread locked 4 Necro.
     
    ZodiacTheories likes this.
Thread Status:
Not open for further replies.

Share This Page