diff --git a/bin/CrunchProjectiles/CrunchProjectile.class b/bin/CrunchProjectiles/CrunchProjectile.class new file mode 100644 index 0000000..c01e8e4 Binary files /dev/null and b/bin/CrunchProjectiles/CrunchProjectile.class differ diff --git a/bin/CrunchProjectiles/EntityProjectile.class b/bin/CrunchProjectiles/EntityProjectile.class new file mode 100644 index 0000000..d4884d8 Binary files /dev/null and b/bin/CrunchProjectiles/EntityProjectile.class differ diff --git a/bin/CrunchProjectiles/ExplosiveProjectile.class b/bin/CrunchProjectiles/ExplosiveProjectile.class new file mode 100644 index 0000000..50cfd48 Binary files /dev/null and b/bin/CrunchProjectiles/ExplosiveProjectile.class differ diff --git a/bin/siegeCore/ClickHandler.class b/bin/siegeCore/ClickHandler.class index 17a948d..5f3a7bf 100644 Binary files a/bin/siegeCore/ClickHandler.class and b/bin/siegeCore/ClickHandler.class differ diff --git a/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class b/bin/siegeCore/CrunchSiegeCore$SiegeCommand.class index 29e504e..8f5a708 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 83c2756..e3152a6 100644 Binary files a/bin/siegeCore/CrunchSiegeCore.class and b/bin/siegeCore/CrunchSiegeCore.class differ diff --git a/bin/siegeCore/SiegeEquipment.class b/bin/siegeCore/SiegeEquipment.class index 5867c5d..1909e92 100644 Binary files a/bin/siegeCore/SiegeEquipment.class and b/bin/siegeCore/SiegeEquipment.class differ diff --git a/bin/siegeCore/SiegeProjectile.class b/bin/siegeCore/SiegeProjectile.class deleted file mode 100644 index 2e3d631..0000000 Binary files a/bin/siegeCore/SiegeProjectile.class and /dev/null differ diff --git a/src/CrunchProjectiles/CrunchProjectile.java b/src/CrunchProjectiles/CrunchProjectile.java new file mode 100644 index 0000000..834cc7b --- /dev/null +++ b/src/CrunchProjectiles/CrunchProjectile.java @@ -0,0 +1,11 @@ +package CrunchProjectiles; + +import org.bukkit.Location; +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 new file mode 100644 index 0000000..657fb72 --- /dev/null +++ b/src/CrunchProjectiles/EntityProjectile.java @@ -0,0 +1,40 @@ +package CrunchProjectiles; + +import org.bukkit.Location; +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.Fireball; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import siegeCore.CrunchSiegeCore; + +public class EntityProjectile implements CrunchProjectile{ + + public int EntityCount = 20; + public int ArrowOnlyDamage = 6; + public EntityType EntityTyp = EntityType.ARROW; + @Override + public void Shoot(Player player, Entity entity, Location loc, Float velocity) { + + 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); + } + // MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET); + // DisguiseAPI.disguiseEntity(arrow, miscDisguise); + world.playSound(entity.getLocation(), Sound.ITEM_CROSSBOW_SHOOT, 20, 2); + // } + } + } +} + diff --git a/src/CrunchProjectiles/ExplosiveProjectile.java b/src/CrunchProjectiles/ExplosiveProjectile.java new file mode 100644 index 0000000..51bd8a7 --- /dev/null +++ b/src/CrunchProjectiles/ExplosiveProjectile.java @@ -0,0 +1,39 @@ +package CrunchProjectiles; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import siegeCore.ClickHandler; +import siegeCore.CrunchSiegeCore; + +public class ExplosiveProjectile implements CrunchProjectile { + + public int Radius = 2; + public float Inaccuracy = 3.0f; + public int ProjectilesCount = 1; + @Override + public void Shoot(Player player, Entity entity, Location loc, Float velocity) { + 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); + } + + 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); + } + } +} + + diff --git a/src/siegeCore/ClickHandler.java b/src/siegeCore/ClickHandler.java index e530c5c..93e1a87 100644 --- a/src/siegeCore/ClickHandler.java +++ b/src/siegeCore/ClickHandler.java @@ -44,16 +44,18 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.EulerAngle; +import CrunchProjectiles.ExplosiveProjectile; + public class ClickHandler implements Listener { public float MinDelay = 5; - public static HashMap projectiles = new HashMap(); + public static HashMap projectiles = new HashMap(); @EventHandler public void onHit(ProjectileHitEvent event) { if ((event.getEntity() instanceof Snowball) && projectiles.containsKey(event.getEntity().getUniqueId())) { - SiegeProjectile proj = projectiles.get(event.getEntity().getUniqueId()); + ExplosiveProjectile proj = projectiles.get(event.getEntity().getUniqueId()); Entity snowball = event.getEntity(); Location loc = snowball.getLocation(); World world = event.getEntity().getWorld(); diff --git a/src/siegeCore/CrunchSiegeCore.java b/src/siegeCore/CrunchSiegeCore.java index 3a956db..4b94b1e 100644 --- a/src/siegeCore/CrunchSiegeCore.java +++ b/src/siegeCore/CrunchSiegeCore.java @@ -47,10 +47,16 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import CrunchProjectiles.EntityProjectile; +import CrunchProjectiles.CrunchProjectile; +import CrunchProjectiles.ExplosiveProjectile; + public class CrunchSiegeCore extends JavaPlugin { public static Plugin plugin; - + + public static Random random = new Random(); + @SuppressWarnings("deprecation") @Override public void onEnable() { @@ -115,11 +121,23 @@ public class CrunchSiegeCore extends JavaPlugin { public static void AddDefined() { SiegeEquipment equip = new SiegeEquipment(); - equip.Projectiles.put(Material.COBBLESTONE, new SiegeProjectile(1, false)); - equip.Projectiles.put(Material.TNT, new SiegeProjectile(1, false)); - equip.Projectiles.put(Material.COPPER_BLOCK, new SiegeProjectile(4, false)); - equip.Projectiles.put(Material.GRAVEL, new SiegeProjectile(1, false)); - equip.Projectiles.put(Material.FIREWORK_STAR, new SiegeProjectile(1, false)); + ExplosiveProjectile proj = new ExplosiveProjectile(); + proj.Radius = 1; + equip.Projectiles.put(Material.COBBLESTONE, proj); + proj = new ExplosiveProjectile(); + proj.Radius = 1; + proj.ProjectilesCount = 3; + proj.Inaccuracy = 12; + equip.Projectiles.put(Material.TNT, proj); + proj = new ExplosiveProjectile(); + proj.Radius = 4; + proj.ProjectilesCount = 1; + equip.Projectiles.put(Material.COPPER_BLOCK, proj); + equip.Projectiles.put(Material.GRAVEL, new EntityProjectile()); + EntityProjectile fireProj = new EntityProjectile(); + fireProj.EntityCount = 3; + fireProj.EntityTyp = EntityType.SMALL_FIREBALL; + equip.Projectiles.put(Material.DIAMOND, fireProj); ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); equip.ReadyModelNumber = 122; equip.ModelNumberToFireAt = 135; diff --git a/src/siegeCore/SiegeEquipment.java b/src/siegeCore/SiegeEquipment.java index 8bee30c..891b2cf 100644 --- a/src/siegeCore/SiegeEquipment.java +++ b/src/siegeCore/SiegeEquipment.java @@ -20,6 +20,8 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import CrunchProjectiles.CrunchProjectile; +import CrunchProjectiles.ExplosiveProjectile; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.MiscDisguise; @@ -36,8 +38,8 @@ public class SiegeEquipment implements Cloneable { public ItemStack ItemToPlace; - public HashMap Projectiles = new HashMap() ; - + public HashMap Projectiles = new HashMap() ; + public String ItemToUseForModel; public String WorldName; @@ -46,7 +48,7 @@ public class SiegeEquipment implements Cloneable { public int YOffset = 0; public int MaxFuel = 5; public float VelocityPerFuel = 0.75f; - public Material FuelMaterial = Material.GUNPOWDER; + public Material FuelMaterial = Material.GUNPOWDER; public int FuseTime; public long NextShotTime = System.currentTimeMillis(); @@ -97,7 +99,7 @@ public class SiegeEquipment implements Cloneable { return false; } } - + return false; } @@ -114,11 +116,11 @@ public class SiegeEquipment implements Cloneable { } float loadedFuel = this.AmmoHolder.LoadedFuel; Material LoadedProjectile = this.AmmoHolder.MaterialName; - + this.AmmoHolder.LoadedFuel = 0; this.AmmoHolder.LoadedProjectile = 0; this.AmmoHolder.MaterialName = Material.BEDROCK; - + LivingEntity living = (LivingEntity) Entity; if (living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) { return; @@ -127,12 +129,12 @@ public class SiegeEquipment implements Cloneable { return; } this.WorldName = Entity.getWorld().getName(); - this.NextShotTime = System.currentTimeMillis() + 6000; + this.NextShotTime = System.currentTimeMillis() + 1000; if (this.CycleThroughModelsBeforeFiring) { this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(CrunchSiegeCore.plugin, () -> { - + Location loc = living.getEyeLocation(); Vector direction = Entity.getLocation().getDirection().multiply(XOffset); Random random = new Random(); @@ -140,8 +142,8 @@ public class SiegeEquipment implements Cloneable { loc.add(direction.multiply(randomVar)); loc.setYaw(loc.getYaw() + randomVar); - - + + this.NextModelNumber = 0; this.location = loc; @@ -182,7 +184,7 @@ public class SiegeEquipment implements Cloneable { // player.sendMessage("" + modelData); CrunchSiegeCore.UpdateEntityIdModel(this.Entity, modelData, this.WorldName); if (modelData == this.ModelNumberToFireAt) { - Shoot(loc, loadedFuel, LoadedProjectile); + Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, loc, loadedFuel * this.VelocityPerFuel); } this.NextModelNumber += 1; @@ -200,77 +202,68 @@ public class SiegeEquipment implements Cloneable { Location loc = living.getEyeLocation(); Vector direction = Entity.getLocation().getDirection().multiply(XOffset); - + loc.add(direction); - + this.NextModelNumber = 0; this.location = loc; // player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis())); - - Shoot(loc, loadedFuel, LoadedProjectile); + + Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, loc, loadedFuel * this.VelocityPerFuel); }, (long) delay); } } - public static Random random = new Random(); - - public void Shoot(Location loc, float loadedFuel, Material LoadedProjectile) { - switch (LoadedProjectile) { - - case COBBLESTONE: - case COPPER_BLOCK: - { - float randomVar = random.nextFloat() * (6 - -6) + -6; - loc.setYaw(loc.getYaw() + randomVar); - Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL); - ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile)); - tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel)); - Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2); - Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0); - } - break; - case GRAVEL: - { - for (int i = 0; i < 20; i++) { - Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.ARROW); - arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel / 2).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()) - .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())))); - Arrow arr = (Arrow) arrow; - arr.setDamage(3 * loadedFuel); -// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET); -// DisguiseAPI.disguiseEntity(arrow, miscDisguise); - Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2); - } - } - break; - case TNT: - { - for (int i = 0; i < 5; i++) { - //float randomVar = random.nextFloat() * (15 - -15) + -15; - Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL); - ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile)); - tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()) - .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())))); - Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2); - Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0); - } - } - break; - case FIREWORK_STAR: - { - for (int i = 0; i < 4; i++) { - Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SMALL_FIREBALL); - arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()) - .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())))); - Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2); - } - } - break; - } - +// +// public void Shoot(Location loc, float loadedFuel, Material LoadedProjectile) { +// +// switch (LoadedProjectile) { +// +// case COBBLESTONE: +// case COPPER_BLOCK: +// { +// float randomVar = random.nextFloat() * (6 - -6) + -6; +// loc.setYaw(loc.getYaw() + randomVar); +// Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL); +// ClickHandler.projectiles.put(tnt.getUniqueId(), ); +// tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel)); +// Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2); +// Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0); +// } +// break; +// case GRAVEL: +// { + +// } +// break; +// case TNT: +// { +// for (int i = 0; i < 5; i++) { +// //float randomVar = random.nextFloat() * (15 - -15) + -15; +// Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL); +// ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile)); +// tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()) +// .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())))); +// Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2); +// Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0); +// } +// } +// break; +// case FIREWORK_STAR: +// { +// for (int i = 0; i < 4; i++) { +// Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SMALL_FIREBALL); +// arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()) +// .subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())))); +// Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2); +// } +// } +// break; +// } +// +// +// } - } - } diff --git a/src/siegeCore/SiegeProjectile.java b/src/siegeCore/SiegeProjectile.java deleted file mode 100644 index 4d927c6..0000000 --- a/src/siegeCore/SiegeProjectile.java +++ /dev/null @@ -1,15 +0,0 @@ -package siegeCore; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class SiegeProjectile { - - public int Radius = 2; - public Boolean DoFire = false; - - public SiegeProjectile(int rad, boolean fire) { - Radius = rad; - DoFire = fire; - } -}