Added Engine-Health Configuration

This commit is contained in:
C_Corp2002 authored and GitHub committed 2024-01-31 20:31:28 -05:00
1 parent 2a8f69697c
commit 64358e9b80
5 files changed
+29 -13

No files matched your search

@@ -48,7 +48,7 @@ public class SiegeEngine implements Cloneable {
private int maxFuel;
private double placementOffsetY;
private float velocityPerFuel;
private double baseHealth = 5.0d;
// Firing variables
private int shotAmount;
private long nextShotTime; // Internal
@@ -469,10 +469,12 @@ public class SiegeEngine implements Cloneable {
}*/
for (Entity enti : l.getWorld().getNearbyEntities(l,2.5d,2.5d,2.5d)) {
if (SiegeEngines.activeSiegeEngines.keySet().contains(enti.getUniqueId())) {
ent.damage(20.0d, player);
ent.setHealth(0.0d);
return false;
}
}
stand.setMaxHealth(baseHealth);
stand.setHealth(baseHealth);
SiegeEngines.activeSiegeEngines.put(stand.getUniqueId(), this);
ClickHandler.TakeControl(player,stand);
if (mount != null && !(mount.isDead())) {
@@ -530,6 +532,14 @@ public class SiegeEngine implements Cloneable {
this.worldName = worldName;
}
public double getHealth() {
return baseHealth;
}
public void setHealth(double health) {
this.baseHealth = health;
}
public Entity getEntity() {
return entity;
}
@@ -47,6 +47,7 @@ public class Config {
public static float trebuchetVelocityPerFuel = 0.3f;
public static int trebuchetMaxFuel = 3;
public static Material trebuchetFuelItem = Material.STRING;
public static double trebuchetHealth = 8d;
public static boolean trebuchetCanMount = false;
public static HashMap<ItemStack, SiegeEngineProjectile> trebuchetProjectiles = new HashMap<>();
public static String trebuchetItemName = "&e&oTrebuchet";
@@ -54,6 +55,7 @@ public class Config {
public static int ballistaShotAmount = 1;
public static float ballistaVelocityPerFuel = 0.925f;
public static double ballistaHealth = 5d;
public static int ballistaMaxFuel = 4;
public static Material ballistaFuelItem = Material.STRING;
public static boolean ballistaCanMount = false;
@@ -63,6 +65,7 @@ public class Config {
public static int swivelCannonShotAmount = 1;
public static float swivelCannonVelocityPerFuel = 1.0125f;
public static double swivelCannonHealth = 15d;
public static int swivelCannonMaxFuel = 5;
public static Material swivelCannonFuelItem = Material.GUNPOWDER;
public static boolean swivelCannonCanMount = false;
@@ -72,6 +75,7 @@ public class Config {
public static int breachCannonShotAmount = 1;
public static float breachCannonVelocityPerFuel = 1.075f;
public static double breachCannonHealth = 25d;
public static int breachCannonMaxFuel = 4;
public static Material breachCannonFuelItem = Material.GUNPOWDER;
public static boolean breachCannonCanMount = false;
@@ -110,6 +114,7 @@ public class Config {
}
private static void loadTrebuchetValues() {
trebuchetHealth = config.getDouble("SiegeEngines.Trebuchet.Health");
trebuchetShotAmount = config.getInt("SiegeEngines.Trebuchet.ShotAmount");
trebuchetVelocityPerFuel = (float) config.getDouble("SiegeEngines.Trebuchet.VelocityPerFuel");
trebuchetMaxFuel = config.getInt("SiegeEngines.Trebuchet.MaxFuel");
@@ -135,6 +140,7 @@ public class Config {
}
private static void loadBallistaValues() {
ballistaHealth = config.getDouble("SiegeEngines.Ballista.Health");
ballistaShotAmount = config.getInt("SiegeEngines.Ballista.ShotAmount");
ballistaVelocityPerFuel = (float) config.getDouble("SiegeEngines.Ballista.VelocityPerFuel");
ballistaMaxFuel = config.getInt("SiegeEngines.Ballista.MaxFuel");
@@ -161,6 +167,7 @@ public class Config {
}
private static void loadSwivelCannonValues() {
swivelCannonHealth = config.getDouble("SiegeEngines.SwivelCannon.Health");
swivelCannonShotAmount = config.getInt("SiegeEngines.SwivelCannon.ShotAmount");
swivelCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.SwivelCannon.VelocityPerFuel");
swivelCannonMaxFuel = config.getInt("SiegeEngines.SwivelCannon.MaxFuel");
@@ -187,6 +194,7 @@ public class Config {
}
private static void loadBreachCannonValues() {
breachCannonHealth = config.getDouble("SiegeEngines.BreachCannon.Health");
breachCannonShotAmount = config.getInt("SiegeEngines.BreachCannon.ShotAmount");
breachCannonVelocityPerFuel = (float) config.getDouble("SiegeEngines.BreachCannon.VelocityPerFuel");
breachCannonMaxFuel = config.getInt("SiegeEngines.BreachCannon.MaxFuel");
@@ -596,22 +596,16 @@ public class ClickHandler implements Listener {
}
@EventHandler(priority = EventPriority.LOW)
public void onEngineDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof ArmorStand) {
if (event.isCancelled()) return;
PlayerHandler.siegeEngineEntityDied(event.getEntity());
}
}
@EventHandler(priority = EventPriority.LOW)
public void onEngineDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof ArmorStand) {
if (event.isCancelled()) return;
if (event.getDamager() instanceof Player) {
PlayerHandler.siegeEngineEntityDied(event.getEntity());
event.setDamage(20);
} else {
event.setDamage(5);
}
event.setDamage(20);
}
}
@@ -51,7 +51,7 @@ public class PlayerHandler implements Listener {
}
SiegeEnginesLogger.debug("ENGINE DISABLED/DEAD "+entity.getUniqueId().toString());
}
Bukkit.getPlayer(uuid).sendMessage("§eSiegeEngine Destroyed!");
Bukkit.getPlayer(uuid).sendMessage("§eSiege Engine Destroyed!");
for (UUID eUuid : SiegeEngines.activeSiegeEngines.keySet()) {
if (Bukkit.getEntity(eUuid) == null || Bukkit.getEntity(eUuid).isDead() || !Bukkit.getEntity(eUuid).isValid()) {
SiegeEngines.activeSiegeEngines.remove(eUuid);
@@ -123,7 +123,7 @@ public class PlayerHandler implements Listener {
SiegeEnginesLogger.debug("LEFT-OVER ENGINES? "+SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).toString());
}
list.clear();
player.sendMessage("§eReleased all SiegeEngines!");
player.sendMessage("§eReleased all Siege Engines!");
SiegeEngines.siegeEngineEntitiesPerPlayer.put(uuid,list);
SiegeEngines.siegeEngineEntitiesPerPlayer.get(uuid).clear();
SiegeEngines.siegeEngineEntitiesPerPlayer.remove(uuid);
+4
View File
@@ -114,6 +114,7 @@ Projectiles:
SiegeEngines:
Trebuchet:
Health: 8
ShotAmount: 1
VelocityPerFuel: 0.75
MaxFuel: 3
@@ -128,6 +129,7 @@ SiegeEngines:
- "&ePlace as a block to spawn a Trebuchet"
CanMount: false
Ballista:
Health: 5
ShotAmount: 1
VelocityPerFuel: 2.0
MaxFuel: 2
@@ -142,6 +144,7 @@ SiegeEngines:
- "&ePlace as a block to spawn a Ballista"
CanMount: false
SwivelCannon:
Health: 15
ShotAmount: 1
VelocityPerFuel: 0.975
MaxFuel: 5
@@ -157,6 +160,7 @@ SiegeEngines:
- "&ePlace as a block to spawn a Swivel Cannon"
CanMount: false
BreachCannon:
Health: 25
ShotAmount: 1
VelocityPerFuel: 1.0625
MaxFuel: 4