9
0
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:
Auxilor
2021-03-13 14:42:52 +00:00
parent ddd567ee6f
commit ee6cbafd79
5 changed files with 39 additions and 8 deletions

View File

@@ -33,6 +33,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@@ -230,6 +231,12 @@ public class EcoBoss extends PluginDependent {
@Getter @Getter
private final Map<Integer, List<Pair<Double, String>>> topDamagerCommands; private final Map<Integer, List<Pair<Double, String>>> topDamagerCommands;
/**
* Incoming damage multipliers.
*/
@Getter
private final Map<EntityDamageEvent.DamageCause, Double> incomingMultipliers;
/** /**
* Create a new Boss. * Create a new Boss.
* *
@@ -303,6 +310,15 @@ public class EcoBoss extends PluginDependent {
this.getConfig().getBool("defence.immunities.explosion") 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 // Effects
this.effects = new HashSet<>(); this.effects = new HashSet<>();
for (String string : this.getConfig().getStrings("attacks.potion-effects")) { for (String string : this.getConfig().getStrings("attacks.potion-effects")) {

View File

@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class AttackListeners extends PluginDependent implements Listener { 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. * @param event The event to listen for.
*/ */
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void defenceListener(@NotNull final EntityDamageEvent event) { public void defenceListener(@NotNull final EntityDamageEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) { if (!(event.getEntity() instanceof LivingEntity)) {
return; 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)) { if (immunities.isImmuneToFire() && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
event.setCancelled(true); event.setCancelled(true);
} }
if (immunities.isImmuneToSuffocation() && event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) { if (immunities.isImmuneToSuffocation() && event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) {
event.setCancelled(true); event.setCancelled(true);
} }
if (immunities.isImmuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) { if (immunities.isImmuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
event.setCancelled(true); event.setCancelled(true);
} }
if (immunities.isImmuneToExplosions() && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) { if (immunities.isImmuneToExplosions() && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
event.setCancelled(true); event.setCancelled(true);
} }
if (immunities.isImmuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) { if (immunities.isImmuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) {
event.setCancelled(true); 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 (boss.isTeleportationEnabled()) {
if (NumberUtils.randFloat(0, 100) < boss.getTeleportOptions().getChance()) { if (NumberUtils.randFloat(0, 100) < boss.getTeleportOptions().getChance()) {
int range = boss.getTeleportOptions().getRange(); int range = boss.getTeleportOptions().getRange();

View File

@@ -62,6 +62,10 @@ defence:
projectiles: false projectiles: false
suffocation: true suffocation: true
incoming-multipliers:
melee: 1
projectile: 0.6
# If the boss should teleport when damaged # If the boss should teleport when damaged
teleport: teleport:
enabled: true enabled: true

View File

@@ -56,12 +56,16 @@ broadcast:
defence: defence:
immunities: immunities:
explosion: true explosion: false
fire: true fire: false
drowning: true drowning: true
projectiles: true projectiles: true
suffocation: true suffocation: true
incoming-multipliers:
melee: 0.8
projectile: 0.2
# If the boss should teleport when damaged # If the boss should teleport when damaged
teleport: teleport:
enabled: false enabled: false

View File

@@ -59,9 +59,13 @@ defence:
explosion: true explosion: true
fire: true fire: true
drowning: true drowning: true
projectiles: true projectiles: false
suffocation: true suffocation: true
incoming-multipliers:
melee: 0.6
projectile: 0.3
# If the boss should teleport when damaged # If the boss should teleport when damaged
teleport: teleport:
enabled: false enabled: false