mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-22 00:19:30 +00:00
Added LightningNearbyEntities and began adding effects to default bosses
This commit is contained in:
@@ -2,6 +2,7 @@ package com.willfp.ecobosses.bosses.effects;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.willfp.ecobosses.bosses.effects.effects.DamageNearbyPlayers;
|
||||
import com.willfp.ecobosses.bosses.effects.effects.LightningNearbyEntities;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -17,6 +18,7 @@ public class Effects {
|
||||
*/
|
||||
private static final Map<String, Function<List<String>, Effect>> EFFECTS = new ImmutableMap.Builder<String, Function<List<String>, Effect>>()
|
||||
.put("damage-nearby-players", DamageNearbyPlayers::new)
|
||||
.put("lightning-nearby-entities", LightningNearbyEntities::new)
|
||||
.build();
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.willfp.ecobosses.bosses.effects.effects;
|
||||
|
||||
import com.willfp.eco.util.LightningUtils;
|
||||
import com.willfp.eco.util.NumberUtils;
|
||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LightningNearbyEntities extends Effect {
|
||||
private final int frequency;
|
||||
private final double chance;
|
||||
private final double damage;
|
||||
private final double radius;
|
||||
|
||||
public LightningNearbyEntities(@NotNull final List<String> args) {
|
||||
super(args);
|
||||
|
||||
if (args.size() < 4) {
|
||||
showConfigError("Incorrect amount of arguments!");
|
||||
}
|
||||
|
||||
frequency = Integer.parseInt(args.get(0));
|
||||
chance = Double.parseDouble(args.get(1));
|
||||
radius = Double.parseDouble(args.get(2));
|
||||
damage = Double.parseDouble(args.get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "lightning-nearby-entities:<frequency>:<chance>:<damage>:<radius>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(@NotNull final EcoBoss boss,
|
||||
@NotNull final LivingEntity entity,
|
||||
final long tick) {
|
||||
if (tick % frequency == 0) {
|
||||
for (Entity nearbyEntity : entity.getNearbyEntities(radius, radius, radius)) {
|
||||
if (NumberUtils.randFloat(0, 100) < chance) {
|
||||
if (nearbyEntity instanceof LivingEntity) {
|
||||
LightningUtils.strike((LivingEntity) nearbyEntity, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,8 @@ broadcast:
|
||||
- "&f - &8%third%&f (%third_damage% Damage)"
|
||||
- ""
|
||||
|
||||
effects: []
|
||||
effects:
|
||||
- "damage-nearby-players:15:2:3"
|
||||
|
||||
defence:
|
||||
immunities:
|
||||
|
||||
@@ -54,7 +54,8 @@ broadcast:
|
||||
- "&f - &4%third%&f (%third_damage% Damage)"
|
||||
- ""
|
||||
|
||||
effects: []
|
||||
effects:
|
||||
- "lightning-nearby-entities:100:15:2:3"
|
||||
|
||||
defence:
|
||||
immunities:
|
||||
|
||||
Reference in New Issue
Block a user