diff --git a/bin/CrunchProjectiles/EntityProjectile.class b/bin/CrunchProjectiles/EntityProjectile.class index d4884d8..e504531 100644 Binary files a/bin/CrunchProjectiles/EntityProjectile.class and b/bin/CrunchProjectiles/EntityProjectile.class differ diff --git a/bin/CrunchProjectiles/ExplosiveProjectile.class b/bin/CrunchProjectiles/ExplosiveProjectile.class index 50cfd48..4c7595f 100644 Binary files a/bin/CrunchProjectiles/ExplosiveProjectile.class and b/bin/CrunchProjectiles/ExplosiveProjectile.class differ diff --git a/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class b/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class index 8f5a708..9f7ee71 100644 Binary files a/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class and b/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class differ diff --git a/bin/siegeCore/CrunchSiegeCore.class b/bin/siegeCore/CrunchSiegeCore.class index e3152a6..5917096 100644 Binary files a/bin/siegeCore/CrunchSiegeCore.class and b/bin/siegeCore/CrunchSiegeCore.class differ diff --git a/src/CrunchProjectiles/CrunchProjectile.java b/src/CrunchProjectiles/CrunchProjectile.java index 834cc7b..8503778 100644 --- a/src/CrunchProjectiles/CrunchProjectile.java +++ b/src/CrunchProjectiles/CrunchProjectile.java @@ -1,11 +1,13 @@ package CrunchProjectiles; import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; public interface CrunchProjectile { public void Shoot(Player player, Entity entity, Location loc, Float velocity); - + } diff --git a/src/CrunchProjectiles/EntityProjectile.java b/src/CrunchProjectiles/EntityProjectile.java index 657fb72..982158e 100644 --- a/src/CrunchProjectiles/EntityProjectile.java +++ b/src/CrunchProjectiles/EntityProjectile.java @@ -1,6 +1,8 @@ package CrunchProjectiles; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.entity.Arrow; @@ -16,25 +18,53 @@ public class EntityProjectile implements CrunchProjectile{ public int EntityCount = 20; public int ArrowOnlyDamage = 6; + public Boolean DelayedFire = false; + public int DelayTime = 6; public EntityType EntityTyp = EntityType.ARROW; + public float Inaccuracy = 0.2f; + public Particle ParticleType = Particle.EXPLOSION_LARGE; + public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE; @Override public void Shoot(Player player, Entity entity, Location loc, Float velocity) { - + int baseDelay = 0; for (int i = 0; i < EntityCount; i++) { - World world = entity.getLocation().getWorld(); - - Entity arrow = world.spawnEntity(loc, EntityTyp); - arrow.setVelocity(loc.getDirection().multiply(velocity).add(new Vector(CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble()) - .subtract(new Vector(CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble(), CrunchSiegeCore.random.nextDouble())))); - if (arrow instanceof Arrow) { - Arrow arr = (Arrow) arrow; - arr.setDamage(8); + if (DelayedFire) { + baseDelay += DelayTime; + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> { + CreateEntity(entity, loc, velocity); + }, (long) baseDelay); } - // MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET); - // DisguiseAPI.disguiseEntity(arrow, miscDisguise); - world.playSound(entity.getLocation(), Sound.ITEM_CROSSBOW_SHOOT, 20, 2); + else { + CreateEntity(entity, loc, velocity); + } + // } } } + private void CreateEntity(Entity entity, Location loc, Float velocity) { + World world = entity.getLocation().getWorld(); + + Entity arrow = world.spawnEntity(loc, EntityTyp); + if (Inaccuracy != 0f) { + arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()) + .subtract(Randomise())); + } + else { + arrow.setVelocity(loc.getDirection().multiply(velocity)); + } + + if (arrow instanceof Arrow) { + Arrow arr = (Arrow) arrow; + arr.setDamage(8); + } + // MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET); + // DisguiseAPI.disguiseEntity(arrow, miscDisguise); + world.playSound(loc, this.SoundType, 20, 2); + world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0); + } + + private Vector Randomise() { + return new Vector(CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1)); + } } diff --git a/src/CrunchProjectiles/ExplosiveProjectile.java b/src/CrunchProjectiles/ExplosiveProjectile.java index 51bd8a7..7ff471e 100644 --- a/src/CrunchProjectiles/ExplosiveProjectile.java +++ b/src/CrunchProjectiles/ExplosiveProjectile.java @@ -1,5 +1,6 @@ package CrunchProjectiles; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; @@ -9,6 +10,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; import siegeCore.ClickHandler; import siegeCore.CrunchSiegeCore; @@ -16,24 +18,49 @@ import siegeCore.CrunchSiegeCore; public class ExplosiveProjectile implements CrunchProjectile { public int Radius = 2; - public float Inaccuracy = 3.0f; + public float Inaccuracy = 0.4f; public int ProjectilesCount = 1; + public Boolean DelayedFire = false; + public int DelayTime = 6; + public Particle ParticleType = Particle.EXPLOSION_LARGE; + public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE; @Override public void Shoot(Player player, Entity entity, Location loc, Float velocity) { + int baseDelay = 0; for (int i = 0; i < ProjectilesCount; i++) { - if (Inaccuracy > 0) { - float randomVar = CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1); - loc.setYaw(loc.getYaw() + randomVar); + if (DelayedFire) { + baseDelay += DelayTime; + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> { + CreateEntity(entity, loc, velocity); + }, (long) baseDelay); } - - World world = entity.getLocation().getWorld(); - Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL); - ClickHandler.projectiles.put(tnt.getUniqueId(), this); - tnt.setVelocity(loc.getDirection().multiply(velocity)); - world.playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 20, 2); - world.spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0); + else { + CreateEntity(entity, loc, velocity); + } + + // } } } + + private void CreateEntity(Entity entity, Location loc, Float velocity) { + World world = entity.getLocation().getWorld(); + Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL); + ClickHandler.projectiles.put(tnt.getUniqueId(), this); + if (Inaccuracy != 0f) { + tnt.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()) + .subtract(Randomise())); + } + else { + tnt.setVelocity(loc.getDirection().multiply(velocity)); + } + + world.playSound(loc, this.SoundType, 20, 2); + world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0); + } + + private Vector Randomise() { + return new Vector(CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),CrunchSiegeCore.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1)); + } } diff --git a/src/siegeCore/CrunchSiegeCore.java b/src/siegeCore/CrunchSiegeCore.java index 4b94b1e..78218ee 100644 --- a/src/siegeCore/CrunchSiegeCore.java +++ b/src/siegeCore/CrunchSiegeCore.java @@ -14,6 +14,7 @@ import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.attribute.Attribute; @@ -126,8 +127,9 @@ public class CrunchSiegeCore extends JavaPlugin { equip.Projectiles.put(Material.COBBLESTONE, proj); proj = new ExplosiveProjectile(); proj.Radius = 1; - proj.ProjectilesCount = 3; - proj.Inaccuracy = 12; + proj.ProjectilesCount = 50; + proj.DelayedFire = true; + proj.Inaccuracy = 0.3f; equip.Projectiles.put(Material.TNT, proj); proj = new ExplosiveProjectile(); proj.Radius = 4; @@ -137,7 +139,19 @@ public class CrunchSiegeCore extends JavaPlugin { EntityProjectile fireProj = new EntityProjectile(); fireProj.EntityCount = 3; fireProj.EntityTyp = EntityType.SMALL_FIREBALL; + fireProj.ParticleType = Particle.WHITE_ASH; + fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT; equip.Projectiles.put(Material.DIAMOND, fireProj); + + EntityProjectile pig = new EntityProjectile(); + pig.EntityCount = 100; + pig.DelayedFire = true; + pig.DelayTime = 3; + pig.EntityTyp = EntityType.ARROW; + pig.SoundType = Sound.ITEM_CROSSBOW_SHOOT; + pig.ParticleType = Particle.GLOW; + equip.Projectiles.put(Material.PORKCHOP, pig); + ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); equip.ReadyModelNumber = 122; equip.ModelNumberToFireAt = 135;