diff --git a/bin/CrunchProjectiles/PotionProjectile.class b/bin/CrunchProjectiles/PotionProjectile.class new file mode 100644 index 0000000..c3cb2eb Binary files /dev/null and b/bin/CrunchProjectiles/PotionProjectile.class differ diff --git a/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class b/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class index 9f7ee71..b7388ac 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 f23b691..d170f07 100644 Binary files a/bin/siegeCore/CrunchSiegeCore.class and b/bin/siegeCore/CrunchSiegeCore.class differ diff --git a/src/CrunchProjectiles/PotionProjectile.java b/src/CrunchProjectiles/PotionProjectile.java new file mode 100644 index 0000000..2ec2a05 --- /dev/null +++ b/src/CrunchProjectiles/PotionProjectile.java @@ -0,0 +1,83 @@ +package CrunchProjectiles; + +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.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.SplashPotion; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import siegeCore.CrunchSiegeCore; + +public class PotionProjectile implements CrunchProjectile { + public int EntityCount = 20; + public Boolean DelayedFire = false; + public int DelayTime = 6; + public float Inaccuracy = 0.4f; + public Particle ParticleType = Particle.EXPLOSION_LARGE; + public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE; + + @Override + public void Shoot(Player player, Entity entity, double XOffset, double YOffset, Float velocity) { + // TODO Auto-generated method stub + int baseDelay = 0; + for (int i = 0; i < EntityCount; i++) { + if (DelayedFire) { + baseDelay += DelayTime; + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> { + + CreateEntity(entity, XOffset, YOffset, velocity); + }, (long) baseDelay); + } + else { + + CreateEntity(entity, XOffset, YOffset, velocity); + } + + // } + } + } + private void CreateEntity(Entity entity, double XOffset, double YOffset, Float velocity) { + World world = entity.getLocation().getWorld(); + LivingEntity living = (LivingEntity) entity; + Location loc = living.getEyeLocation(); + Vector direction = entity.getLocation().getDirection().multiply(XOffset); + loc.add(direction); + + Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION); + if (Inaccuracy != 0f) { + arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()) + .subtract(Randomise())); + } + else { + arrow.setVelocity(loc.getDirection().multiply(velocity)); + } + ItemStack itemStack = new ItemStack(Material.LINGERING_POTION); + PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta(); + potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.POISON, 100, 0, true), true); + itemStack.setItemMeta(potionMeta); + ThrownPotion potion = (ThrownPotion) arrow; + potion.setItem(itemStack); + // 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/siegeCore/CrunchSiegeCore.java b/src/siegeCore/CrunchSiegeCore.java index ff85d84..580d862 100644 --- a/src/siegeCore/CrunchSiegeCore.java +++ b/src/siegeCore/CrunchSiegeCore.java @@ -51,6 +51,7 @@ import org.bukkit.util.Vector; import CrunchProjectiles.EntityProjectile; import CrunchProjectiles.CrunchProjectile; import CrunchProjectiles.ExplosiveProjectile; +import CrunchProjectiles.PotionProjectile; public class CrunchSiegeCore extends JavaPlugin { @@ -151,7 +152,7 @@ public class CrunchSiegeCore extends JavaPlugin { pig.SoundType = Sound.ITEM_CROSSBOW_SHOOT; pig.ParticleType = Particle.GLOW; equip.Projectiles.put(Material.PORKCHOP, pig); - + equip.Projectiles.put(Material.BONE, new PotionProjectile()); ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); equip.ReadyModelNumber = 122; equip.ModelNumberToFireAt = 135;