mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	mcMMO will no longer use the DamageModifier API (potentially fix immortal player bug)
This commit is contained in:
		@@ -1,35 +1,14 @@
 | 
			
		||||
package com.gmail.nossr50.events.fake;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Function;
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.EnumMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Called when mcMMO applies damage from an entity due to special abilities.
 | 
			
		||||
 */
 | 
			
		||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements FakeEvent {
 | 
			
		||||
 | 
			
		||||
    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(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage) {
 | 
			
		||||
        super(damager, damagee, cause, damage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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);
 | 
			
		||||
 | 
			
		||||
        for (DamageModifier modifier : modifiers.keySet()) {
 | 
			
		||||
            modifierFunctions.put(modifier, (o -> -0.0));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return modifierFunctions;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,35 +1,14 @@
 | 
			
		||||
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.EntityDamageEvent;
 | 
			
		||||
 | 
			
		||||
import java.util.EnumMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Called when mcMMO applies damage due to special abilities.
 | 
			
		||||
 */
 | 
			
		||||
public class FakeEntityDamageEvent extends EntityDamageEvent implements FakeEvent {
 | 
			
		||||
 | 
			
		||||
    public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
 | 
			
		||||
        super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
 | 
			
		||||
        super(damagee, cause, damage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return modifierFunctions;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,15 @@
 | 
			
		||||
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))));
 | 
			
		||||
		super(damager.getPlayer(), damagee, DamageCause.CUSTOM, damage);
 | 
			
		||||
		this.mcMMODamager = damager;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user