mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-22 08:29:20 +00:00
Added incoming multipliers
This commit is contained in:
@@ -33,6 +33,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -230,6 +231,12 @@ public class EcoBoss extends PluginDependent {
|
||||
@Getter
|
||||
private final Map<Integer, List<Pair<Double, String>>> topDamagerCommands;
|
||||
|
||||
/**
|
||||
* Incoming damage multipliers.
|
||||
*/
|
||||
@Getter
|
||||
private final Map<EntityDamageEvent.DamageCause, Double> incomingMultipliers;
|
||||
|
||||
/**
|
||||
* Create a new Boss.
|
||||
*
|
||||
@@ -303,6 +310,15 @@ public class EcoBoss extends PluginDependent {
|
||||
this.getConfig().getBool("defence.immunities.explosion")
|
||||
);
|
||||
|
||||
// Multipliers
|
||||
this.incomingMultipliers = new HashMap<>();
|
||||
double melee = this.getConfig().getDouble("defence.incoming-multipliers.melee");
|
||||
this.incomingMultipliers.put(EntityDamageEvent.DamageCause.ENTITY_ATTACK, melee);
|
||||
this.incomingMultipliers.put(EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK, melee);
|
||||
|
||||
double projectile = this.getConfig().getDouble("defence.incoming-multipliers.projectile");
|
||||
this.incomingMultipliers.put(EntityDamageEvent.DamageCause.PROJECTILE, projectile);
|
||||
|
||||
// Effects
|
||||
this.effects = new HashSet<>();
|
||||
for (String string : this.getConfig().getStrings("attacks.potion-effects")) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AttackListeners extends PluginDependent implements Listener {
|
||||
@@ -157,7 +158,7 @@ public class AttackListeners extends PluginDependent implements Listener {
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||
public void defenceListener(@NotNull final EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
return;
|
||||
@@ -176,23 +177,25 @@ public class AttackListeners extends PluginDependent implements Listener {
|
||||
if (immunities.isImmuneToFire() && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (immunities.isImmuneToSuffocation() && event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (immunities.isImmuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (immunities.isImmuneToExplosions() && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (immunities.isImmuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
for (Map.Entry<EntityDamageEvent.DamageCause, Double> entry : boss.getIncomingMultipliers().entrySet()) {
|
||||
if (event.getCause() == entry.getKey()) {
|
||||
event.setDamage(event.getDamage() * entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (boss.isTeleportationEnabled()) {
|
||||
if (NumberUtils.randFloat(0, 100) < boss.getTeleportOptions().getChance()) {
|
||||
int range = boss.getTeleportOptions().getRange();
|
||||
|
||||
@@ -62,6 +62,10 @@ defence:
|
||||
projectiles: false
|
||||
suffocation: true
|
||||
|
||||
incoming-multipliers:
|
||||
melee: 1
|
||||
projectile: 0.6
|
||||
|
||||
# If the boss should teleport when damaged
|
||||
teleport:
|
||||
enabled: true
|
||||
|
||||
@@ -56,12 +56,16 @@ broadcast:
|
||||
|
||||
defence:
|
||||
immunities:
|
||||
explosion: true
|
||||
fire: true
|
||||
explosion: false
|
||||
fire: false
|
||||
drowning: true
|
||||
projectiles: true
|
||||
suffocation: true
|
||||
|
||||
incoming-multipliers:
|
||||
melee: 0.8
|
||||
projectile: 0.2
|
||||
|
||||
# If the boss should teleport when damaged
|
||||
teleport:
|
||||
enabled: false
|
||||
|
||||
@@ -59,9 +59,13 @@ defence:
|
||||
explosion: true
|
||||
fire: true
|
||||
drowning: true
|
||||
projectiles: true
|
||||
projectiles: false
|
||||
suffocation: true
|
||||
|
||||
incoming-multipliers:
|
||||
melee: 0.6
|
||||
projectile: 0.3
|
||||
|
||||
# If the boss should teleport when damaged
|
||||
teleport:
|
||||
enabled: false
|
||||
|
||||
Reference in New Issue
Block a user