mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 14:38:55 +00:00
Hopefully fix Repeated Firing issues
*Crosses fingers*
This commit is contained in:
1 parent
fd5281ecc3
commit
8d526969ae
3 files changed
+36
-9
No files matched your search
@@ -181,6 +181,7 @@ public class ClickHandler implements Listener {
|
||||
public void Shoot(Entity player, long delay) {
|
||||
float actualDelay = delay;
|
||||
Boolean FirstShot = true;
|
||||
int counter = 0;
|
||||
if (GunnersCore.TrackedStands.get(player.getUniqueId()) == null) {
|
||||
for (Entity ent : player.getNearbyEntities(5, 5, 5)) {
|
||||
if(ent instanceof ArmorStand) {
|
||||
@@ -193,9 +194,14 @@ public class ClickHandler implements Listener {
|
||||
}
|
||||
if (GunnersCore.TrackedStands.get(player.getUniqueId()) == null)
|
||||
return;
|
||||
int counter = 0;
|
||||
for (Entity ent : GunnersCore.TrackedStands.get(player.getUniqueId())){
|
||||
List<Entity> entities = new ArrayList<>(GunnersCore.TrackedStands.get(player.getUniqueId()));
|
||||
for (Entity ent : entities){
|
||||
if (ent == null || ent.isDead()) {
|
||||
GunnersCore.TrackedStands.get(player.getUniqueId()).remove(ent);
|
||||
continue;
|
||||
}
|
||||
if (((LivingEntity) ent).getEquipment().getHelmet().getType() != Material.CARVED_PUMPKIN) {
|
||||
GunnersCore.TrackedStands.get(player.getUniqueId()).remove(ent);
|
||||
continue;
|
||||
}
|
||||
double distance = player.getLocation().distance(ent.getLocation());
|
||||
@@ -204,15 +210,19 @@ public class ClickHandler implements Listener {
|
||||
}
|
||||
GunnerEquipment siege = GunnersCore.equipment.get(ent.getUniqueId());
|
||||
if (counter > 4)
|
||||
return;
|
||||
if (ent == null || ent.isDead()) {
|
||||
GunnersCore.TrackedStands.get(player.getUniqueId()).remove(ent);
|
||||
continue;
|
||||
}
|
||||
if (siege.isLoaded()) {
|
||||
counter++;
|
||||
if (player instanceof Player) {
|
||||
siege.Fire(player, actualDelay,0);
|
||||
siege.Fire(player, actualDelay,1);
|
||||
actualDelay += delay;
|
||||
} else {
|
||||
siege.Fire(player,15,1);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
else {
|
||||
if (player instanceof Player) {}
|
||||
|
||||
@@ -35,12 +35,12 @@ public class GunnerEquipment implements Cloneable {
|
||||
public Boolean Enabled = true;
|
||||
public UUID EntityId;
|
||||
public Entity Entity;
|
||||
public Integer shotAmount = 3;
|
||||
public Integer shotAmount = 1;
|
||||
|
||||
public HashMap<ItemStack, GunnersProjectile> Projectiles = new HashMap<ItemStack, GunnersProjectile>();
|
||||
|
||||
public String WorldName;
|
||||
public String EquipmentName = "Basic Cannon";
|
||||
public String EquipmentName = "Peckle Gun";
|
||||
public int XOffset = 7;
|
||||
public int YOffset = 0;
|
||||
public int PitchOffset = 0;
|
||||
@@ -199,14 +199,24 @@ public class GunnerEquipment implements Cloneable {
|
||||
this.WorldName = Entity.getWorld().getName();
|
||||
this.NextShotTime = System.currentTimeMillis() + 1000;
|
||||
for (int i = 0; i <= this.shotAmount /* range */; i+= 1) {
|
||||
if (living == null || living.isDead()) {
|
||||
return;
|
||||
}
|
||||
if (this.CycleThroughModelsBeforeFiring) {
|
||||
|
||||
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(GunnersCore.plugin, () -> {
|
||||
if (living == null || living.isDead()) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.HasFired) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(GunnersCore.plugin, () -> {
|
||||
|
||||
if (living == null || living.isDead()) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
return;
|
||||
}
|
||||
// player.sendMessage("§etask");
|
||||
if (this.HasReloaded) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
@@ -252,9 +262,12 @@ public class GunnerEquipment implements Cloneable {
|
||||
}
|
||||
}, 0, this.MillisecondsBetweenFiringStages);
|
||||
} else {
|
||||
|
||||
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GunnersCore.plugin, () -> {
|
||||
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GunnersCore.plugin, () -> {
|
||||
//player.sendMessage("§etask");
|
||||
if (living == null || living.isDead()) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = living.getEyeLocation();
|
||||
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
|
||||
|
||||
@@ -210,6 +210,7 @@ public class GunnersCore extends JavaPlugin {
|
||||
|
||||
return timeLeftFormatted;
|
||||
}
|
||||
|
||||
public static GunnerEquipment CreateNewGun(String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack,GunnersProjectile> projObj) {
|
||||
GunnerEquipment equip = new GunnerEquipment();
|
||||
if (customModelId == null || customModelId == 0)
|
||||
@@ -261,6 +262,7 @@ public class GunnersCore extends JavaPlugin {
|
||||
equip.VelocityPerFuel = 0.3f;
|
||||
ExplosiveProjectile proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 2;
|
||||
equip.shotAmount = 1;
|
||||
equip.RotateStandHead = false;
|
||||
equip.RotateSideways = true;
|
||||
equip.FuelMaterial = new ItemStack(Material.STRING);
|
||||
@@ -279,6 +281,7 @@ public class GunnersCore extends JavaPlugin {
|
||||
equip.EquipmentName = "Naval Cannon";
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.shotAmount = 1;
|
||||
equip.ReadyModelNumber = 142;
|
||||
equip.ModelNumberToFireAt = 142;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
@@ -306,6 +309,7 @@ public class GunnersCore extends JavaPlugin {
|
||||
equip.EquipmentName = "Siege Cannon";
|
||||
proj.ExplodePower = 2;
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.shotAmount = 1;
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.ReadyModelNumber = 141;
|
||||
equip.ModelNumberToFireAt = 141;
|
||||
|
||||
Reference in new issue
Block a user