mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-02 06:28:57 +00:00
refactor: npe fixes & code maturity
This commit is contained in:
20 files changed
+215
-239
No files matched your search
@@ -14,8 +14,8 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
// Defaults
|
||||
public int projectileCount = 20;
|
||||
public int arrowOnlyDamage = 6;
|
||||
public Boolean delayedFire = false;
|
||||
public int delayTime = 6;
|
||||
public final Boolean delayedFire = false;
|
||||
public final int delayTime = 6;
|
||||
public EntityType entityType = EntityType.ARROW;
|
||||
public float inaccuracy = 0.2f;
|
||||
public Particle particleType = Particle.CAMPFIRE_SIGNAL_SMOKE;
|
||||
@@ -38,9 +38,7 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
for (int i = 0; i < projectileCount; i++) {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}, baseDelay);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> CreateEntity(entity, FireLocation, velocity * velocityFactor, player), baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}
|
||||
|
||||
@@ -13,15 +13,15 @@ public class ExplosiveProjectile extends SiegeEngineProjectile {
|
||||
|
||||
|
||||
// Defaults
|
||||
public Boolean placeBlocks = false;
|
||||
public Material blockToPlace = Material.COBWEB; // TO-DO
|
||||
public int blocksToPlaceAmount = 3; // TO-DO
|
||||
public final Boolean placeBlocks = false;
|
||||
public final Material blockToPlace = Material.COBWEB; // TO-DO
|
||||
public final int blocksToPlaceAmount = 3; // TO-DO
|
||||
public float explodePower = 2.0f;
|
||||
public float inaccuracy = 0.3f;
|
||||
public int projectilesCount = 1;
|
||||
public Boolean delayedFire = false;
|
||||
public int delayTime = 6;
|
||||
public Particle particleType = Particle.EXPLOSION_LARGE;
|
||||
public final Boolean delayedFire = false;
|
||||
public final int delayTime = 6;
|
||||
public final Particle particleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
public Boolean alertOnLanding = false;
|
||||
public float velocityFactor = 1.0f;
|
||||
@@ -39,9 +39,7 @@ public class ExplosiveProjectile extends SiegeEngineProjectile {
|
||||
for (int i = 0; i < projectilesCount; i++) {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
CreateEntity(entity, loc, velocity * velocityFactor, player);
|
||||
}, baseDelay);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> CreateEntity(entity, loc, velocity * velocityFactor, player), baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, loc, velocity * velocityFactor, player);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,7 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
for (int i = 0; i < projectileCount; i++) {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}, baseDelay);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> CreateEntity(entity, FireLocation, velocity * velocityFactor, player), baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}
|
||||
@@ -80,10 +78,10 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
if (rocketItem.getItemMeta() instanceof FireworkMeta) {
|
||||
firework.setFireworkMeta((FireworkMeta) rocketItem.getItemMeta());
|
||||
}
|
||||
int fuse = firework.getMaxLife();
|
||||
int fuse = firework.getTicksToDetonate();
|
||||
int itemPower = 1 + firework.getFireworkMeta().getPower();
|
||||
fuse = fuse + (5 * itemPower);
|
||||
firework.setMaxLife(fuse);
|
||||
firework.setTicksToDetonate(fuse);
|
||||
}
|
||||
}
|
||||
if (playSound) {
|
||||
|
||||
@@ -16,8 +16,8 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
public Boolean delayedFire = false;
|
||||
public int delayTime = 6;
|
||||
public float inaccuracy = 0.1f;
|
||||
public Particle particleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
public final Particle particleType = Particle.EXPLOSION_LARGE;
|
||||
public final Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
public float velocityFactor = 1.0f;
|
||||
|
||||
public PotionProjectile(ItemStack ammunitionItem) {
|
||||
@@ -31,10 +31,7 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
for (int i = 0; i < projectileCount; i++) {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}, baseDelay);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> CreateEntity(entity, loc, velocity), baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class SiegeEngineProjectile {
|
||||
|
||||
protected ProjectileType projectileType;
|
||||
protected ItemStack ammunitionItem;
|
||||
protected final ProjectileType projectileType;
|
||||
protected final ItemStack ammunitionItem;
|
||||
|
||||
public SiegeEngineProjectile(ProjectileType projectileType, @NotNull ItemStack ammunitionItem) {
|
||||
this.projectileType = projectileType;
|
||||
|
||||
Reference in new issue
Block a user