Add McMMOEntityDamageByRuptureEvent (#4498)

This commit is contained in:
lexikiq
2021-04-20 17:51:57 -04:00
committed by GitHub
parent 394e9e5110
commit 6d0fe4fb58
4 changed files with 49 additions and 17 deletions

View File

@@ -1,9 +1,9 @@
package com.gmail.nossr50.events.fake;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
import java.util.EnumMap;
import java.util.Map;
@@ -13,21 +13,21 @@ import java.util.Map;
*/
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements FakeEvent {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers) {
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
}
@Deprecated
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage) {
super(damager, damagee, cause, damage);
}
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
@NotNull
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(@NotNull Map<DamageModifier, Double> modifiers) {
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
for (DamageModifier modifier : modifiers.keySet()) {
modifierFunctions.put(modifier, ZERO);
modifierFunctions.put(modifier, (o -> -0.0));
}
return modifierFunctions;

View File

@@ -0,0 +1,23 @@
package com.gmail.nossr50.events.skills.rupture;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.google.common.collect.ImmutableMap;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
import java.util.EnumMap;
public class McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent {
private final McMMOPlayer mcMMODamager;
public McMMOEntityDamageByRuptureEvent(@NotNull McMMOPlayer damager, @NotNull Entity damagee, double damage) {
super(damager.getPlayer(), damagee, DamageCause.CUSTOM, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, (o -> -0.0))));
this.mcMMODamager = damager;
}
@NotNull
public McMMOPlayer getMcMMODamager() {
return mcMMODamager;
}
}