From 082d6e4087077349818aba9a2e09feda61feec1b Mon Sep 17 00:00:00 2001 From: ShermansWorld <77093412+ShermansWorld@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:56:38 -0500 Subject: [PATCH] feat: more config options for projectiles --- pom.xml | 2 +- .../github/alathra/siegeengines/config/Config.java | 9 +++++++++ .../siegeengines/projectile/EntityProjectile.java | 9 +++++---- .../siegeengines/projectile/ExplosiveProjectile.java | 5 +++-- .../siegeengines/projectile/FireworkProjectile.java | 4 ++-- src/main/resources/config.yml | 11 ++++++++++- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 6514ce4..d6e0ed2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.alathra SiegeEngines - 0.7.8 + 0.7.9 jar SiegeEngines diff --git a/src/main/java/com/github/alathra/siegeengines/config/Config.java b/src/main/java/com/github/alathra/siegeengines/config/Config.java index 5a11851..8c55806 100644 --- a/src/main/java/com/github/alathra/siegeengines/config/Config.java +++ b/src/main/java/com/github/alathra/siegeengines/config/Config.java @@ -23,6 +23,7 @@ import com.github.alathra.siegeengines.projectile.FireworkProjectile; import com.github.alathra.siegeengines.projectile.ProjectileType; import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile; +@SuppressWarnings("deprecation") public class Config { private static FileConfiguration config; @@ -257,6 +258,8 @@ public class Config { .getInt("Projectiles." + projectileName + ".ProjectileCount"); explosiveProjectile.soundType = Sound .valueOf(config.getString("Projectiles." + projectileName + ".FireSound")); + explosiveProjectile.velocityFactor = (float) config + .getDouble("Projectiles." + projectileName + ".VelocityFactor"); projectileMap.put(projectileName, explosiveProjectile); break; case ENTITY: @@ -269,6 +272,12 @@ public class Config { .valueOf(config.getString("Projectiles." + projectileName + ".EntityType")); entityProjectile.soundType = Sound .valueOf(config.getString("Projectiles." + projectileName + ".FireSound")); + entityProjectile.velocityFactor = (float) config + .getDouble("Projectiles." + projectileName + ".VelocityFactor"); + if (entityProjectile.entityType.equals(EntityType.ARROW)) { + entityProjectile.arrowDamageFactor = (float) config + .getDouble("Projectiles." + projectileName + ".ArrowDamageFactor"); + } projectileMap.put(projectileName, entityProjectile); break; case FIREWORK: diff --git a/src/main/java/com/github/alathra/siegeengines/projectile/EntityProjectile.java b/src/main/java/com/github/alathra/siegeengines/projectile/EntityProjectile.java index 0467983..f8ae79f 100644 --- a/src/main/java/com/github/alathra/siegeengines/projectile/EntityProjectile.java +++ b/src/main/java/com/github/alathra/siegeengines/projectile/EntityProjectile.java @@ -5,7 +5,6 @@ import com.github.alathra.siegeengines.SiegeEnginesUtil; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.World; @@ -26,6 +25,8 @@ public class EntityProjectile extends SiegeEngineProjectile { public float inaccuracy = 0.2f; public Particle particleType = Particle.CAMPFIRE_SIGNAL_SMOKE; public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE; + public float velocityFactor = 1.0f; + public float arrowDamageFactor = 1.0f; private boolean playSound = true; @@ -43,10 +44,10 @@ public class EntityProjectile extends SiegeEngineProjectile { if (delayedFire) { baseDelay += delayTime; Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> { - CreateEntity(entity, FireLocation, velocity, player); + CreateEntity(entity, FireLocation, velocity*velocityFactor, player); }, (long) baseDelay); } else { - CreateEntity(entity, FireLocation, velocity, player); + CreateEntity(entity, FireLocation, velocity*velocityFactor, player); } } } @@ -69,7 +70,7 @@ public class EntityProjectile extends SiegeEngineProjectile { } if (arrow instanceof Arrow) { Arrow arr = (Arrow) arrow; - arr.setDamage(8); + arr.setDamage(8*arrowDamageFactor); if (player instanceof org.bukkit.projectiles.ProjectileSource) { arr.setShooter((org.bukkit.projectiles.ProjectileSource) player); arr.setPickupStatus(org.bukkit.entity.AbstractArrow.PickupStatus.CREATIVE_ONLY); diff --git a/src/main/java/com/github/alathra/siegeengines/projectile/ExplosiveProjectile.java b/src/main/java/com/github/alathra/siegeengines/projectile/ExplosiveProjectile.java index a7b72c1..977fc3e 100644 --- a/src/main/java/com/github/alathra/siegeengines/projectile/ExplosiveProjectile.java +++ b/src/main/java/com/github/alathra/siegeengines/projectile/ExplosiveProjectile.java @@ -29,6 +29,7 @@ public class ExplosiveProjectile extends SiegeEngineProjectile { public Particle particleType = Particle.EXPLOSION_LARGE; public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE; public Boolean alertOnLanding = false; + public float velocityFactor = 1.0f; private boolean playSound = true; @@ -44,10 +45,10 @@ public class ExplosiveProjectile extends SiegeEngineProjectile { if (delayedFire) { baseDelay += delayTime; Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> { - CreateEntity(entity, loc, velocity, player); + CreateEntity(entity, loc, velocity*velocityFactor, player); }, (long) baseDelay); } else { - CreateEntity(entity, loc, velocity, player); + CreateEntity(entity, loc, velocity*velocityFactor, player); } } } diff --git a/src/main/java/com/github/alathra/siegeengines/projectile/FireworkProjectile.java b/src/main/java/com/github/alathra/siegeengines/projectile/FireworkProjectile.java index d82cd85..aeee0a5 100644 --- a/src/main/java/com/github/alathra/siegeengines/projectile/FireworkProjectile.java +++ b/src/main/java/com/github/alathra/siegeengines/projectile/FireworkProjectile.java @@ -25,7 +25,7 @@ public class FireworkProjectile extends SiegeEngineProjectile { public float inaccuracy = 0.125f; public Particle particleType = Particle.FLASH; public Sound soundType = Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR; - public float velocityFactor = 0.5f; + public float velocityFactor = 1.0f; private boolean playSound = true; @@ -55,7 +55,7 @@ public class FireworkProjectile extends SiegeEngineProjectile { CreateEntity(entity, FireLocation, velocity*velocityFactor, player); }, (long) baseDelay); } else { - CreateEntity(entity, FireLocation, velocity, player); + CreateEntity(entity, FireLocation, velocity*velocityFactor, player); } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2143975..762567c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -49,6 +49,7 @@ Projectiles: ExplodePower: 3.25 Inaccuracy: 0.125 ProjectileCount: 1 + VelocityFactor: 1.0 AmmoItem: COBBLESTONE FireSound: ENTITY_GENERIC_EXPLODE BreachShot: @@ -56,6 +57,7 @@ Projectiles: ExplodePower: 5.25 Inaccuracy: 0.375 ProjectileCount: 1 + VelocityFactor: 1.0 AmmoItem: IRON_BLOCK FireSound: ENTITY_GENERIC_EXPLODE RepeatingShot: @@ -63,26 +65,32 @@ Projectiles: ExplodePower: 1.75 Inaccuracy: 0.525 ProjectileCount: 6 + VelocityFactor: 1.0 AmmoItem: TNT FireSound: ENTITY_GENERIC_EXPLODE ScatterShot: ProjectileType: ENTITY Inaccuracy: 0.365 EntityCount: 24 + VelocityFactor: 1.0 EntityType: ARROW + ArrowDamageFactor: 1.0 AmmoItem: GRAVEL FireSound: ITEM_CROSSBOW_SHOOT BallistaBoltShot: ProjectileType: ENTITY Inaccuracy: 0.0125 EntityCount: 1 + VelocityFactor: 0.5 EntityType: ARROW + ArrowDamageFactor: 1.0 AmmoItem: ARROW FireSound: ITEM_CROSSBOW_SHOOT DragonsBreath: ProjectileType: ENTITY Inaccuracy: 0.125 EntityCount: 1 + VelocityFactor: 1.0 EntityType: DRAGON_FIREBALL AmmoItem: DRAGON_BREATH FireSound: ENTITY_GENERIC_EXPLODE @@ -90,6 +98,7 @@ Projectiles: ProjectileType: ENTITY Inaccuracy: 0.475 EntityCount: 8 + VelocityFactor: 1.0 EntityType: SMALL_FIREBALL AmmoItem: MAGMA_BLOCK FireSound: ENTITY_GENERIC_EXPLODE @@ -117,7 +126,7 @@ SiegeEngines: CanMount: false Ballista: ShotAmount: 1 - VelocityPerFuel: 0.975 + VelocityPerFuel: 2.0 MaxFuel: 2 FuelItem: STRING Projectiles: