Solved EntityDamageEvent?

Discussion in 'Spigot Plugin Development' started by Heretere, May 21, 2016.

  1. Hey, I am trying to figure out how to call the non-deprecated version of the EntityDamageEvent Event but I can't seem to figure out how to do it. Could someone he me out? (I don't want to call the deprecated version of EntityDamageEvent)
     
  2. Why do you want to call the event? Usually you listen to an event.

    About your question: Use the non-deprectated constructor.
     
  3. I am implementing nofall detection into my plugin and after they get caught I want to force the fall damage on them. I need to call the event so plugins that listen for PlayerDamageEvent can catch it.
     
  4. Here you can find out how to use the constructor. Take a look at the second (deprecated) constructor:
    Code (Java):
        @Deprecated
        public EntityDamageEvent(final Entity damagee, final DamageCause cause, final double damage) {
            this(damagee, cause, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, ZERO)));
        }
    You can do the same:
    Code (Java):
            new EntityDamageEvent(damagee, cause, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, ZERO)));
    And replace ZERO with Functions.constant(-0.0).
     
    • Informative Informative x 1