diff --git a/src/main/java/net/countercraft/movecraft/combat/MovecraftCombat.java b/src/main/java/net/countercraft/movecraft/combat/MovecraftCombat.java index 0526add..1489853 100644 --- a/src/main/java/net/countercraft/movecraft/combat/MovecraftCombat.java +++ b/src/main/java/net/countercraft/movecraft/combat/MovecraftCombat.java @@ -84,11 +84,11 @@ public void onEnable() { AntiRadar.load(config); ContactExplosives.load(config); DurabilityOverride.load(config); - FireballBehaviour.load(config); + FireballLifespan.load(config); FireballPenetration.load(config); ReImplementTNTTranslocation.load(config); BlockBehaviorOverride.load(config); - + // Register event translation listeners PluginManager pluginManager = getServer().getPluginManager(); pluginManager.registerEvents(new CraftCollisionExplosionListener(), this); @@ -129,9 +129,10 @@ public void onEnable() { pluginManager.registerEvents(contactExplosives, this); contactExplosives.runTaskTimer(this, 0, 1); // Every tick pluginManager.registerEvents(new DurabilityOverride(), this); - var fireballBehavior = new FireballBehaviour(); - pluginManager.registerEvents(fireballBehavior, this); - fireballBehavior.runTaskTimer(this, 0, 20); // Every 1 second + var fireballLifespan = new FireballLifespan(); + pluginManager.registerEvents(fireballLifespan, this); + fireballLifespan.runTaskTimer(this, 0, 20); // Every 1 second + pluginManager.registerEvents(new FireballLifespan(), this); pluginManager.registerEvents(new FireballPenetration(), this); pluginManager.registerEvents(new ReImplementTNTTranslocation(), this); diff --git a/src/main/java/net/countercraft/movecraft/combat/features/FireballBehaviour.java b/src/main/java/net/countercraft/movecraft/combat/features/FireballLifespan.java similarity index 61% rename from src/main/java/net/countercraft/movecraft/combat/features/FireballBehaviour.java rename to src/main/java/net/countercraft/movecraft/combat/features/FireballLifespan.java index 161700b..b3b8c77 100644 --- a/src/main/java/net/countercraft/movecraft/combat/features/FireballBehaviour.java +++ b/src/main/java/net/countercraft/movecraft/combat/features/FireballLifespan.java @@ -9,22 +9,19 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.util.Deque; import java.util.LinkedList; -public class FireballBehaviour extends BukkitRunnable implements Listener { +public class FireballLifespan extends BukkitRunnable implements Listener { private static final String METADATA_KEY = "MCC-Expiry"; public static int FireballLifespan = 0; - private static double FireballSpeed = 1.0; private final Deque queue = new LinkedList<>(); public static void load(@NotNull FileConfiguration config) { FireballLifespan = config.getInt("FireballLifespan", 6); - FireballSpeed = config.getDouble("FireballSpeed", 1.0); - FireballLifespan *= 1000; // Convert from seconds to milliseconds + FireballLifespan *= 20 * 50; // Convert from seconds to milliseconds } @Override @@ -42,29 +39,11 @@ public void run() { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onProjectileLaunch(@NotNull ProjectileLaunchEvent e) { - if (!(e.getEntity() instanceof SmallFireball fireball)) + if (!(e.getEntity() instanceof SmallFireball)) return; + SmallFireball fireball = (SmallFireball) e.getEntity(); fireball.setMetadata(METADATA_KEY, new FixedMetadataValue(MovecraftCombat.getInstance(), System.currentTimeMillis())); queue.add(fireball); - - new BukkitRunnable() { - @Override - public void run() { - Vector fireballVector = fireball.getVelocity(); - try { - fireballVector.checkFinite(); - } - catch (IllegalArgumentException ignored) { - return; - } - double speed = fireballVector.length() * FireballSpeed; - - fireballVector = fireballVector.normalize(); - fireballVector.multiply(speed); - - fireball.setVelocity(fireballVector); - } - }.runTaskLater(MovecraftCombat.getInstance(), 1L); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 474daec..83f721a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -41,7 +41,6 @@ BleedfixExplosion: true # Fireball Lifespan FireballLifespan: 6 # Lifespan of fireballs in seconds -FireballSpeed: 1.0 # Speed multiplier for fireballs # TNT Tracers TracerRateTicks: 5.0 # Rate at which tracers are spawned on the path of flying TNT @@ -53,6 +52,7 @@ ExplosionBlock: GLOWSTONE # Block to use to indicate tracer explosions TracerParticles: FIREWORKS_SPARK # Particle to use for particle tracers See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html for options. ExplosionParticles: VILLAGER_ANGRY # Particle to use for particle tracer explosions + ### Custom features # Damage Tracking