diff --git a/bin/siegeCore/ClickHandler.class b/bin/siegeCore/ClickHandler.class index eba055b..d21e75b 100644 Binary files a/bin/siegeCore/ClickHandler.class and b/bin/siegeCore/ClickHandler.class differ diff --git a/bin/siegeCore/CrunchSiegeCore.class b/bin/siegeCore/CrunchSiegeCore.class index 6e6f340..f2fa0b8 100644 Binary files a/bin/siegeCore/CrunchSiegeCore.class and b/bin/siegeCore/CrunchSiegeCore.class differ diff --git a/bin/siegeCore/RotationHandler.class b/bin/siegeCore/RotationHandler.class index 6b6d734..d022463 100644 Binary files a/bin/siegeCore/RotationHandler.class and b/bin/siegeCore/RotationHandler.class differ diff --git a/bin/siegeCore/SiegeEquipment.class b/bin/siegeCore/SiegeEquipment.class index 9b4e2b7..d996b1f 100644 Binary files a/bin/siegeCore/SiegeEquipment.class and b/bin/siegeCore/SiegeEquipment.class differ diff --git a/src/siegeCore/ClickHandler.java b/src/siegeCore/ClickHandler.java index 90026c2..448ddc2 100644 --- a/src/siegeCore/ClickHandler.java +++ b/src/siegeCore/ClickHandler.java @@ -65,7 +65,9 @@ public class ClickHandler implements Listener { public void Shoot(Player player) { + int delay = 6; for (Entity ent : CrunchSiegeCore.TrackedStands.get(player.getUniqueId())){{ + if (ent == null || ent.isDead()) { continue; } @@ -86,9 +88,10 @@ public class ClickHandler implements Listener { } else { player.sendMessage("Cannot fire, missing cobblestone, requires 10 per shot"); - return; + continue; } - siege.Fire(player); + siege.Fire(player, delay); + delay += 6; } } @@ -176,19 +179,16 @@ public class ClickHandler implements Listener { public void onPlayerClickSign(PlayerInteractEvent event){ Player p = event.getPlayer(); if(event.getClickedBlock() != null && event.getClickedBlock().getType().toString().contains("SIGN")){ + Sign sign = (Sign) event.getClickedBlock().getState(); + if(sign.getLine(0).equalsIgnoreCase( "[Cannon]")){ if(event.getAction() == Action.RIGHT_CLICK_BLOCK){ - Sign sign = (Sign) event.getClickedBlock().getState(); - //^^ .getState(); really important - if(sign.getLine(0).equalsIgnoreCase( "[Cannon]")){ NamespacedKey key = new NamespacedKey(CrunchSiegeCore.plugin, "cannons"); TileState state = (TileState) sign.getBlock().getState(); - + CrunchSiegeCore.TrackedStands.remove(p.getUniqueId()); List temp = new ArrayList(); - event.getPlayer().sendMessage("1"); if (!state.getPersistentDataContainer().has(key, PersistentDataType.STRING)) { return; } - event.getPlayer().sendMessage("2"); String[] split = state.getPersistentDataContainer().get(key, PersistentDataType.STRING).replace("[", "").replace("]", "").split(","); for (String s : split) { p.sendMessage(s.trim()); @@ -203,6 +203,10 @@ public class ClickHandler implements Listener { } } } + if (event.getAction() == Action.LEFT_CLICK_BLOCK) { + CrunchSiegeCore.TrackedStands.remove(p.getUniqueId()); + p.sendMessage("Releasing the cannons!"); + } } } diff --git a/src/siegeCore/CrunchSiegeCore.java b/src/siegeCore/CrunchSiegeCore.java index 0a2ddc4..10bdfe7 100644 --- a/src/siegeCore/CrunchSiegeCore.java +++ b/src/siegeCore/CrunchSiegeCore.java @@ -156,8 +156,8 @@ public class CrunchSiegeCore extends JavaPlugin { stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING); ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1)); - // stand.setSmall(true); - // stand.setVisible(true); + stand.setSmall(true); + stand.setVisible(true); //stand.setSmall(true); ent.getEquipment().setHelmet(item); if (TrackedStands.containsKey(player.getUniqueId())) { diff --git a/src/siegeCore/RotationHandler.java b/src/siegeCore/RotationHandler.java index c17a2c8..d8fa6d3 100644 --- a/src/siegeCore/RotationHandler.java +++ b/src/siegeCore/RotationHandler.java @@ -53,6 +53,7 @@ public class RotationHandler implements Listener { if (equipment.RotateUpDown) { stand.setHeadPose(new EulerAngle(player.getLocation().getDirection().getY()*(-1),0,0)); + loc.setPitch(player.getLocation().getPitch()); } diff --git a/src/siegeCore/SiegeEquipment.java b/src/siegeCore/SiegeEquipment.java index ca29692..e4ad71d 100644 --- a/src/siegeCore/SiegeEquipment.java +++ b/src/siegeCore/SiegeEquipment.java @@ -7,12 +7,14 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; public class SiegeEquipment implements Cloneable { @@ -30,6 +32,9 @@ public class SiegeEquipment implements Cloneable { public String WorldName; + public int XOffset = 5; + public int YOffset = 0; + public int FuseTime; public double Velocity = 3; public long NextShotTime = System.currentTimeMillis(); @@ -41,7 +46,7 @@ public class SiegeEquipment implements Cloneable { public Location location; public int ModelNumberToFireAt; public Boolean CycleThroughModelsBeforeFiring = false; - public Boolean RotateSideways = true; + public Boolean RotateSideways = false; public Boolean RotateUpDown = true; public Boolean HasFired = false; @@ -61,9 +66,11 @@ public class SiegeEquipment implements Cloneable { EntityId = id; } - public void Fire(Player player) { + public void Fire(Player player, int delay) { LivingEntity living = (LivingEntity) Entity; Location loc = living.getEyeLocation(); + Vector direction = Entity.getLocation().getDirection().multiply(XOffset); + loc.add(direction); Random random = new Random(); float randomVar = random.nextFloat() * (7 - -7) + -7; @@ -73,7 +80,7 @@ public class SiegeEquipment implements Cloneable { this.NextShotTime = System.currentTimeMillis() + 6000; player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis())); this.WorldName = Entity.getWorld().getName(); - Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_BAT_DEATH, 20, 2); + if (this.CycleThroughModelsBeforeFiring) { @@ -117,7 +124,7 @@ public class SiegeEquipment implements Cloneable { ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile); tnt.setVelocity(loc.getDirection().multiply(this.Velocity)); - + Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_BAT_DEATH, 20, 2); } this.NextModelNumber += 1; @@ -129,10 +136,16 @@ public class SiegeEquipment implements Cloneable { }, 0, this.MillisecondsBetweenFiringStages); } else { - Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL); - - ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile); - tnt.setVelocity(loc.getDirection().multiply(this.Velocity)); + + this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> { + //player.sendMessage("task"); + Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL); + ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile); + tnt.setVelocity(loc.getDirection().multiply(this.Velocity)); + Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2); + Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.SMOKE_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0); + }, delay); + } }