mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-22 16:39:25 +00:00
Added target ticker
This commit is contained in:
@@ -8,6 +8,7 @@ import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|||||||
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||||
import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker;
|
import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker;
|
||||||
import com.willfp.ecobosses.bosses.tick.tickers.HealthPlaceholderTicker;
|
import com.willfp.ecobosses.bosses.tick.tickers.HealthPlaceholderTicker;
|
||||||
|
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.attacks.EffectOption;
|
import com.willfp.ecobosses.bosses.util.obj.attacks.EffectOption;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.attacks.SummonsOption;
|
import com.willfp.ecobosses.bosses.util.obj.attacks.SummonsOption;
|
||||||
@@ -69,6 +70,7 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
// Tickers
|
// Tickers
|
||||||
this.tickers = new HashSet<>();
|
this.tickers = new HashSet<>();
|
||||||
this.tickers.add(new HealthPlaceholderTicker());
|
this.tickers.add(new HealthPlaceholderTicker());
|
||||||
|
this.tickers.add(new TargetTicker());
|
||||||
if (boss.isBossbarEnabled()) {
|
if (boss.isBossbarEnabled()) {
|
||||||
this.tickers.add(
|
this.tickers.add(
|
||||||
new BossBarTicker(
|
new BossBarTicker(
|
||||||
|
|||||||
@@ -13,24 +13,22 @@ public class DamageNearbyPlayers extends Effect {
|
|||||||
private final int frequency;
|
private final int frequency;
|
||||||
private final double damage;
|
private final double damage;
|
||||||
private final double radius;
|
private final double radius;
|
||||||
private final boolean triggerHandler;
|
|
||||||
|
|
||||||
public DamageNearbyPlayers(@NotNull final List<String> args) {
|
public DamageNearbyPlayers(@NotNull final List<String> args) {
|
||||||
super(args);
|
super(args);
|
||||||
|
|
||||||
if (args.size() < 4) {
|
if (args.size() < 3) {
|
||||||
showConfigError("Incorrect amount of arguments!");
|
showConfigError("Incorrect amount of arguments!");
|
||||||
}
|
}
|
||||||
|
|
||||||
frequency = Integer.parseInt(args.get(0));
|
frequency = Integer.parseInt(args.get(0));
|
||||||
radius = Double.parseDouble(args.get(1));
|
radius = Double.parseDouble(args.get(1));
|
||||||
damage = Double.parseDouble(args.get(2));
|
damage = Double.parseDouble(args.get(2));
|
||||||
triggerHandler = Boolean.parseBoolean(args.get(3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "damage-nearby-players:<frequency>:<damage>:<radius>:<triggerHandler>";
|
return "damage-nearby-players:<frequency>:<damage>:<radius>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,11 +38,7 @@ public class DamageNearbyPlayers extends Effect {
|
|||||||
if (tick % frequency == 0) {
|
if (tick % frequency == 0) {
|
||||||
for (Entity nearbyEntity : entity.getNearbyEntities(radius, radius, radius)) {
|
for (Entity nearbyEntity : entity.getNearbyEntities(radius, radius, radius)) {
|
||||||
if (nearbyEntity instanceof Player) {
|
if (nearbyEntity instanceof Player) {
|
||||||
if (triggerHandler) {
|
|
||||||
((Player) nearbyEntity).damage(damage, entity);
|
((Player) nearbyEntity).damage(damage, entity);
|
||||||
} else {
|
|
||||||
((Player) nearbyEntity).damage(damage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.willfp.ecobosses.bosses.tick.tickers;
|
||||||
|
|
||||||
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
|
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class TargetTicker implements BossTicker {
|
||||||
|
@Override
|
||||||
|
public void tick(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
final long tick) {
|
||||||
|
if (tick % 10 == 0) {
|
||||||
|
for (Entity nearbyEntity : entity.getNearbyEntities(10, 5, 10)) {
|
||||||
|
if (nearbyEntity instanceof Player) {
|
||||||
|
if (entity instanceof Mob) {
|
||||||
|
((Mob) entity).setTarget((Player) nearbyEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user