bruh
This commit is contained in:
parent
498d96267b
commit
1335b2e759
2 changed files with 27 additions and 7 deletions
|
@ -17,6 +17,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
@ -30,11 +31,13 @@ public class Main extends JavaPlugin implements Listener {
|
|||
FileConfiguration config;
|
||||
|
||||
Random rnd = new Random();
|
||||
List<Entity> giants = new ArrayList<Entity>();
|
||||
List<LivingEntity> giants = new ArrayList<LivingEntity>();
|
||||
|
||||
boolean ai;
|
||||
boolean headRotations;
|
||||
double chance;
|
||||
double attackDamage;
|
||||
long refreshDelay;
|
||||
Map<PotionEffectType, Integer> effects = new HashMap<PotionEffectType, Integer>();
|
||||
|
||||
@Override
|
||||
|
@ -71,13 +74,24 @@ public class Main extends JavaPlugin implements Listener {
|
|||
@Override
|
||||
public void run() {
|
||||
for (Entity e : giants) {
|
||||
Collection<Entity> nearby = e.getWorld().getNearbyEntities(e.getBoundingBox().expand(4D, 1D, 4D));
|
||||
for (Entity n : nearby) {
|
||||
((LivingEntity) n).damage(attackDamage, e);
|
||||
Collection<Entity> nearby = e.getWorld().getNearbyEntities(e.getBoundingBox().expand(4D, 1D, 4D), n -> (n instanceof Player));
|
||||
for (Entity p : nearby) {
|
||||
((LivingEntity) p).damage(attackDamage, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this, 20L, 0L)
|
||||
}.runTaskTimer(this, config.getLong("hitDelay"), 0L);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Entity e : giants) {
|
||||
List<Entity> passengers = e.getPassengers();
|
||||
passengers.removeIf(n -> (n.getType() != EntityType.HUSK));
|
||||
Location loc = passengers.get(0).getLocation();
|
||||
e.setRotation(loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(this, refreshDelay, 0L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -102,7 +116,7 @@ public class Main extends JavaPlugin implements Listener {
|
|||
PotionEffect effect = new PotionEffect(t.getKey(), Integer.MAX_VALUE, t.getValue());
|
||||
effect.apply(entity);
|
||||
}
|
||||
giants.add((Entity) entity);
|
||||
giants.add(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,15 @@ ai: true
|
|||
attackDamage: 1.0
|
||||
# Spawning chance, from 0 to 1
|
||||
chance: 0.02
|
||||
# Attack delay in ticks, smaller values will lag the server more
|
||||
hitDelay: 20
|
||||
# Additional potion effects
|
||||
# type:amplifier
|
||||
# See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
|
||||
# Set to [] to disable
|
||||
effects:
|
||||
- "JUMP:2"
|
||||
- "JUMP:2"
|
||||
|
||||
# No need to change this
|
||||
headRotations: true
|
||||
refreshDelay: 40
|
Loading…
Reference in a new issue