This commit is contained in:
ShermansWorld committed 2024-01-06 19:45:58 -05:00
1 parent 6250d17520
commit 6e36cce455
6 files changed
+482 -516

No files matched your search

@@ -0,0 +1,343 @@
package com.github.alathra.siegeengines;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import com.github.alathra.siegeengines.projectile.EntityProjectile;
import com.github.alathra.siegeengines.projectile.GunnersProjectile;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
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;
import org.jetbrains.annotations.NotNull;
public class SiegeEngine implements Cloneable {
// Core variables
public Boolean enabled;
public String id;
public String worldName;
public UUID entityId;
public Entity entity;
public int yOffset;
public int xOffset;
public int pitchOffset;
public int maxFuel;
public double placementOffsetY;
public float velocityPerFuel;
// Firing variables
public int shotAmount;
public long nextShotTime;
public int millisecondsBetweenFiringStages;
public int millisecondsBetweenReloadingStages;
public int millisecondsToLoad;
public int modelNumberToFireAt;
public boolean cycleThroughModelsBeforeFiring;
public boolean rotateSideways;
public boolean rotateUpDown;
public boolean rotateStandHead;
public boolean hasFired;
public boolean hasReloaded;
public int taskNumber;
public List<Integer> firingModelNumbers;
public int readyModelNumber;
public int nextModelNumber;
public EquipmentMagazine ammoHolder;
// Optional variables
public boolean allowInvisibleStand;
public boolean hasBaseStand;
public double baseStandOffset;
public int baseStandModelNumber;
// Passed parameters
public String name = "Unnammed Siege Engine";
public ItemStack fuelItem = new ItemStack(Material.GUNPOWDER);
public HashMap<ItemStack, GunnersProjectile> projectiles;
public int customModelID = 150;
@Override
public SiegeEngine clone() throws CloneNotSupportedException {
return (SiegeEngine) super.clone();
}
public SiegeEngine(@NotNull String name, @NotNull HashMap<ItemStack, GunnersProjectile> projectiles, @NotNull ItemStack fuelItem, int customModelID) {
//String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj
// Default custom model data id if it is passes as null
if (customModelID == 0) {
customModelID = 150;
}
// Set Default values
xOffset = 0;
yOffset = 0;
maxFuel = 5;
velocityPerFuel = 1.0125f;
id = name.replaceAll(" ", "_").toLowerCase();
rotateStandHead = true;
rotateSideways = true;
placementOffsetY = -1.125f;
readyModelNumber = customModelID;
modelNumberToFireAt = customModelID;
firingModelNumbers = new ArrayList<Integer>();
ammoHolder = new EquipmentMagazine();
//fuelItem = new ItemStack(Material.GUNPOWDER);
cycleThroughModelsBeforeFiring = false;
allowInvisibleStand = false;
shotAmount = 1;
ammoHolder.LoadedFuel = maxFuel;
enabled = true;
cycleThroughModelsBeforeFiring = false;
rotateSideways = false;
rotateUpDown = true;
rotateStandHead = true;
hasFired = false;
hasReloaded = false;
allowInvisibleStand = false;
hasBaseStand = false;
baseStandOffset = 0;
baseStandModelNumber = 147;
nextShotTime = System.currentTimeMillis();
EntityProjectile defaultProj = new EntityProjectile();
defaultProj.EntityCount = 2;
defaultProj.EntityTyp = EntityType.SHULKER_BULLET;
defaultProj.ParticleType = Particle.WHITE_ASH;
defaultProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
if (projectiles.keySet().isEmpty() || projectiles.isEmpty())
projectiles.put(new ItemStack(Material.GUNPOWDER), defaultProj);
for (ItemStack mat : projectiles.keySet()) {
projectiles.put(mat, projectiles.get(mat));
}
// set passed parameters as object variables
this.name = name;
this.projectiles = projectiles;
this.fuelItem = fuelItem;
this.customModelID = customModelID;
}
public boolean equals(String EquipmentId) {
return id.equals(EquipmentId);
}
public Boolean isLoaded() {
if (this.maxFuel <= 0 && ammoHolder.LoadedProjectile >= 1)
return true;
return (ammoHolder.LoadedFuel > 0 && ammoHolder.LoadedProjectile >= 1);
}
public Boolean CanLoadFuel() {
return ammoHolder.LoadedFuel < maxFuel;
}
public Boolean LoadFuel(Entity player) {
if (ammoHolder.LoadedFuel == maxFuel) {
return true;
}
if (!(player instanceof Player)) {
ammoHolder.LoadedFuel = maxFuel;
return true;
}
if (((Player) player).getInventory().containsAtLeast(fuelItem, 1) || fuelItem.getType() == Material.AIR) {
if (CanLoadFuel()) {
this.ammoHolder.LoadedFuel += 1;
//SaveState();
((Player) player).getInventory().removeItem(fuelItem);
((Player) player).sendMessage("§eLoaded " + ammoHolder.LoadedFuel + "/" + maxFuel);
return true;
} else {
return false;
}
}
return false;
}
public Boolean LoadProjectile(Entity player, ItemStack itemInHand) {
if (itemInHand.getAmount() <= 0) {
return false;
}
if (!(player instanceof Player)) {
ammoHolder.LoadedProjectile = 1;
ammoHolder.LoadedFuel = maxFuel;
ammoHolder.MaterialName = itemInHand;
return true;
}
if (projectiles.containsKey(itemInHand.getType()) && ammoHolder.LoadedProjectile == 0) {
ammoHolder.LoadedProjectile = 1;
ammoHolder.MaterialName = itemInHand;
((Player) player).sendMessage("§eAdding Ammunition to Weapon");
itemInHand.setAmount(itemInHand.getAmount() - 1);
return true;
}
return false;
}
public Location GetFireLocation(LivingEntity living) {
if (living == null)
return null;
Location loc = living.getEyeLocation();
Vector direction = living.getLocation().getDirection().multiply(xOffset);
loc.add(direction);
if (yOffset > 0) {
loc.setY(loc.getY() + yOffset);
} else {
loc.setY(loc.getY() - yOffset);
}
loc.setPitch(loc.getPitch() + pitchOffset);
return loc;
}
public void ShowFireLocation(Entity player) {
LivingEntity living = (LivingEntity) entity;
if (player instanceof Player) {
if (living != null) {
Location origin = this.GetFireLocation(living);
Vector direction = origin.getDirection();
direction.multiply(5 /* the range */);
Location destination = origin.clone().add(direction);
direction.normalize();
for (int i = 0; i < 3 /* range */; i += 1) {
Location spawn = origin.add(direction);
((Player) player).spawnParticle(Particle.CLOUD, spawn, 1, 0, 0, 0, 0);
}
}
}
}
public void Fire(Entity player, float delay, Integer amount) {
if (amount == null || amount == 0)
amount = this.shotAmount;
this.shotAmount = amount;
if (System.currentTimeMillis() < nextShotTime) {
return;
}
if (ammoHolder.LoadedFuel <= 0)
ammoHolder.LoadedFuel = 0;
float loadedFuel = ammoHolder.LoadedFuel;
ItemStack LoadedProjectile = ammoHolder.MaterialName;
LivingEntity living = (LivingEntity) entity;
if (living == null || living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) {
return;
}
if (living.getEquipment().getHelmet().getItemMeta().getCustomModelData() != readyModelNumber) {
if (player instanceof Player) {
((Player) player).sendMessage("§eCannot fire yet!");
}
return;
}
ammoHolder.LoadedFuel = 0;
ammoHolder.LoadedProjectile = 0;
ammoHolder.MaterialName = new ItemStack(Material.AIR, 1);
worldName = entity.getWorld().getName();
nextShotTime = System.currentTimeMillis() + 1000;
//for (int i = 0; i <= this.shotAmount /* range */; i += 1) {
if (living == null || living.isDead()) {
return;
}
if (cycleThroughModelsBeforeFiring) {
this.taskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(SiegeEngines.plugin, () -> {
if (living == null || living.isDead()) {
Bukkit.getServer().getScheduler().cancelTask(taskNumber);
return;
}
if (hasFired) {
Bukkit.getServer().getScheduler().cancelTask(taskNumber);
taskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(SiegeEngines.plugin, () -> {
if (living == null || living.isDead()) {
Bukkit.getServer().getScheduler().cancelTask(taskNumber);
return;
}
// player.sendMessage("§etask");
if (hasReloaded) {
Bukkit.getServer().getScheduler().cancelTask(taskNumber);
hasReloaded = false;
hasFired = false;
nextModelNumber = 0;
SiegeEngines.UpdateEntityIdModel(entity, readyModelNumber, worldName);
taskNumber = 0;
} else {
//firing stages
if (nextModelNumber - 1 <= firingModelNumbers.size() && nextModelNumber - 1 >= 0) {
int modelData = firingModelNumbers.get(nextModelNumber - 1);
// player.sendMessage("§e" + modelData);
SiegeEngines.UpdateEntityIdModel(entity, modelData, worldName);
nextModelNumber -= 1;
} else {
// plugin.getLogger().log(Level.INFO, "its reloaded");
hasReloaded = true;
}
}
}, 0, millisecondsBetweenReloadingStages);
} else {
//firing stages
if (nextModelNumber < firingModelNumbers.size()) {
int modelData = firingModelNumbers.get(nextModelNumber);
// player.sendMessage("§e" + modelData);
SiegeEngines.UpdateEntityIdModel(entity, modelData, worldName);
if (modelData == modelNumberToFireAt) {
// player.sendMessage("§efiring" + modelData);
if (LoadedProjectile == null) return;
if (LoadedProjectile.getType() == Material.AIR) return;
GunnersProjectile projType = projectiles.get(LoadedProjectile);
if (projType == null) return;
projType.Shoot(player, entity, this.GetFireLocation(living), loadedFuel * velocityPerFuel);
}
nextModelNumber += 1;
} else {
hasFired = true;
}
}
}, 0, millisecondsBetweenFiringStages);
} else {
taskNumber = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
//player.sendMessage("§etask");
if (living == null || living.isDead()) {
Bukkit.getServer().getScheduler().cancelTask(taskNumber);
return;
}
Location loc = living.getEyeLocation();
Vector direction = entity.getLocation().getDirection().multiply(xOffset);
loc.add(direction);
nextModelNumber = 0;
if (LoadedProjectile == null) return;
if (LoadedProjectile.getType() == Material.AIR) return;
GunnersProjectile projType = projectiles.get(LoadedProjectile);
if (projType == null) return;
projType.Shoot(player, entity, this.GetFireLocation(living), loadedFuel * velocityPerFuel);
}, (long) delay);
}
}
//}
}
@@ -26,8 +26,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.metadata.MetadataValueAdapter; import org.bukkit.metadata.MetadataValueAdapter;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
@@ -71,10 +70,10 @@ public class SiegeEngines extends JavaPlugin {
TrackedStands.clear(); TrackedStands.clear();
DefinedEquipment.clear(); DefinedEquipment.clear();
AddDefaults(); AddDefaults();
for (SiegeEquipment i : DefinedEquipment.values()) { for (SiegeEngine i : DefinedEquipment.values()) {
System.out.println("§eEnabled Weapon : " + i.EquipmentName); System.out.println("§eEnabled Weapon : " + i.name);
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial); System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.fuelItem);
for (ItemStack proj : i.Projectiles.keySet()) { for (ItemStack proj : i.projectiles.keySet()) {
System.out.println("§eWeapon Projectile ItemStacks : " + proj); System.out.println("§eWeapon Projectile ItemStacks : " + proj);
} }
} }
@@ -85,20 +84,20 @@ public class SiegeEngines extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
commandHandler.onDisable(); commandHandler.onDisable();
for (SiegeEquipment equip : equipment.values()) { for (SiegeEngine siegeEngine : equipment.values()) {
if (equip.Entity != null) { if (siegeEngine.entity != null) {
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
equip.AmmoHolder = new EquipmentMagazine(); siegeEngine.ammoHolder = new EquipmentMagazine();
meta.setCustomModelData(equip.ReadyModelNumber); meta.setCustomModelData(siegeEngine.readyModelNumber);
meta.setDisplayName("§e" + equip.EquipmentName + " Item"); meta.setDisplayName("§e" + siegeEngine.name + " Item");
List<String> Lore = new ArrayList<String>(); List<String> Lore = new ArrayList<String>();
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand."); Lore.add("§ePlace as a block to spawn a " + siegeEngine.name + " or put on an Armor Stand.");
meta.setLore(Lore); meta.setLore(Lore);
item.setItemMeta(meta); item.setItemMeta(meta);
((LivingEntity) equip.Entity).getEquipment().setHelmet(item); ((LivingEntity) siegeEngine.entity).getEquipment().setHelmet(item);
} }
} }
} }
@@ -107,7 +106,7 @@ public class SiegeEngines extends JavaPlugin {
return new FixedMetadataValue(Bukkit.getServer().getPluginManager().getPlugin("SiegeEngines"), value); return new FixedMetadataValue(Bukkit.getServer().getPluginManager().getPlugin("SiegeEngines"), value);
} }
public static SiegeEquipment CreateClone(Integer ModelId) { public static SiegeEngine CreateClone(Integer ModelId) {
try { try {
return DefinedEquipment.get(ModelId).clone(); return DefinedEquipment.get(ModelId).clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
@@ -117,11 +116,11 @@ public class SiegeEngines extends JavaPlugin {
return null; return null;
} }
public static HashMap<Integer, SiegeEquipment> DefinedEquipment = new HashMap<Integer, SiegeEquipment>(); public static HashMap<Integer, SiegeEngine> DefinedEquipment = new HashMap<Integer, SiegeEngine>();
public static HashMap<UUID, List<Entity>> TrackedStands = new HashMap<UUID, List<Entity>>(); public static HashMap<UUID, List<Entity>> TrackedStands = new HashMap<UUID, List<Entity>>();
public static HashMap<UUID, SiegeEquipment> equipment = new HashMap<UUID, SiegeEquipment>(); public static HashMap<UUID, SiegeEngine> equipment = new HashMap<UUID, SiegeEngine>();
public static String convertTime(long time) { public static String convertTime(long time) {
@@ -140,94 +139,49 @@ public class SiegeEngines extends JavaPlugin {
return timeLeftFormatted; return timeLeftFormatted;
} }
public static SiegeEquipment CreateNewGun(String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj) {
SiegeEquipment equip = new SiegeEquipment();
if (customModelId == null || customModelId == 0)
customModelId = 150;
if (name == null)
name = "Unnamed Cannon";
if (XOffset == null)
XOffset = 0;
if (YOffset == null)
YOffset = 0;
if (fuelMax == null)
fuelMax = 0;
if (fuelVelocityMod == null)
fuelVelocityMod = 0.95f;
equip.EquipmentName = name;
equip.EquipmentId = equip.EquipmentName.replaceAll(" ", "_").toLowerCase();
equip.XOffset = XOffset;
equip.YOffset = YOffset;
equip.RotateStandHead = true;
equip.RotateSideways = true;
equip.PlacementOffsetY = -1.125f;
equip.ReadyModelNumber = customModelId;
equip.ModelNumberToFireAt = customModelId;
equip.FiringModelNumbers = new ArrayList<Integer>();
equip.VelocityPerFuel = fuelVelocityMod;
equip.FuelMaterial = new ItemStack(Material.GUNPOWDER);
equip.CycleThroughModelsBeforeFiring = false;
equip.AllowInvisibleStand = false;
equip.MaxFuel = fuelMax;
equip.shotAmount = 1;
equip.AmmoHolder.LoadedFuel = fuelMax;
EntityProjectile defaultProj = new EntityProjectile();
defaultProj.EntityCount = 2;
defaultProj.EntityTyp = EntityType.SHULKER_BULLET;
defaultProj.ParticleType = Particle.WHITE_ASH;
defaultProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
if (projObj.keySet().isEmpty() || projObj.isEmpty())
projObj.put(new ItemStack(Material.GUNPOWDER), defaultProj);
for (ItemStack mat : projObj.keySet()) {
equip.Projectiles.put(mat, projObj.get(mat));
}
DefinedEquipment.put(equip.ReadyModelNumber, equip);
return equip;
}
public static void AddDefaults() { public static void AddDefaults() {
SiegeEquipment equip = new SiegeEquipment(); //String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj
equip.EquipmentName = "Trebuchet"; //@NotNull String name, @NotNull HashMap<ItemStack, GunnersProjectile> projectiles, @NotNull ItemStack fuelItem, int customModelID
equip.XOffset = 5; SiegeEngine trebuchet = new SiegeEngine("Trebuchet", new HashMap<ItemStack, GunnersProjectile>(), new ItemStack(Material.GUNPOWDER), 150);
equip.YOffset = 5; trebuchet.xOffset = 5;
equip.VelocityPerFuel = 0.3f; trebuchet.yOffset = 5;
trebuchet.velocityPerFuel = 0.3f;
ExplosiveProjectile proj = new ExplosiveProjectile(); ExplosiveProjectile proj = new ExplosiveProjectile();
proj.ExplodePower = 1; proj.ExplodePower = 1;
equip.shotAmount = 2; trebuchet.shotAmount = 2;
equip.RotateStandHead = false; trebuchet.rotateStandHead = false;
equip.RotateSideways = true; trebuchet.rotateSideways = true;
equip.FuelMaterial = new ItemStack(Material.STRING); trebuchet.fuelItem = new ItemStack(Material.STRING);
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj); trebuchet.projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
equip.ReadyModelNumber = 122; trebuchet.readyModelNumber = 122;
equip.ModelNumberToFireAt = 135; trebuchet.modelNumberToFireAt = 135;
equip.MillisecondsBetweenFiringStages = 2; trebuchet.millisecondsBetweenFiringStages = 2;
equip.MillisecondsBetweenReloadingStages = 10; trebuchet.millisecondsBetweenReloadingStages = 10;
equip.FiringModelNumbers = new ArrayList<>(Arrays.asList( trebuchet.firingModelNumbers = new ArrayList<>(Arrays.asList(
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139
)); ));
equip.CycleThroughModelsBeforeFiring = true; trebuchet.cycleThroughModelsBeforeFiring = true;
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(trebuchet.readyModelNumber, trebuchet);
equip = new SiegeEquipment(); SiegeEngine navalCannon = new SiegeEngine("Naval Cannon", new HashMap<ItemStack, GunnersProjectile>(), new ItemStack(Material.GUNPOWDER), 142);
equip.EquipmentName = "Naval Cannon"; navalCannon.projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj); navalCannon.placementOffsetY = -1;
equip.PlacementOffsetY = -1; navalCannon.shotAmount = 1;
equip.shotAmount = 1; navalCannon.readyModelNumber = 142;
equip.ReadyModelNumber = 142; navalCannon.modelNumberToFireAt = 142;
equip.ModelNumberToFireAt = 142; navalCannon.firingModelNumbers = new ArrayList<Integer>();
equip.FiringModelNumbers = new ArrayList<Integer>(); navalCannon.rotateStandHead = true;
equip.RotateStandHead = true; navalCannon.rotateSideways = false;
equip.RotateSideways = false;
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 1; proj.ExplodePower = 1;
proj.ProjectilesCount = 5; proj.ProjectilesCount = 5;
proj.DelayedFire = true; proj.DelayedFire = true;
proj.Inaccuracy = 0.75f; proj.Inaccuracy = 0.75f;
equip.Projectiles.put(new ItemStack(Material.TNT), proj); navalCannon.projectiles.put(new ItemStack(Material.TNT), proj);
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 3; proj.ExplodePower = 3;
proj.ProjectilesCount = 1; proj.ProjectilesCount = 1;
equip.Projectiles.put(new ItemStack(Material.IRON_BLOCK), proj); navalCannon.projectiles.put(new ItemStack(Material.IRON_BLOCK), proj);
EntityProjectile fireProj = new EntityProjectile(); EntityProjectile fireProj = new EntityProjectile();
fireProj.EntityCount = 4; fireProj.EntityCount = 4;
@@ -235,43 +189,43 @@ public class SiegeEngines extends JavaPlugin {
fireProj.ParticleType = Particle.WHITE_ASH; fireProj.ParticleType = Particle.WHITE_ASH;
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT; fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
fireProj.Inaccuracy = 0.75f; fireProj.Inaccuracy = 0.75f;
equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj); navalCannon.projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj);
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(navalCannon.readyModelNumber, navalCannon);
equip = new SiegeEquipment();
equip.EquipmentName = "Siege Cannon"; SiegeEngine siegeCannon = new SiegeEngine("Siege Cannon", new HashMap<ItemStack, GunnersProjectile>(), new ItemStack(Material.GUNPOWDER), 141);
proj.ExplodePower = 2; proj.ExplodePower = 2;
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj); siegeCannon.projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
equip.shotAmount = 1; siegeCannon.shotAmount = 1;
equip.PlacementOffsetY = -1; siegeCannon.placementOffsetY = -1;
equip.ReadyModelNumber = 141; siegeCannon.readyModelNumber = 141;
equip.ModelNumberToFireAt = 141; siegeCannon.modelNumberToFireAt = 141;
equip.FiringModelNumbers = new ArrayList<Integer>(); siegeCannon.firingModelNumbers = new ArrayList<Integer>();
equip.RotateStandHead = true; siegeCannon.rotateStandHead = true;
equip.RotateSideways = true; siegeCannon.rotateSideways = true;
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 2; proj.ExplodePower = 2;
proj.ProjectilesCount = 3; proj.ProjectilesCount = 3;
proj.DelayedFire = true; proj.DelayedFire = true;
proj.Inaccuracy = 0.75f; proj.Inaccuracy = 0.75f;
equip.Projectiles.put(new ItemStack(Material.TNT), proj); siegeCannon.projectiles.put(new ItemStack(Material.TNT), proj);
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 3; proj.ExplodePower = 3;
proj.ProjectilesCount = 1; proj.ProjectilesCount = 1;
equip.Projectiles.put(new ItemStack(Material.IRON_BLOCK), proj); siegeCannon.projectiles.put(new ItemStack(Material.IRON_BLOCK), proj);
EntityProjectile scatterShot = new EntityProjectile(); EntityProjectile scatterShot = new EntityProjectile();
scatterShot.Inaccuracy = 0.5f; scatterShot.Inaccuracy = 0.5f;
scatterShot.EntityCount = 24; scatterShot.EntityCount = 24;
scatterShot.ParticleType = Particle.ELECTRIC_SPARK; scatterShot.ParticleType = Particle.ELECTRIC_SPARK;
scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT; scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
equip.Projectiles.put(new ItemStack(Material.GRAVEL), scatterShot); siegeCannon.projectiles.put(new ItemStack(Material.GRAVEL), scatterShot);
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(siegeCannon.readyModelNumber, siegeCannon);
} }
public static Boolean placeEquipment(Entity player, int CustomModelData, Location l) { public static Boolean placeEquipment(Entity player, int CustomModelData, Location l) {
l.add(0.5, 0, 0.5); l.add(0.5, 0, 0.5);
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons"); NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
SiegeEquipment equip = CreateClone(CustomModelData); SiegeEngine siegeEngine = CreateClone(CustomModelData);
if (equip == null || !equip.Enabled) { if (siegeEngine == null || !siegeEngine.enabled) {
return false; return false;
} }
l.setY(l.getY() + 1); l.setY(l.getY() + 1);
@@ -280,17 +234,17 @@ public class SiegeEngines extends JavaPlugin {
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
String id = ""; String id = "";
equip.AmmoHolder = new EquipmentMagazine(); siegeEngine.ammoHolder = new EquipmentMagazine();
if (equip.HasBaseStand) { if (siegeEngine.hasBaseStand) {
Location l2 = l; Location l2 = l;
l2.setY(l.getY() + equip.BaseStandOffset); l2.setY(l.getY() + siegeEngine.baseStandOffset);
Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
LivingEntity ent = (LivingEntity) entity3; LivingEntity ent = (LivingEntity) entity3;
ArmorStand stand = (ArmorStand) ent; ArmorStand stand = (ArmorStand) ent;
id = entity3.getUniqueId().toString(); id = entity3.getUniqueId().toString();
meta.setCustomModelData(equip.BaseStandModelNumber); meta.setCustomModelData(siegeEngine.baseStandModelNumber);
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
@@ -302,20 +256,20 @@ public class SiegeEngines extends JavaPlugin {
stand.setBasePlate(false); stand.setBasePlate(false);
// stand.setSmall(true); // stand.setSmall(true);
item.setItemMeta(meta); item.setItemMeta(meta);
stand.setInvisible(equip.AllowInvisibleStand); stand.setInvisible(siegeEngine.allowInvisibleStand);
ent.getEquipment().setHelmet(item); ent.getEquipment().setHelmet(item);
stand.setGravity(false); stand.setGravity(false);
stand.setMarker(true); stand.setMarker(true);
} }
l.setY(l.getY() + equip.PlacementOffsetY); l.setY(l.getY() + siegeEngine.placementOffsetY);
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
if (id != "") { if (id != "") {
entity2.getPersistentDataContainer().set(key, PersistentDataType.STRING, id); entity2.getPersistentDataContainer().set(key, PersistentDataType.STRING, id);
} }
meta.setCustomModelData(equip.ReadyModelNumber); meta.setCustomModelData(siegeEngine.readyModelNumber);
meta.setDisplayName("§e" + equip.EquipmentName + " Item"); meta.setDisplayName("§e" + siegeEngine.name + " Item");
List<String> Lore = new ArrayList<String>(); List<String> Lore = new ArrayList<String>();
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand."); Lore.add("§ePlace as a block to spawn a " + siegeEngine.name + " or put on an Armor Stand.");
meta.setLore(Lore); meta.setLore(Lore);
item.setItemMeta(meta); item.setItemMeta(meta);
@@ -323,9 +277,9 @@ public class SiegeEngines extends JavaPlugin {
LivingEntity ent = (LivingEntity) entity2; LivingEntity ent = (LivingEntity) entity2;
ArmorStand stand = (ArmorStand) ent; ArmorStand stand = (ArmorStand) ent;
equip.Entity = entity2; siegeEngine.entity = entity2;
equip.EntityId = entity2.getUniqueId(); siegeEngine.entityId = entity2.getUniqueId();
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
@@ -334,7 +288,7 @@ public class SiegeEngines extends JavaPlugin {
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.ADDING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
stand.setInvisible(equip.AllowInvisibleStand); stand.setInvisible(siegeEngine.allowInvisibleStand);
stand.setBasePlate(true); stand.setBasePlate(true);
stand.setGravity(false); stand.setGravity(false);
@@ -348,7 +302,7 @@ public class SiegeEngines extends JavaPlugin {
newList.add(entity2); newList.add(entity2);
TrackedStands.put(player.getUniqueId(), newList); TrackedStands.put(player.getUniqueId(), newList);
} }
equipment.put(entity2.getUniqueId(), equip); equipment.put(entity2.getUniqueId(), siegeEngine);
return true; return true;
} }
@@ -1,293 +0,0 @@
package com.github.alathra.siegeengines;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import com.github.alathra.siegeengines.projectile.GunnersProjectile;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
//import GunnersProjectiles.GunnersProjectile;
//import GunnersProjectiles.ExplosiveProjectile;
//import me.libraryaddict.disguise.DisguiseAPI;
//import me.libraryaddict.disguise.disguisetypes.DisguiseType;
//import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
public class SiegeEquipment implements Cloneable {
@Override
public SiegeEquipment clone() throws CloneNotSupportedException {
return (SiegeEquipment) super.clone();
}
public boolean equals(String EquipmentId) {
return this.EquipmentId.equals(EquipmentId);
}
public Boolean Enabled = true;
public UUID EntityId;
public Entity Entity;
public Integer shotAmount = 1;
public HashMap<ItemStack, GunnersProjectile> Projectiles = new HashMap<ItemStack, GunnersProjectile>();
public String WorldName;
public String EquipmentName = "Peckle Gun";
public String EquipmentId = this.EquipmentName.replaceAll(" ", "_").toLowerCase();
public int XOffset = 2;
public int YOffset = 0;
public int PitchOffset = 0;
public int MaxFuel = 5;
public double PlacementOffsetY = 0;
public float VelocityPerFuel = 1.0125f;
public ItemStack FuelMaterial = new ItemStack(Material.GUNPOWDER);
public long NextShotTime = System.currentTimeMillis();
public int MillisecondsBetweenFiringStages;
public int MillisecondsBetweenReloadingStages;
public int MillisecondsToLoad;
public int ModelNumberToFireAt;
public Boolean CycleThroughModelsBeforeFiring = false;
public Boolean RotateSideways = false;
public Boolean RotateUpDown = true;
public Boolean RotateStandHead = true;
public Boolean HasFired = false;
public Boolean HasReloaded = false;
public Boolean AllowInvisibleStand = false;
public Boolean HasBaseStand = false;
public double BaseStandOffset = 0;
public int BaseStandModelNumber = 147;
public int TaskNumber;
public int ReadyModelNumber;
public int NextModelNumber = 0;
public List<Integer> FiringModelNumbers = new ArrayList<Integer>();
public EquipmentMagazine AmmoHolder = new EquipmentMagazine();
public Boolean isLoaded() {
if (this.MaxFuel <= 0 && AmmoHolder.LoadedProjectile >= 1)
return true;
return (AmmoHolder.LoadedFuel > 0 && AmmoHolder.LoadedProjectile >= 1);
}
public Boolean CanLoadFuel() {
return AmmoHolder.LoadedFuel < MaxFuel;
}
public Boolean LoadFuel(Entity player) {
ItemStack fuelItem = this.FuelMaterial;
if (this.AmmoHolder.LoadedFuel == this.MaxFuel) {
return true;
}
if (!(player instanceof Player)) {
this.AmmoHolder.LoadedFuel = this.MaxFuel;
return true;
}
if (((Player) player).getInventory().containsAtLeast(fuelItem, 1) || fuelItem.getType() == Material.AIR) {
if (CanLoadFuel()) {
this.AmmoHolder.LoadedFuel += 1;
//SaveState();
((Player) player).getInventory().removeItem(fuelItem);
((Player) player).sendMessage("§eLoaded " + this.AmmoHolder.LoadedFuel + "/" + this.MaxFuel);
return true;
} else {
return false;
}
}
return false;
}
public Boolean LoadProjectile(Entity player, ItemStack itemInHand) {
if (itemInHand.getAmount() <= 0) {
return false;
}
if (!(player instanceof Player)) {
this.AmmoHolder.LoadedProjectile = 1;
this.AmmoHolder.LoadedFuel = this.MaxFuel;
this.AmmoHolder.MaterialName = itemInHand;
return true;
}
if (this.Projectiles.containsKey(itemInHand.getType()) && this.AmmoHolder.LoadedProjectile == 0) {
this.AmmoHolder.LoadedProjectile = 1;
this.AmmoHolder.MaterialName = itemInHand;
((Player) player).sendMessage("§eAdding Ammunition to Weapon");
itemInHand.setAmount(itemInHand.getAmount() - 1);
return true;
}
return false;
}
//public void SaveState() {
//}
public Location GetFireLocation(LivingEntity living) {
if (living == null)
return null;
Location loc = living.getEyeLocation();
Vector direction = living.getLocation().getDirection().multiply(XOffset);
loc.add(direction);
if (this.YOffset > 0) {
loc.setY(loc.getY() + this.YOffset);
} else {
loc.setY(loc.getY() - this.YOffset);
}
loc.setPitch(loc.getPitch() + this.PitchOffset);
return loc;
}
public void ShowFireLocation(Entity player) {
LivingEntity living = (LivingEntity) this.Entity;
if (player instanceof Player) {
if (living != null) {
Location origin = this.GetFireLocation(living);
Vector direction = origin.getDirection();
direction.multiply(5 /* the range */);
Location destination = origin.clone().add(direction);
direction.normalize();
for (int i = 0; i < 3 /* range */; i += 1) {
Location spawn = origin.add(direction);
((Player) player).spawnParticle(Particle.CLOUD, spawn, 1, 0, 0, 0, 0);
}
}
}
}
public void Fire(Entity player, float delay, Integer amount) {
if (amount == null || amount == 0)
amount = this.shotAmount;
this.shotAmount = amount;
if (System.currentTimeMillis() < this.NextShotTime) {
return;
}
if (this.AmmoHolder.LoadedFuel <= 0)
this.AmmoHolder.LoadedFuel = 0;
float loadedFuel = this.AmmoHolder.LoadedFuel;
ItemStack LoadedProjectile = this.AmmoHolder.MaterialName;
LivingEntity living = (LivingEntity) this.Entity;
if (living == null || living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) {
return;
}
if (living.getEquipment().getHelmet().getItemMeta().getCustomModelData() != this.ReadyModelNumber) {
if (player instanceof Player) {
((Player) player).sendMessage("§eCannot fire yet!");
}
return;
}
this.AmmoHolder.LoadedFuel = 0;
this.AmmoHolder.LoadedProjectile = 0;
this.AmmoHolder.MaterialName = new ItemStack(Material.AIR, 1);
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(SiegeEngines.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(SiegeEngines.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);
this.HasReloaded = false;
this.HasFired = false;
this.NextModelNumber = 0;
SiegeEngines.UpdateEntityIdModel(this.Entity, this.ReadyModelNumber, this.WorldName);
this.TaskNumber = 0;
} else {
//firing stages
if (this.NextModelNumber - 1 <= this.FiringModelNumbers.size() && this.NextModelNumber - 1 >= 0) {
int modelData = this.FiringModelNumbers.get(this.NextModelNumber - 1);
// player.sendMessage("§e" + modelData);
SiegeEngines.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
this.NextModelNumber -= 1;
} else {
// plugin.getLogger().log(Level.INFO, "its reloaded");
this.HasReloaded = true;
}
}
}, 0, this.MillisecondsBetweenReloadingStages);
} else {
//firing stages
if (this.NextModelNumber < this.FiringModelNumbers.size()) {
int modelData = this.FiringModelNumbers.get(this.NextModelNumber);
// player.sendMessage("§e" + modelData);
SiegeEngines.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
if (modelData == this.ModelNumberToFireAt) {
// player.sendMessage("§efiring" + modelData);
if (LoadedProjectile == null) return;
if (LoadedProjectile.getType() == Material.AIR) return;
GunnersProjectile projType = Projectiles.get(LoadedProjectile);
if (projType == null) return;
projType.Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
}
this.NextModelNumber += 1;
} else {
this.HasFired = true;
}
}
}, 0, this.MillisecondsBetweenFiringStages);
} else {
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.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);
loc.add(direction);
this.NextModelNumber = 0;
if (LoadedProjectile == null) return;
if (LoadedProjectile.getType() == Material.AIR) return;
GunnersProjectile projType = Projectiles.get(LoadedProjectile);
if (projType == null) return;
projType.Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
}, (long) delay);
}
}
//}
}
@@ -1,6 +1,6 @@
package com.github.alathra.siegeengines.command; package com.github.alathra.siegeengines.command;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEngine;
import com.github.alathra.siegeengines.projectile.GunnersProjectile; import com.github.alathra.siegeengines.projectile.GunnersProjectile;
import com.github.milkdrinkers.colorparser.ColorParser; import com.github.milkdrinkers.colorparser.ColorParser;
import dev.jorel.commandapi.CommandAPIBukkit; import dev.jorel.commandapi.CommandAPIBukkit;
@@ -49,7 +49,7 @@ public class SiegeEnginesCommand {
new StringArgument("equipmentid") new StringArgument("equipmentid")
.replaceSuggestions( .replaceSuggestions(
ArgumentSuggestions.strings( ArgumentSuggestions.strings(
DefinedEquipment.values().stream().map(SiegeEquipment -> SiegeEquipment.EquipmentId).toList() DefinedEquipment.values().stream().map(SiegeEquipment -> SiegeEquipment.id).toList()
) )
), ),
new PlayerArgument("target") new PlayerArgument("target")
@@ -76,7 +76,7 @@ public class SiegeEnginesCommand {
Player player = (Player) args.getOptional("target").orElse(sender); Player player = (Player) args.getOptional("target").orElse(sender);
for (SiegeEquipment SiegeEquipment : DefinedEquipment.values()) { for (SiegeEngine SiegeEquipment : DefinedEquipment.values()) {
if (SiegeEquipment.equals(equipmentId)) { if (SiegeEquipment.equals(equipmentId)) {
giveEquipment(player, SiegeEquipment); giveEquipment(player, SiegeEquipment);
break; break;
@@ -88,7 +88,7 @@ public class SiegeEnginesCommand {
if (!(sender instanceof Player player)) if (!(sender instanceof Player player))
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>Only players can use this command.").build()); throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>Only players can use this command.").build());
for (SiegeEquipment i : DefinedEquipment.values()) { for (SiegeEngine i : DefinedEquipment.values()) {
giveEquipment(player, i); giveEquipment(player, i);
} }
} }
@@ -103,23 +103,23 @@ public class SiegeEnginesCommand {
AddDefaults(); AddDefaults();
HashMap<ItemStack, GunnersProjectile> projObj = new HashMap<>(); HashMap<ItemStack, GunnersProjectile> projObj = new HashMap<>();
//SiegeEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj); //SiegeEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
for (SiegeEquipment i : DefinedEquipment.values()) { for (SiegeEngine i : DefinedEquipment.values()) {
sender.sendMessage(ColorParser.of("<yellow>Enabled Weapon : %s".formatted(i.EquipmentName)).build()); sender.sendMessage(ColorParser.of("<yellow>Enabled Weapon : %s".formatted(i.name)).build());
sender.sendMessage(ColorParser.of("<yellow>Weapon Propellant/\"Fuel\" ItemStacks : %s".formatted(i.FuelMaterial)).build()); sender.sendMessage(ColorParser.of("<yellow>Weapon Propellant/\"Fuel\" ItemStacks : %s".formatted(i.fuelItem)).build());
for (ItemStack proj : i.Projectiles.keySet()) { for (ItemStack proj : i.projectiles.keySet()) {
sender.sendMessage(ColorParser.of("<yellow>Weapon Projectile ItemStacks : %s".formatted(proj)).build()); sender.sendMessage(ColorParser.of("<yellow>Weapon Projectile ItemStacks : %s".formatted(proj)).build());
} }
} }
sender.sendMessage("<yellow>Gunners Core configs reloaded"); sender.sendMessage("<yellow>Gunners Core configs reloaded");
} }
private void giveEquipment(Player player, SiegeEquipment SiegeEquipment) { private void giveEquipment(Player player, SiegeEngine SiegeEquipment) {
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(SiegeEquipment.ReadyModelNumber); meta.setCustomModelData(SiegeEquipment.readyModelNumber);
meta.displayName(ColorParser.of("<yellow>%s Item".formatted(SiegeEquipment.EquipmentName)).build()); meta.displayName(ColorParser.of("<yellow>%s Item".formatted(SiegeEquipment.name)).build());
List<Component> lore = new ArrayList<>(); List<Component> lore = new ArrayList<>();
lore.add(ColorParser.of("<yellow>Place as a block to spawn a '%s'".formatted(SiegeEquipment.EquipmentName)).build()); lore.add(ColorParser.of("<yellow>Place as a block to spawn a '%s'".formatted(SiegeEquipment.name)).build());
lore.add(ColorParser.of("<yellow>or put on an Armor Stand.").build()); lore.add(ColorParser.of("<yellow>or put on an Armor Stand.").build());
lore.add(ColorParser.of("<yellow>Right click to toggle visibility of stand.").build()); lore.add(ColorParser.of("<yellow>Right click to toggle visibility of stand.").build());
meta.lore(lore); meta.lore(lore);
@@ -44,15 +44,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEngine;
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile; import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
//import com.palmergames.bukkit.towny.TownyAPI;
//import com.palmergames.bukkit.towny.event.actions.TownyDestroyEvent;
//import com.palmergames.bukkit.towny.object.TownBlock;
//import GunnersProjectiles.ExplosiveProjectile;
public class ClickHandler implements Listener { public class ClickHandler implements Listener {
public float MinDelay = 5; public float MinDelay = 5;
@@ -64,16 +58,6 @@ public class ClickHandler implements Listener {
for (Entity entity : e.getEntity().getNearbyEntities(e.getYield() + 1, e.getYield() + 1, e.getYield() + 1)) { for (Entity entity : e.getEntity().getNearbyEntities(e.getYield() + 1, e.getYield() + 1, e.getYield() + 1)) {
if (entity instanceof ArmorStand) { if (entity instanceof ArmorStand) {
ArmorStand stand = (ArmorStand) entity; ArmorStand stand = (ArmorStand) entity;
/*if (SiegeEngines.towny != null) {
TownBlock block = TownyAPI.getInstance().getTownBlock(stand.getLocation());
if (block != null) {
if (block.hasTown()) {
if (!block.getTownBlockOwner().getPermissions().explosion) {
return;
}
}
}
}*/
stand.eject(); stand.eject();
stand.remove(); stand.remove();
} }
@@ -92,7 +76,6 @@ public class ClickHandler implements Listener {
} }
Location loc = snowball.getLocation(); Location loc = snowball.getLocation();
World world = event.getEntity().getWorld(); World world = event.getEntity().getWorld();
// world.createExplosion(loc, proj.Radius, proj.DoFire);
Entity tnt = event.getEntity().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT); Entity tnt = event.getEntity().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
projectiles.remove(event.getEntity().getUniqueId()); projectiles.remove(event.getEntity().getUniqueId());
@@ -101,16 +84,6 @@ public class ClickHandler implements Listener {
TNTPrimed tntEnt = (TNTPrimed) tnt; TNTPrimed tntEnt = (TNTPrimed) tnt;
tntEnt.setYield(0); tntEnt.setYield(0);
tntEnt.setFuseTicks(0); tntEnt.setFuseTicks(0);
/*if (SiegeEngines.towny != null) {
TownBlock block = TownyAPI.getInstance().getTownBlock(loc);
if (block != null) {
if (block.hasTown()) {
if (!block.getTownBlockOwner().getPermissions().explosion) {
return;
}
}
}
}*/
if (event.getHitBlock() != null) { if (event.getHitBlock() != null) {
List<Block> Blocks = sphere(event.getHitBlock().getLocation(), (int) proj.ExplodePower); List<Block> Blocks = sphere(event.getHitBlock().getLocation(), (int) proj.ExplodePower);
for (int i = 0; i < proj.BlocksToPlaceAmount; i++) { for (int i = 0; i < proj.BlocksToPlaceAmount; i++) {
@@ -201,7 +174,7 @@ public class ClickHandler implements Listener {
SiegeEngines.TrackedStands.get(player.getUniqueId()).remove(ent); SiegeEngines.TrackedStands.get(player.getUniqueId()).remove(ent);
continue; continue;
} }
SiegeEquipment siege = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine siege = SiegeEngines.equipment.get(ent.getUniqueId());
if (counter > 4) if (counter > 4)
return; return;
if (ent == null || ent.isDead()) { if (ent == null || ent.isDead()) {
@@ -219,9 +192,7 @@ public class ClickHandler implements Listener {
} else { } else {
if (player instanceof Player) { if (player instanceof Player) {
} }
//player.sendMessage("§eAmmunition Not Loaded");
} }
// player.sendMessage(String.format("§e" +actualDelay));
} }
} }
@@ -290,8 +261,8 @@ public class ClickHandler implements Listener {
for (Entity entity : entities) { for (Entity entity : entities) {
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) { if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId()); SiegeEngine equip = SiegeEngines.equipment.get(entity.getUniqueId());
if (equip != null && equip.Enabled && !(entity.isDead())) { if (equip != null && equip.enabled && !(entity.isDead())) {
equip.Fire(player,10f,1); equip.Fire(player,10f,1);
} }
} }
@@ -309,22 +280,22 @@ public class ClickHandler implements Listener {
foundAmmo = false; foundAmmo = false;
if ((entity.isDead())) continue; if ((entity.isDead())) continue;
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) { if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId()); SiegeEngine equip = SiegeEngines.equipment.get(entity.getUniqueId());
if (equip == null || !equip.Enabled) { if (equip == null || !equip.enabled) {
continue; continue;
} }
if (entity.getLocation().getBlock().getType() == Material.BARREL || entity.getLocation().getBlock().getType() == Material.CHEST) { if (entity.getLocation().getBlock().getType() == Material.BARREL || entity.getLocation().getBlock().getType() == Material.CHEST) {
Block inv = entity.getLocation().getBlock(); Block inv = entity.getLocation().getBlock();
Container state = ((Container) inv.getState()); Container state = ((Container) inv.getState());
for (ItemStack stack : equip.Projectiles.keySet()) { for (ItemStack stack : equip.projectiles.keySet()) {
if (foundAmmo) if (foundAmmo)
continue; continue;
if (!hasItem((Inventory)state.getInventory(),stack)) if (!hasItem((Inventory)state.getInventory(),stack))
continue; continue;
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1)); state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
//state.update(true,true); //state.update(true,true);
equip.AmmoHolder.LoadedProjectile = 1; equip.ammoHolder.LoadedProjectile = 1;
equip.AmmoHolder.MaterialName = stack; equip.ammoHolder.MaterialName = stack;
foundAmmo = true; foundAmmo = true;
} }
//state.update(true,true); //state.update(true,true);
@@ -334,15 +305,15 @@ public class ClickHandler implements Listener {
if (entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.CHEST) { if (entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, -1, 0).getType() == Material.CHEST) {
Block inv = entity.getLocation().getBlock().getRelative(0, -1, 0); Block inv = entity.getLocation().getBlock().getRelative(0, -1, 0);
Container state = ((Container) inv.getState()); Container state = ((Container) inv.getState());
for (ItemStack stack : equip.Projectiles.keySet()) { for (ItemStack stack : equip.projectiles.keySet()) {
if (foundAmmo) if (foundAmmo)
continue; continue;
if (!hasItem((Inventory)state.getInventory(),stack)) if (!hasItem((Inventory)state.getInventory(),stack))
continue; continue;
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1)); state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
//state.update(true,true); //state.update(true,true);
equip.AmmoHolder.LoadedProjectile = 1; equip.ammoHolder.LoadedProjectile = 1;
equip.AmmoHolder.MaterialName = stack; equip.ammoHolder.MaterialName = stack;
foundAmmo = true; foundAmmo = true;
} }
//state.update(true,true); //state.update(true,true);
@@ -352,15 +323,15 @@ public class ClickHandler implements Listener {
if (entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.CHEST) { if (entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.BARREL || entity.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.CHEST) {
Block inv = entity.getLocation().getBlock().getRelative(0, 1, 0); Block inv = entity.getLocation().getBlock().getRelative(0, 1, 0);
Container state = ((Container) inv.getState()); Container state = ((Container) inv.getState());
for (ItemStack stack : equip.Projectiles.keySet()) { for (ItemStack stack : equip.projectiles.keySet()) {
if (foundAmmo) if (foundAmmo)
continue; continue;
if (!hasItem((Inventory)state.getInventory(),stack)) if (!hasItem((Inventory)state.getInventory(),stack))
continue; continue;
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1)); state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
//state.update(true,true); //state.update(true,true);
equip.AmmoHolder.LoadedProjectile = 1; equip.ammoHolder.LoadedProjectile = 1;
equip.AmmoHolder.MaterialName = stack; equip.ammoHolder.MaterialName = stack;
foundAmmo = true; foundAmmo = true;
} }
//state.update(true,true); //state.update(true,true);
@@ -371,14 +342,14 @@ public class ClickHandler implements Listener {
break; break;
if (!foundAmmo) { if (!foundAmmo) {
for (ItemStack inventoryItem : event.getPlayer().getInventory().getContents()) { for (ItemStack inventoryItem : event.getPlayer().getInventory().getContents()) {
for (ItemStack stack : equip.Projectiles.keySet()) { for (ItemStack stack : equip.projectiles.keySet()) {
if (foundAmmo) if (foundAmmo)
continue; continue;
if (!hasItem(event.getPlayer().getInventory(),stack)) if (!hasItem(event.getPlayer().getInventory(),stack))
continue; continue;
if (stack.isSimilar(inventoryItem) && equip.AmmoHolder.LoadedProjectile == 0) { if (stack.isSimilar(inventoryItem) && equip.ammoHolder.LoadedProjectile == 0) {
equip.AmmoHolder.LoadedProjectile = 1; equip.ammoHolder.LoadedProjectile = 1;
equip.AmmoHolder.MaterialName = stack; equip.ammoHolder.MaterialName = stack;
inventoryItem.setAmount(inventoryItem.getAmount() - 1); inventoryItem.setAmount(inventoryItem.getAmount() - 1);
foundAmmo = true; foundAmmo = true;
break; break;
@@ -396,11 +367,11 @@ public class ClickHandler implements Listener {
foundAmmo = false; foundAmmo = false;
if ((entity.isDead())) continue; if ((entity.isDead())) continue;
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) { if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
SiegeEquipment equip = SiegeEngines.equipment.get(entity.getUniqueId()); SiegeEngine equip = SiegeEngines.equipment.get(entity.getUniqueId());
if (equip == null || !equip.Enabled) { if (equip == null || !equip.enabled) {
continue; continue;
} }
ItemStack stack = equip.FuelMaterial; ItemStack stack = equip.fuelItem;
if (entity.getLocation().getBlock().getType() == Material.BARREL || entity.getLocation().getBlock().getType() == Material.CHEST) { if (entity.getLocation().getBlock().getType() == Material.BARREL || entity.getLocation().getBlock().getType() == Material.CHEST) {
Block inv = entity.getLocation().getBlock(); Block inv = entity.getLocation().getBlock();
Container state = ((Container) inv.getState()); Container state = ((Container) inv.getState());
@@ -412,7 +383,7 @@ public class ClickHandler implements Listener {
continue; continue;
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1)); state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
//state.update(true,true); //state.update(true,true);
equip.AmmoHolder.LoadedFuel += 1; equip.ammoHolder.LoadedFuel += 1;
foundAmmo = true; foundAmmo = true;
//state.update(true,true); //state.update(true,true);
} }
@@ -429,7 +400,7 @@ public class ClickHandler implements Listener {
//state.update(true,true); //state.update(true,true);
if (!equip.CanLoadFuel()) if (!equip.CanLoadFuel())
continue; continue;
equip.AmmoHolder.LoadedFuel += 1; equip.ammoHolder.LoadedFuel += 1;
foundAmmo = true; foundAmmo = true;
//state.update(true,true); //state.update(true,true);
} }
@@ -446,7 +417,7 @@ public class ClickHandler implements Listener {
continue; continue;
state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1)); state.getInventory().removeItem(stack);//setStorageContents(updateContents(state.getInventory(),stack,1));
//state.update(true,true); //state.update(true,true);
equip.AmmoHolder.LoadedFuel += 1; equip.ammoHolder.LoadedFuel += 1;
foundAmmo = true; foundAmmo = true;
//state.update(true,true); //state.update(true,true);
} }
@@ -460,7 +431,7 @@ public class ClickHandler implements Listener {
break; break;
if (!equip.CanLoadFuel()) if (!equip.CanLoadFuel())
continue; continue;
equip.AmmoHolder.LoadedFuel += 1; equip.ammoHolder.LoadedFuel += 1;
stack.setAmount(1); stack.setAmount(1);
event.getPlayer().getInventory().removeItem(stack); event.getPlayer().getInventory().removeItem(stack);
foundAmmo = true; foundAmmo = true;
@@ -516,7 +487,7 @@ public class ClickHandler implements Listener {
} }
ArmorStand stand = (ArmorStand) entity; ArmorStand stand = (ArmorStand) entity;
SiegeEquipment equip; SiegeEngine equip;
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
@@ -525,17 +496,17 @@ public class ClickHandler implements Listener {
if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) { if (SiegeEngines.equipment.containsKey(entity.getUniqueId())) {
equip = SiegeEngines.equipment.get(entity.getUniqueId()); equip = SiegeEngines.equipment.get(entity.getUniqueId());
if (equip == null || !equip.Enabled) { if (equip == null || !equip.enabled) {
return; return;
} }
} else { } else {
equip = SiegeEngines.CreateClone(living.getEquipment().getHelmet().getItemMeta().getCustomModelData()); equip = SiegeEngines.CreateClone(living.getEquipment().getHelmet().getItemMeta().getCustomModelData());
if (equip == null || !equip.Enabled) { if (equip == null || !equip.enabled) {
return; return;
} }
equip.AmmoHolder = new EquipmentMagazine(); equip.ammoHolder = new EquipmentMagazine();
equip.Entity = entity; equip.entity = entity;
equip.EntityId = entity.getUniqueId(); equip.entityId = entity.getUniqueId();
} }
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
@@ -586,11 +557,11 @@ public class ClickHandler implements Listener {
return; return;
} }
loc.setPitch((float) (loc.getPitch() - amount)); loc.setPitch((float) (loc.getPitch() - amount));
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (equipment != null) { if (equipment != null) {
if (player instanceof Player) if (player instanceof Player)
equipment.ShowFireLocation(player); equipment.ShowFireLocation(player);
if (equipment.RotateStandHead) { if (equipment.rotateStandHead) {
stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0)); stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0));
} }
ent.teleport(loc); ent.teleport(loc);
@@ -605,11 +576,11 @@ public class ClickHandler implements Listener {
return; return;
} }
loc.setPitch((float) (loc.getPitch() - amount)); loc.setPitch((float) (loc.getPitch() - amount));
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (equipment != null) { if (equipment != null) {
if (player instanceof Player) if (player instanceof Player)
equipment.ShowFireLocation(player); equipment.ShowFireLocation(player);
if (equipment.RotateStandHead) { if (equipment.rotateStandHead) {
stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0)); stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0));
} }
ent.teleport(loc); ent.teleport(loc);
@@ -623,12 +594,12 @@ public class ClickHandler implements Listener {
if (loc.getPitch() == 85 || loc.getPitch() + amount > 85) { if (loc.getPitch() == 85 || loc.getPitch() + amount > 85) {
return; return;
} }
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (equipment != null) { if (equipment != null) {
if (player instanceof Player) { if (player instanceof Player) {
equipment.ShowFireLocation((Player) player); equipment.ShowFireLocation((Player) player);
} }
if (equipment.RotateStandHead) { if (equipment.rotateStandHead) {
stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0)); stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0));
} }
@@ -699,7 +670,7 @@ public class ClickHandler implements Listener {
continue; continue;
} }
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (equipment != null) { if (equipment != null) {
equipment.LoadFuel(player); equipment.LoadFuel(player);
} }
@@ -711,7 +682,7 @@ public class ClickHandler implements Listener {
if (ent.isDead()) { if (ent.isDead()) {
continue; continue;
} }
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (equipment != null) { if (equipment != null) {
equipment.LoadProjectile(player, projectile); equipment.LoadProjectile(player, projectile);
} }
@@ -842,7 +813,7 @@ public class ClickHandler implements Listener {
return; return;
} }
SiegeEquipment equipment = SiegeEngines.equipment.get(entity.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(entity.getUniqueId());
event.setCancelled(true); event.setCancelled(true);
if (itemInHand == null || itemInHand.getType() == Material.AIR) { if (itemInHand == null || itemInHand.getType() == Material.AIR) {
@@ -851,32 +822,23 @@ public class ClickHandler implements Listener {
stand.setInvisible(false); stand.setInvisible(false);
player.sendMessage("§eEquipment is now breakable"); player.sendMessage("§eEquipment is now breakable");
} else { } else {
if (equipment.AllowInvisibleStand) { if (equipment.allowInvisibleStand) {
stand.setInvisible(true); stand.setInvisible(true);
player.sendMessage("§eEquipment is no longer breakable"); player.sendMessage("§eEquipment is no longer breakable");
} }
} }
return; return;
} }
if (itemInHand.isSimilar(equipment.FuelMaterial)) { if (itemInHand.isSimilar(equipment.fuelItem)) {
if (!equipment.LoadFuel(player)) { if (!equipment.LoadFuel(player)) {
player.sendMessage("§eCould not load Propellant."); player.sendMessage("§eCould not load Propellant.");
return; return;
} }
} }
/*if (itemInHand.isSimilar(new ItemStack(Material.FLINT))) { for (ItemStack stack : equipment.projectiles.keySet()) {
if (equipment.isLoaded()) { if (stack.isSimilar(itemInHand) && equipment.ammoHolder.LoadedProjectile == 0) {
equipment.Fire((Entity) player, 6, 1); equipment.ammoHolder.LoadedProjectile = 1;
} equipment.ammoHolder.MaterialName = stack;
else {
player.sendMessage("§eEquipment is not loaded");
}
return;
}*/
for (ItemStack stack : equipment.Projectiles.keySet()) {
if (stack.isSimilar(itemInHand) && equipment.AmmoHolder.LoadedProjectile == 0) {
equipment.AmmoHolder.LoadedProjectile = 1;
equipment.AmmoHolder.MaterialName = stack;
player.sendMessage("§eAdding Ammunition to Weapon"); player.sendMessage("§eAdding Ammunition to Weapon");
itemInHand.setAmount(itemInHand.getAmount() - 1); itemInHand.setAmount(itemInHand.getAmount() - 1);
return; return;
@@ -20,7 +20,7 @@ import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEngine;
import com.github.alathra.siegeengines.config.Config; import com.github.alathra.siegeengines.config.Config;
public class RotationHandler implements Listener { public class RotationHandler implements Listener {
@@ -40,7 +40,7 @@ public class RotationHandler implements Listener {
final List<Entity> list = new ArrayList<>(SiegeEngines.TrackedStands.get(player.getUniqueId())); final List<Entity> list = new ArrayList<>(SiegeEngines.TrackedStands.get(player.getUniqueId()));
for (Entity ent : list) { for (Entity ent : list) {
if (ent != null) { if (ent != null) {
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEngine equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (ent.isDead()) { if (ent.isDead()) {
continue; continue;
} }
@@ -50,7 +50,7 @@ public class RotationHandler implements Listener {
LivingEntity living = (LivingEntity) ent; LivingEntity living = (LivingEntity) ent;
Location loc = ent.getLocation(); Location loc = ent.getLocation();
if (equipment.RotateSideways) { if (equipment.rotateSideways) {
Location direction = player.getLocation().add(player.getLocation().getDirection().multiply(50)); Location direction = player.getLocation().add(player.getLocation().getDirection().multiply(50));
Vector dirBetweenLocations = direction.toVector().subtract(loc.toVector()); Vector dirBetweenLocations = direction.toVector().subtract(loc.toVector());
@@ -68,7 +68,7 @@ public class RotationHandler implements Listener {
ArmorStand stand = (ArmorStand) living; ArmorStand stand = (ArmorStand) living;
if (equipment.RotateUpDown) { if (equipment.rotateUpDown) {
loc.setPitch(player.getLocation().getPitch()); loc.setPitch(player.getLocation().getPitch());
if (loc.getPitch() < -85) { if (loc.getPitch() < -85) {
loc.setPitch(-85); loc.setPitch(-85);
@@ -76,7 +76,7 @@ public class RotationHandler implements Listener {
if (loc.getPitch() > 85) { if (loc.getPitch() > 85) {
loc.setPitch(85); loc.setPitch(85);
} }
if (equipment.RotateStandHead) { if (equipment.rotateStandHead) {
stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0)); stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0));
} }
} }