From 24946325bb03417d50055ba0a0fd7ae760b2357a Mon Sep 17 00:00:00 2001 From: NK Date: Thu, 22 Dec 2022 10:08:12 +0000 Subject: [PATCH] using oop now --- .../nullvalkyrie/events/listeners/DamageEffectEvents.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/night/nullvalkyrie/events/listeners/DamageEffectEvents.java b/src/main/java/me/night/nullvalkyrie/events/listeners/DamageEffectEvents.java index d76848d..cd0fde4 100644 --- a/src/main/java/me/night/nullvalkyrie/events/listeners/DamageEffectEvents.java +++ b/src/main/java/me/night/nullvalkyrie/events/listeners/DamageEffectEvents.java @@ -27,6 +27,7 @@ public class DamageEffectEvents implements Listener { double damage = e.getFinalDamage(); if (e.getEntity() instanceof Zombie) { Location loc = e.getEntity().getLocation().clone().add(getRandomOffset(), 1, getRandomOffset()); + assert world != null; world.spawn(loc, ArmorStand.class, armorStand -> { armorStand.setMarker(true); armorStand.setVisible(false); @@ -62,18 +63,18 @@ public class DamageEffectEvents implements Listener { }.runTaskTimer(Main.getPlugin(Main.class), 0L, 1L); } - public static boolean isSpawnable(Location loc) { + public boolean isSpawnable(Location loc) { Block feetBlock = loc.getBlock(), headBlock = loc.clone().add(0, 1, 0).getBlock(), upperBlock = loc.clone().add(0, 2, 0).getBlock(); return feetBlock.isPassable() && !feetBlock.isLiquid() && headBlock.isPassable() && !headBlock.isLiquid() && upperBlock.isPassable() && !upperBlock.isLiquid(); } - private static double getRandomOffset() { + private double getRandomOffset() { double random = Math.random(); if (Math.random() > 0.5) random *= -1; return random; } - public static int getRandomWithNeg(int size) { + public int getRandomWithNeg(int size) { int random = (int) (Math.random() * (size + 1)); if (Math.random() > 0.5) random *= -1; return random; @@ -87,6 +88,7 @@ public class DamageEffectEvents implements Listener { public Location generateRandomCoordIsSpawnable(int size) { while (true) { + assert world != null; Location coord = generateRandomCoord(size, world); boolean spawnable = isSpawnable(coord); if (spawnable) {