mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-02 06:28:57 +00:00
style: reformat codebase
This commit is contained in:
25 files changed
+2362
-2440
No files matched your search
@@ -2,12 +2,7 @@ package com.github.alathra.siegeengines.projectile;
|
||||
|
||||
import com.github.alathra.siegeengines.SiegeEngines;
|
||||
import com.github.alathra.siegeengines.util.SiegeEnginesUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -15,9 +10,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EntityProjectile extends SiegeEngineProjectile {
|
||||
|
||||
// Defaults
|
||||
public int projectileCount = 20;
|
||||
|
||||
// Defaults
|
||||
public int projectileCount = 20;
|
||||
public int arrowOnlyDamage = 6;
|
||||
public Boolean delayedFire = false;
|
||||
public int delayTime = 6;
|
||||
@@ -27,14 +22,14 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
public float velocityFactor = 1.0f;
|
||||
public float arrowDamageFactor = 1.0f;
|
||||
|
||||
|
||||
private boolean playSound = true;
|
||||
|
||||
|
||||
public EntityProjectile(ItemStack ammunitionItem) {
|
||||
super(ProjectileType.ENTITY, ammunitionItem);
|
||||
|
||||
// Defaults
|
||||
}
|
||||
super(ProjectileType.ENTITY, ammunitionItem);
|
||||
|
||||
// Defaults
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location FireLocation, Float velocity) {
|
||||
@@ -44,17 +39,17 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
CreateEntity(entity, FireLocation, velocity*velocityFactor, player);
|
||||
}, (long) baseDelay);
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}, baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, FireLocation, velocity*velocityFactor, player);
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) {
|
||||
World world = entity.getLocation().getWorld();
|
||||
|
||||
|
||||
Entity arrow = world.spawnEntity(loc, entityType);
|
||||
if (inaccuracy != 0f) {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
@@ -68,9 +63,8 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
((org.bukkit.entity.Projectile) arrow).setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
}
|
||||
if (arrow instanceof Arrow) {
|
||||
Arrow arr = (Arrow) arrow;
|
||||
arr.setDamage(8*arrowDamageFactor);
|
||||
if (arrow instanceof Arrow arr) {
|
||||
arr.setDamage(8 * arrowDamageFactor);
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource) {
|
||||
arr.setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
arr.setPickupStatus(org.bukkit.entity.AbstractArrow.PickupStatus.CREATIVE_ONLY);
|
||||
@@ -92,7 +86,7 @@ public class EntityProjectile extends SiegeEngineProjectile {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1));
|
||||
}
|
||||
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,7 @@ package com.github.alathra.siegeengines.projectile;
|
||||
import com.github.alathra.siegeengines.SiegeEngines;
|
||||
import com.github.alathra.siegeengines.data.SiegeEnginesData;
|
||||
import com.github.alathra.siegeengines.util.SiegeEnginesUtil;
|
||||
|
||||
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.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -17,8 +11,8 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class ExplosiveProjectile extends SiegeEngineProjectile {
|
||||
|
||||
|
||||
// Defaults
|
||||
|
||||
// Defaults
|
||||
public Boolean placeBlocks = false;
|
||||
public Material blockToPlace = Material.COBWEB; // TO-DO
|
||||
public int blocksToPlaceAmount = 3; // TO-DO
|
||||
@@ -31,13 +25,13 @@ public class ExplosiveProjectile extends SiegeEngineProjectile {
|
||||
public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
public Boolean alertOnLanding = false;
|
||||
public float velocityFactor = 1.0f;
|
||||
|
||||
|
||||
private boolean playSound = true;
|
||||
|
||||
|
||||
public ExplosiveProjectile(ItemStack ammunitionItem) {
|
||||
super(ProjectileType.EXPLOSIVE, ammunitionItem);
|
||||
}
|
||||
|
||||
super(ProjectileType.EXPLOSIVE, ammunitionItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||
playSound = true;
|
||||
@@ -46,10 +40,10 @@ public class ExplosiveProjectile extends SiegeEngineProjectile {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
CreateEntity(entity, loc, velocity*velocityFactor, player);
|
||||
}, (long) baseDelay);
|
||||
CreateEntity(entity, loc, velocity * velocityFactor, player);
|
||||
}, baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, loc, velocity*velocityFactor, player);
|
||||
CreateEntity(entity, loc, velocity * velocityFactor, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,9 +79,9 @@ public class ExplosiveProjectile extends SiegeEngineProjectile {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1));
|
||||
}
|
||||
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,7 @@ package com.github.alathra.siegeengines.projectile;
|
||||
|
||||
import com.github.alathra.siegeengines.SiegeEngines;
|
||||
import com.github.alathra.siegeengines.util.SiegeEnginesUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
@@ -16,9 +11,9 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
|
||||
// Defaults
|
||||
public int projectileCount = 1;
|
||||
|
||||
// Defaults
|
||||
public int projectileCount = 1;
|
||||
public Boolean delayedFire = true;
|
||||
public int delayTime = 6;
|
||||
public EntityType entityType = EntityType.FIREWORK;
|
||||
@@ -26,16 +21,16 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
public Particle particleType = Particle.FLASH;
|
||||
public Sound soundType = Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR;
|
||||
public float velocityFactor = 1.0f;
|
||||
|
||||
|
||||
private boolean playSound = true;
|
||||
|
||||
|
||||
public FireworkProjectile(ItemStack ammunitionItem) {
|
||||
super(ProjectileType.FIREWORK, ammunitionItem);
|
||||
// Defaults
|
||||
}
|
||||
|
||||
super(ProjectileType.FIREWORK, ammunitionItem);
|
||||
// Defaults
|
||||
}
|
||||
|
||||
public static FireworkProjectile getDefaultRocketShot(ItemStack rocketItem) {
|
||||
FireworkProjectile fireProj = new FireworkProjectile(rocketItem);
|
||||
FireworkProjectile fireProj = new FireworkProjectile(rocketItem);
|
||||
fireProj.projectileCount = 1;
|
||||
fireProj.entityType = EntityType.FIREWORK;
|
||||
fireProj.particleType = Particle.WHITE_ASH;
|
||||
@@ -52,17 +47,17 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
if (delayedFire) {
|
||||
baseDelay += delayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
CreateEntity(entity, FireLocation, velocity*velocityFactor, player);
|
||||
}, (long) baseDelay);
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}, baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, FireLocation, velocity*velocityFactor, player);
|
||||
CreateEntity(entity, FireLocation, velocity * velocityFactor, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) {
|
||||
World world = entity.getLocation().getWorld();
|
||||
|
||||
|
||||
Entity arrow = world.spawnEntity(loc, entityType);
|
||||
if (inaccuracy != 0f) {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
@@ -77,18 +72,17 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
((org.bukkit.entity.Projectile) arrow).setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
}
|
||||
if (arrow instanceof Firework) {
|
||||
Firework firework = (Firework) arrow;
|
||||
if (arrow instanceof Firework firework) {
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource) {
|
||||
firework.setShotAtAngle(true);
|
||||
firework.setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
ItemStack rocketItem = getAmmuinitionItem();
|
||||
if (rocketItem.getItemMeta() instanceof FireworkMeta) {
|
||||
firework.setFireworkMeta((FireworkMeta)rocketItem.getItemMeta());
|
||||
firework.setFireworkMeta((FireworkMeta) rocketItem.getItemMeta());
|
||||
}
|
||||
int fuse = firework.getMaxLife();
|
||||
int itemPower = 1+firework.getFireworkMeta().getPower();
|
||||
fuse = fuse + (5*itemPower);
|
||||
int itemPower = 1 + firework.getFireworkMeta().getPower();
|
||||
fuse = fuse + (5 * itemPower);
|
||||
firework.setMaxLife(fuse);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +100,7 @@ public class FireworkProjectile extends SiegeEngineProjectile {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1));
|
||||
}
|
||||
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,7 @@ package com.github.alathra.siegeengines.projectile;
|
||||
|
||||
import com.github.alathra.siegeengines.SiegeEngines;
|
||||
import com.github.alathra.siegeengines.util.SiegeEnginesUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
@@ -16,7 +11,7 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PotionProjectile extends SiegeEngineProjectile {
|
||||
|
||||
|
||||
public int projectileCount = 3;
|
||||
public Boolean delayedFire = false;
|
||||
public int delayTime = 6;
|
||||
@@ -26,8 +21,8 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
public float velocityFactor = 1.0f;
|
||||
|
||||
public PotionProjectile(ItemStack ammunitionItem) {
|
||||
super(ProjectileType.POTION, ammunitionItem);
|
||||
}
|
||||
super(ProjectileType.POTION, ammunitionItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||
@@ -39,7 +34,7 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}, (long) baseDelay);
|
||||
}, baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}
|
||||
@@ -60,7 +55,7 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
ItemStack itemStack = this.getAmmuinitionItem();
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
System.out.println(potionMeta.toString());
|
||||
System.out.println(itemStack.toString());
|
||||
System.out.println(itemStack);
|
||||
potionMeta.getBasePotionData();
|
||||
itemStack.setItemMeta(potionMeta);
|
||||
ThrownPotion potion = (ThrownPotion) arrow;
|
||||
@@ -73,7 +68,7 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1));
|
||||
}
|
||||
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
public ProjectileType getProjectileType() {
|
||||
return projectileType;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.github.alathra.siegeengines.projectile;
|
||||
|
||||
public enum ProjectileType {
|
||||
DEFAULT, ENTITY, EXPLOSIVE, FIREWORK, POTION;
|
||||
DEFAULT, ENTITY, EXPLOSIVE, FIREWORK, POTION
|
||||
}
|
||||
+15
-15
@@ -6,23 +6,23 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class SiegeEngineProjectile {
|
||||
|
||||
protected ProjectileType projectileType;
|
||||
protected ItemStack ammunitionItem;
|
||||
|
||||
public SiegeEngineProjectile(ProjectileType projectileType, @NotNull ItemStack ammunitionItem ) {
|
||||
this.projectileType = projectileType;
|
||||
this.ammunitionItem = ammunitionItem;
|
||||
}
|
||||
|
||||
public abstract void Shoot(Entity player, Entity entity, Location fireLocation, Float velocity);
|
||||
|
||||
public ProjectileType getType() {
|
||||
return projectileType;
|
||||
|
||||
protected ProjectileType projectileType;
|
||||
protected ItemStack ammunitionItem;
|
||||
|
||||
public SiegeEngineProjectile(ProjectileType projectileType, @NotNull ItemStack ammunitionItem) {
|
||||
this.projectileType = projectileType;
|
||||
this.ammunitionItem = ammunitionItem;
|
||||
}
|
||||
|
||||
|
||||
public abstract void Shoot(Entity player, Entity entity, Location fireLocation, Float velocity);
|
||||
|
||||
public ProjectileType getType() {
|
||||
return projectileType;
|
||||
}
|
||||
|
||||
public ItemStack getAmmuinitionItem() {
|
||||
return ammunitionItem;
|
||||
return ammunitionItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user