Updated Some stuff, Ported over my Changes

Hi!
This commit is contained in:
C_Corp2002 committed 2024-01-05 21:59:11 -05:00
1 parent 4283710716
commit 09eecbb8ee
4 files changed
+1500 -1478

No files matched your search

@@ -1,405 +1,411 @@
package com.github.alathra.siegeengines; package com.github.alathra.siegeengines;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.github.alathra.siegeengines.command.CommandHandler; import com.github.alathra.siegeengines.command.CommandHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.ArmorStand.LockType; import org.bukkit.entity.ArmorStand.LockType;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; 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.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; 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;
//import com.palmergames.bukkit.towny.Towny; //import com.palmergames.bukkit.towny.Towny;
import com.github.alathra.siegeengines.listeners.ClickHandler; import com.github.alathra.siegeengines.listeners.ClickHandler;
import com.github.alathra.siegeengines.listeners.RotationHandler; import com.github.alathra.siegeengines.listeners.RotationHandler;
import com.github.alathra.siegeengines.projectile.EntityProjectile; import com.github.alathra.siegeengines.projectile.EntityProjectile;
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile; import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
import com.github.alathra.siegeengines.projectile.GunnersProjectile; import com.github.alathra.siegeengines.projectile.GunnersProjectile;
//import GunnersProjectiles.EntityProjectile; //import GunnersProjectiles.EntityProjectile;
//import GunnersProjectiles.GunnersProjectile; //import GunnersProjectiles.GunnersProjectile;
//import GunnersProjectiles.ExplosiveProjectile; //import GunnersProjectiles.ExplosiveProjectile;
//import GunnersProjectiles.PotionProjectile; //import GunnersProjectiles.PotionProjectile;
public class SiegeEngines extends JavaPlugin { public class SiegeEngines extends JavaPlugin {
public static SiegeEngines instance; public static SiegeEngines instance;
public static Plugin plugin; public static Plugin plugin;
public static MetadataValueAdapter metadata; public static MetadataValueAdapter metadata;
public static Random random = new Random(); public static Random random = new Random();
private static String Path; private static String Path;
private CommandHandler commandHandler; private CommandHandler commandHandler;
//public static Towny towny; //public static Towny towny;
public static SiegeEngines getInstance() { public static SiegeEngines getInstance() {
return instance; return instance;
} }
@Override @Override
public void onLoad() { public void onLoad() {
plugin = this; plugin = this;
commandHandler = new CommandHandler(this); commandHandler = new CommandHandler(this);
commandHandler.onLoad(); commandHandler.onLoad();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void onEnable() { public void onEnable() {
instance = this; instance = this;
Path = this.getDataFolder().getAbsolutePath(); Path = this.getDataFolder().getAbsolutePath();
//this.getCommand("SiegeEngines").setExecutor(new GunnersCommand()); // Fixed Start-up //this.getCommand("SiegeEngines").setExecutor(new GunnersCommand()); // Fixed Start-up
getServer().getPluginManager().registerEvents(new RotationHandler(), this); getServer().getPluginManager().registerEvents(new RotationHandler(), this);
getServer().getPluginManager().registerEvents(new ClickHandler(), this); getServer().getPluginManager().registerEvents(new ClickHandler(), this);
//StorageManager.setup(Path, plugin); //StorageManager.setup(Path, plugin);
equipment.clear(); equipment.clear();
TrackedStands.clear(); TrackedStands.clear();
DefinedEquipment.clear(); DefinedEquipment.clear();
//AddDefaults(); //AddDefaults();
//HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>(); //HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>();
//GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj); //GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
for (SiegeEquipment i : DefinedEquipment.values()) { for (SiegeEquipment i : DefinedEquipment.values()) {
System.out.println("§eEnabled Weapon : " + i.EquipmentName); System.out.println("§eEnabled Weapon : " + i.EquipmentName);
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial); System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
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);
} }
} }
commandHandler.onEnable(); commandHandler.onEnable();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void onDisable() { public void onDisable() {
commandHandler.onDisable(); commandHandler.onDisable();
for (SiegeEquipment equip : equipment.values()) { for (SiegeEquipment equip : equipment.values()) {
if (equip.Entity != null) { if (equip.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(); equip.AmmoHolder = new EquipmentMagazine();
meta.setCustomModelData(equip.ReadyModelNumber); meta.setCustomModelData(equip.ReadyModelNumber);
meta.setDisplayName("§e" + equip.EquipmentName + " Item"); meta.setDisplayName("§e" + equip.EquipmentName + " 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 " + equip.EquipmentName + " 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) equip.Entity).getEquipment().setHelmet(item);
} }
} }
} }
public static FixedMetadataValue addMetaDataValue(Object value) { public static FixedMetadataValue addMetaDataValue(Object value) {
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 SiegeEquipment CreateClone(Integer ModelId) {
try { try {
return DefinedEquipment.get(ModelId).clone(); return DefinedEquipment.get(ModelId).clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
} }
return null; return null;
} }
public static HashMap<Integer, SiegeEquipment> DefinedEquipment = new HashMap<Integer, SiegeEquipment>(); public static HashMap<Integer, SiegeEquipment> DefinedEquipment = new HashMap<Integer, SiegeEquipment>();
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, SiegeEquipment> equipment = new HashMap<UUID, SiegeEquipment>();
public static String convertTime(long time) { public static String convertTime(long time) {
long days = TimeUnit.MILLISECONDS.toDays(time); long days = TimeUnit.MILLISECONDS.toDays(time);
time -= TimeUnit.DAYS.toMillis(days); time -= TimeUnit.DAYS.toMillis(days);
long hours = TimeUnit.MILLISECONDS.toHours(time); long hours = TimeUnit.MILLISECONDS.toHours(time);
time -= TimeUnit.HOURS.toMillis(hours); time -= TimeUnit.HOURS.toMillis(hours);
long minutes = TimeUnit.MILLISECONDS.toMinutes(time); long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
time -= TimeUnit.MINUTES.toMillis(minutes); time -= TimeUnit.MINUTES.toMillis(minutes);
long seconds = TimeUnit.MILLISECONDS.toSeconds(time); long seconds = TimeUnit.MILLISECONDS.toSeconds(time);
String timeLeftFormatted = String.format("§e" + minutes + " Minutes " + seconds + " Seconds§f"); String timeLeftFormatted = String.format("§e" + minutes + " Minutes " + seconds + " Seconds§f");
return timeLeftFormatted; return timeLeftFormatted;
} }
public static SiegeEquipment CreateNewGun(String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj) { public static SiegeEquipment CreateNewGun(String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj) {
SiegeEquipment equip = new SiegeEquipment(); SiegeEquipment equip = new SiegeEquipment();
if (customModelId == null || customModelId == 0) if (customModelId == null || customModelId == 0)
customModelId = 150; customModelId = 150;
if (name == null) if (name == null)
name = "Light Turret"; name = "Unnamed Cannon";
if (XOffset == null) if (XOffset == null)
XOffset = 0; XOffset = 0;
if (YOffset == null) if (YOffset == null)
YOffset = 0; YOffset = 0;
if (fuelMax == null) if (fuelMax == null)
fuelMax = 0; fuelMax = 0;
if (fuelVelocityMod == null) if (fuelVelocityMod == null)
fuelVelocityMod = 0.95f; fuelVelocityMod = 0.95f;
equip.EquipmentName = name; equip.EquipmentName = name;
equip.EquipmentId = equip.EquipmentName.replaceAll(" ", "_").toLowerCase(); equip.EquipmentId = equip.EquipmentName.replaceAll(" ", "_").toLowerCase();
equip.XOffset = XOffset; equip.XOffset = XOffset;
equip.YOffset = YOffset; equip.YOffset = YOffset;
equip.RotateStandHead = true; equip.RotateStandHead = true;
equip.RotateSideways = true; equip.RotateSideways = true;
equip.PlacementOffsetY = -1.125f; equip.PlacementOffsetY = -1.125f;
equip.ReadyModelNumber = customModelId; equip.ReadyModelNumber = customModelId;
equip.ModelNumberToFireAt = customModelId; equip.ModelNumberToFireAt = customModelId;
equip.FiringModelNumbers = new ArrayList<Integer>(); equip.FiringModelNumbers = new ArrayList<Integer>();
equip.VelocityPerFuel = fuelVelocityMod; equip.VelocityPerFuel = fuelVelocityMod;
equip.FuelMaterial = new ItemStack(Material.GUNPOWDER); equip.FuelMaterial = new ItemStack(Material.GUNPOWDER);
equip.CycleThroughModelsBeforeFiring = false; equip.CycleThroughModelsBeforeFiring = false;
equip.AllowInvisibleStand = false; equip.AllowInvisibleStand = false;
equip.MaxFuel = fuelMax; equip.MaxFuel = fuelMax;
equip.shotAmount = 1; equip.shotAmount = 1;
equip.AmmoHolder.LoadedFuel = fuelMax; equip.AmmoHolder.LoadedFuel = fuelMax;
EntityProjectile defaultProj = new EntityProjectile(); EntityProjectile defaultProj = new EntityProjectile();
defaultProj.EntityCount = 2; defaultProj.EntityCount = 2;
defaultProj.EntityTyp = EntityType.SHULKER_BULLET; defaultProj.EntityTyp = EntityType.SHULKER_BULLET;
defaultProj.ParticleType = Particle.WHITE_ASH; defaultProj.ParticleType = Particle.WHITE_ASH;
defaultProj.SoundType = Sound.ENTITY_BLAZE_SHOOT; defaultProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
if (projObj.keySet().isEmpty() || projObj.isEmpty()) if (projObj.keySet().isEmpty() || projObj.isEmpty())
projObj.put(new ItemStack(Material.GUNPOWDER), defaultProj); projObj.put(new ItemStack(Material.GUNPOWDER), defaultProj);
for (ItemStack mat : projObj.keySet()) { for (ItemStack mat : projObj.keySet()) {
equip.Projectiles.put(mat, projObj.get(mat)); equip.Projectiles.put(mat, projObj.get(mat));
} }
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(equip.ReadyModelNumber, equip);
return equip; return equip;
} }
public static void AddDefaults() { public static void AddDefaults() {
SiegeEquipment equip = new SiegeEquipment(); SiegeEquipment equip = new SiegeEquipment();
equip.EquipmentName = "Trebuchet"; equip.EquipmentName = "Trebuchet";
equip.XOffset = 5; equip.XOffset = 5;
equip.YOffset = 5; equip.YOffset = 5;
equip.VelocityPerFuel = 0.3f; equip.VelocityPerFuel = 0.3f;
ExplosiveProjectile proj = new ExplosiveProjectile(); ExplosiveProjectile proj = new ExplosiveProjectile();
proj.ExplodePower = 2; proj.ExplodePower = 1;
equip.shotAmount = 1; equip.shotAmount = 2;
equip.RotateStandHead = false; equip.RotateStandHead = false;
equip.RotateSideways = true; equip.RotateSideways = true;
equip.FuelMaterial = new ItemStack(Material.STRING); equip.FuelMaterial = new ItemStack(Material.STRING);
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj); equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
equip.ReadyModelNumber = 122; equip.ReadyModelNumber = 122;
equip.ModelNumberToFireAt = 135; equip.ModelNumberToFireAt = 135;
equip.MillisecondsBetweenFiringStages = 2; equip.MillisecondsBetweenFiringStages = 2;
equip.MillisecondsBetweenReloadingStages = 10; equip.MillisecondsBetweenReloadingStages = 10;
equip.FiringModelNumbers = new ArrayList<>(Arrays.asList( equip.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; equip.CycleThroughModelsBeforeFiring = true;
DefinedEquipment.put(equip.ReadyModelNumber, equip); DefinedEquipment.put(equip.ReadyModelNumber, equip);
equip = new SiegeEquipment(); equip = new SiegeEquipment();
equip.EquipmentName = "Naval Cannon"; equip.EquipmentName = "Naval Cannon";
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj); equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
equip.PlacementOffsetY = -1; equip.PlacementOffsetY = -1;
equip.shotAmount = 1; equip.shotAmount = 1;
equip.ReadyModelNumber = 142; equip.ReadyModelNumber = 142;
equip.ModelNumberToFireAt = 142; equip.ModelNumberToFireAt = 142;
equip.FiringModelNumbers = new ArrayList<Integer>(); equip.FiringModelNumbers = new ArrayList<Integer>();
equip.RotateStandHead = true; equip.RotateStandHead = true;
equip.RotateSideways = false; equip.RotateSideways = false;
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 1; proj.ExplodePower = 1;
proj.ProjectilesCount = 3; 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); equip.Projectiles.put(new ItemStack(Material.TNT), proj);
proj = new ExplosiveProjectile(); proj = new ExplosiveProjectile();
proj.ExplodePower = 4; proj.ExplodePower = 3;
proj.ProjectilesCount = 1; proj.ProjectilesCount = 1;
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj); equip.Projectiles.put(new ItemStack(Material.IRON_BLOCK), proj);
EntityProjectile fireProj = new EntityProjectile(); EntityProjectile fireProj = new EntityProjectile();
fireProj.EntityCount = 2; fireProj.EntityCount = 4;
fireProj.EntityTyp = EntityType.SMALL_FIREBALL; fireProj.EntityTyp = EntityType.SMALL_FIREBALL;
fireProj.ParticleType = Particle.WHITE_ASH; fireProj.ParticleType = Particle.WHITE_ASH;
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT; fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj); fireProj.Inaccuracy = 0.75f;
DefinedEquipment.put(equip.ReadyModelNumber, equip); equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj);
equip = new SiegeEquipment(); DefinedEquipment.put(equip.ReadyModelNumber, equip);
equip.EquipmentName = "Siege Cannon"; equip = new SiegeEquipment();
proj.ExplodePower = 2; equip.EquipmentName = "Siege Cannon";
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj); proj.ExplodePower = 2;
equip.shotAmount = 1; equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
equip.PlacementOffsetY = -1; equip.shotAmount = 1;
equip.ReadyModelNumber = 141; equip.PlacementOffsetY = -1;
equip.ModelNumberToFireAt = 141; equip.ReadyModelNumber = 141;
equip.FiringModelNumbers = new ArrayList<Integer>(); equip.ModelNumberToFireAt = 141;
equip.RotateStandHead = true; equip.FiringModelNumbers = new ArrayList<Integer>();
equip.RotateSideways = true; equip.RotateStandHead = true;
proj = new ExplosiveProjectile(); equip.RotateSideways = true;
proj.ExplodePower = 1; proj = new ExplosiveProjectile();
proj.ProjectilesCount = 3; proj.ExplodePower = 2;
proj.DelayedFire = true; proj.ProjectilesCount = 3;
proj.Inaccuracy = 0.5f; proj.DelayedFire = true;
equip.Projectiles.put(new ItemStack(Material.TNT), proj); proj.Inaccuracy = 0.75f;
proj = new ExplosiveProjectile(); equip.Projectiles.put(new ItemStack(Material.TNT), proj);
proj.ExplodePower = 4; proj = new ExplosiveProjectile();
proj.ProjectilesCount = 1; proj.ExplodePower = 3;
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj); proj.ProjectilesCount = 1;
equip.Projectiles.put(new ItemStack(Material.GRAVEL), new EntityProjectile()); equip.Projectiles.put(new ItemStack(Material.IRON_BLOCK), proj);
DefinedEquipment.put(equip.ReadyModelNumber, equip); EntityProjectile scatterShot = new EntityProjectile();
// EntityProjectile pig = new EntityProjectile(); scatterShot.Inaccuracy = 0.5f;
// pig.EntityCount = 100; scatterShot.EntityCount = 24;
// pig.DelayedFire = true; scatterShot.ParticleType = Particle.ELECTRIC_SPARK;
// pig.DelayTime = 3; scatterShot.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
// pig.EntityTyp = EntityType.ARROW; equip.Projectiles.put(new ItemStack(Material.GRAVEL), scatterShot);
// pig.SoundType = Sound.ITEM_CROSSBOW_SHOOT; DefinedEquipment.put(equip.ReadyModelNumber, equip);
// pig.ParticleType = Particle.GLOW; // EntityProjectile pig = new EntityProjectile();
// equip.Projectiles.put(Material.PORKCHOP, pig); // pig.EntityCount = 100;
// equip.Projectiles.put(Material.BONE, new PotionProjectile()); // pig.DelayedFire = true;
// pig.DelayTime = 3;
} // pig.EntityTyp = EntityType.ARROW;
// pig.SoundType = Sound.ITEM_CROSSBOW_SHOOT;
public static Boolean CreateCannon(Entity player, int CustomModelData, Location l) { // pig.ParticleType = Particle.GLOW;
//l.setY(l.getY() - 1); // equip.Projectiles.put(Material.PORKCHOP, pig);
l.add(0.5, 0, 0.5); // equip.Projectiles.put(Material.BONE, new PotionProjectile());
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
SiegeEquipment equip = CreateClone(CustomModelData); }
if (equip == null || !equip.Enabled) {
return false; public static Boolean CreateCannon(Entity player, int CustomModelData, Location l) {
} //l.setY(l.getY() - 1);
l.setY(l.getY() + 1); l.add(0.5, 0, 0.5);
int maxNearby = 0; NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
SiegeEquipment equip = CreateClone(CustomModelData);
l.setDirection(player.getFacing().getDirection()); if (equip == null || !equip.Enabled) {
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); return false;
ItemMeta meta = item.getItemMeta(); }
String id = ""; l.setY(l.getY() + 1);
equip.AmmoHolder = new EquipmentMagazine(); int maxNearby = 0;
if (equip.HaseBaseStand) {
l.setDirection(player.getFacing().getDirection());
Location l2 = l; ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
l2.setY(l.getY() + equip.BaseStandOffset); ItemMeta meta = item.getItemMeta();
Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); String id = "";
equip.AmmoHolder = new EquipmentMagazine();
LivingEntity ent = (LivingEntity) entity3; if (equip.HaseBaseStand) {
ArmorStand stand = (ArmorStand) ent;
id = entity3.getUniqueId().toString(); Location l2 = l;
meta.setCustomModelData(equip.BaseStandModelNumber); l2.setY(l.getY() + equip.BaseStandOffset);
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING); Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING); LivingEntity ent = (LivingEntity) entity3;
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING); ArmorStand stand = (ArmorStand) ent;
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING); id = entity3.getUniqueId().toString();
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.ADDING_OR_CHANGING); meta.setCustomModelData(equip.BaseStandModelNumber);
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
stand.setBasePlate(false); stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
// stand.setSmall(true); stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
item.setItemMeta(meta); stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
stand.setInvisible(equip.AllowInvisibleStand); stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.ADDING_OR_CHANGING);
ent.getEquipment().setHelmet(item); stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
stand.setGravity(false); stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
stand.setMarker(true); stand.setBasePlate(false);
} // stand.setSmall(true);
l.setY(l.getY() + equip.PlacementOffsetY); item.setItemMeta(meta);
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND); stand.setInvisible(equip.AllowInvisibleStand);
if (id != "") { ent.getEquipment().setHelmet(item);
entity2.getPersistentDataContainer().set(key, PersistentDataType.STRING, id); stand.setGravity(false);
} stand.setMarker(true);
meta.setCustomModelData(equip.ReadyModelNumber); }
meta.setDisplayName("§e" + equip.EquipmentName + " Item"); l.setY(l.getY() + equip.PlacementOffsetY);
List<String> Lore = new ArrayList<String>(); Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand."); if (id != "") {
meta.setLore(Lore); entity2.getPersistentDataContainer().set(key, PersistentDataType.STRING, id);
item.setItemMeta(meta); }
meta.setCustomModelData(equip.ReadyModelNumber);
// entity3.addPassenger(entity2); meta.setDisplayName("§e" + equip.EquipmentName + " Item");
List<String> Lore = new ArrayList<String>();
LivingEntity ent = (LivingEntity) entity2; Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand.");
ArmorStand stand = (ArmorStand) ent; meta.setLore(Lore);
equip.Entity = entity2; item.setItemMeta(meta);
for (Entity le : l.getNearbyEntities(5, 5, 5)) {
if (maxNearby >= 4) { // entity3.addPassenger(entity2);
ent.damage(100.0d, player);
return false; LivingEntity ent = (LivingEntity) entity2;
} ArmorStand stand = (ArmorStand) ent;
if (le instanceof ArmorStand) equip.Entity = entity2;
maxNearby++; for (Entity le : l.getNearbyEntities(5, 5, 5)) {
} if (maxNearby >= 4) {
ent.damage(100.0d, player);
equip.EntityId = entity2.getUniqueId(); return false;
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING); }
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING); if (le instanceof ArmorStand)
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING); maxNearby++;
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING); }
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.ADDING_OR_CHANGING); equip.EntityId = entity2.getUniqueId();
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING); stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
stand.setInvisible(equip.AllowInvisibleStand); stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
stand.setBasePlate(false); stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1)); stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
// stand.setSmall(true); stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.ADDING_OR_CHANGING);
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
stand.setGravity(false); stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
//stand.setSmall(true); stand.setInvisible(equip.AllowInvisibleStand);
ent.getEquipment().setHelmet(item); stand.setBasePlate(false);
if (TrackedStands.containsKey(player.getUniqueId())) { ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
List<Entity> entities = TrackedStands.get(player.getUniqueId()); // stand.setSmall(true);
entities.add(entity2);
TrackedStands.put(player.getUniqueId(), entities); stand.setGravity(false);
} else { //stand.setSmall(true);
List<Entity> newList = new ArrayList<Entity>(); ent.getEquipment().setHelmet(item);
newList.add(entity2); if (TrackedStands.containsKey(player.getUniqueId())) {
TrackedStands.put(player.getUniqueId(), newList); List<Entity> entities = TrackedStands.get(player.getUniqueId());
} entities.add(entity2);
equipment.put(entity2.getUniqueId(), equip); TrackedStands.put(player.getUniqueId(), entities);
return true; } else {
} List<Entity> newList = new ArrayList<Entity>();
newList.add(entity2);
public static void UpdateEntityIdModel(Entity ent, int modelNumber, String WorldName) { TrackedStands.put(player.getUniqueId(), newList);
if (ent instanceof LivingEntity) { }
LivingEntity liv = (LivingEntity) ent; equipment.put(entity2.getUniqueId(), equip);
ItemStack Helmet = liv.getEquipment().getHelmet(); return true;
if (Helmet != null) { }
ItemMeta meta = Helmet.getItemMeta();
meta.setCustomModelData(modelNumber); public static void UpdateEntityIdModel(Entity ent, int modelNumber, String WorldName) {
Helmet.setItemMeta(meta); if (ent instanceof LivingEntity) {
liv.getEquipment().setHelmet(Helmet); LivingEntity liv = (LivingEntity) ent;
// plugin.getLogger().log(Level.INFO, "Updating stand?"); ItemStack Helmet = liv.getEquipment().getHelmet();
} if (Helmet != null) {
} ItemMeta meta = Helmet.getItemMeta();
} meta.setCustomModelData(modelNumber);
Helmet.setItemMeta(meta);
} liv.getEquipment().setHelmet(Helmet);
// plugin.getLogger().log(Level.INFO, "Updating stand?");
}
}
}
}
@@ -1,131 +1,129 @@
package com.github.alathra.siegeengines.command; package com.github.alathra.siegeengines.command;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEquipment;
import com.github.alathra.siegeengines.config.Config; 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; import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandAPICommand; import dev.jorel.commandapi.arguments.ArgumentSuggestions;
import dev.jorel.commandapi.arguments.ArgumentSuggestions; import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.arguments.PlayerArgument; import dev.jorel.commandapi.arguments.StringArgument;
import dev.jorel.commandapi.arguments.StringArgument; import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException; import dev.jorel.commandapi.executors.CommandArguments;
import dev.jorel.commandapi.executors.CommandArguments; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.Component; import org.bukkit.Material;
import org.bukkit.Material; import org.bukkit.command.CommandSender;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.ArrayList; import java.util.HashMap;
import java.util.HashMap; import java.util.List;
import java.util.List;
import static com.github.alathra.siegeengines.SiegeEngines.*;
import static com.github.alathra.siegeengines.SiegeEngines.*;
public class SiegeEnginesCommand {
public class SiegeEnginesCommand { public SiegeEnginesCommand() {
public SiegeEnginesCommand() { new CommandAPICommand("siegeengines")
new CommandAPICommand("siegeengines") .withFullDescription("Example command.")
.withFullDescription("Example command.") .withShortDescription("Example command.")
.withShortDescription("Example command.") .withPermission("siegeengines.command")
.withPermission("siegeengines.command") .withSubcommands(
.withSubcommands( commandGet(),
commandGet(), commandGetAll(),
commandGetAll(), commandReload()
commandReload() )
) .executesPlayer(this::onExecute)
.executesPlayer(this::onExecute) .register();
.register(); }
}
private void onExecute(CommandSender sender, CommandArguments args) {
private void onExecute(CommandSender sender, CommandArguments args) { sender.sendMessage(ColorParser.of("<yellow>Incorrect usage, /SiegeEngines get, /SiegeEngines reload").build());
sender.sendMessage(ColorParser.of("<yellow>Incorrect usage, /SiegeEngines get, /SiegeEngines reload").build()); }
}
private CommandAPICommand commandGet() {
private CommandAPICommand commandGet() { return new CommandAPICommand("get")
return new CommandAPICommand("get") .withPermission("siegeengines.command.get")
.withPermission("siegeengines.command.get") .withArguments(
.withArguments( new StringArgument("equipmentid")
new StringArgument("equipmentid") .replaceSuggestions(
.replaceSuggestions( ArgumentSuggestions.strings(
ArgumentSuggestions.strings( DefinedEquipment.values().stream().map(SiegeEquipment -> SiegeEquipment.EquipmentId).toList()
DefinedEquipment.values().stream().map(gunnerEquipment -> gunnerEquipment.EquipmentId).toList() )
) ),
), new PlayerArgument("target")
new PlayerArgument("target") .setOptional(true)
.setOptional(true) )
) .executesPlayer(this::onGet);
.executesPlayer(this::onGet); }
}
private CommandAPICommand commandGetAll() {
private CommandAPICommand commandGetAll() { return new CommandAPICommand("getAll")
return new CommandAPICommand("getAll") .withPermission("siegeengines.command.getAll")
.withPermission("siegeengines.command.getAll") .executesPlayer(this::onGetAll);
.executesPlayer(this::onGetAll); }
}
private CommandAPICommand commandReload() {
private CommandAPICommand commandReload() { return new CommandAPICommand("reload")
return new CommandAPICommand("reload") .withPermission("siegeengines.command.reload")
.withPermission("siegeengines.command.reload") .executesPlayer(this::onReload);
.executesPlayer(this::onReload); }
}
private void onGet(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
private void onGet(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException { if (!(args.get("equipmentid") instanceof String equipmentId))
if (!(args.get("equipmentid") instanceof String equipmentId)) throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>Invalid equipment id specified.").build());
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>Invalid equipment id specified.").build());
Player player = (Player) args.getOptional("target").orElse(sender);
Player player = (Player) args.getOptional("target").orElse(sender);
for (SiegeEquipment SiegeEquipment : DefinedEquipment.values()) {
for (SiegeEquipment gunnerEquipment : DefinedEquipment.values()) { if (SiegeEquipment.equals(equipmentId)) {
if (gunnerEquipment.equals(equipmentId)) { giveEquipment(player, SiegeEquipment);
giveEquipment(player, gunnerEquipment); break;
break; }
} }
} }
}
private void onGetAll(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
private void onGetAll(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException { 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 (SiegeEquipment i : DefinedEquipment.values()) { giveEquipment(player, i);
giveEquipment(player, i); }
} }
}
private void onReload(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
private void onReload(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException { if (!(sender instanceof Player))
if (!(sender instanceof 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());
equipment.clear();
equipment.clear(); TrackedStands.clear();
TrackedStands.clear(); DefinedEquipment.clear();
DefinedEquipment.clear(); 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 (SiegeEquipment 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.EquipmentName)).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.FuelMaterial)).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");
Config.reload(); }
sender.sendMessage("<yellow>Gunners Core configs reloaded");
} private void giveEquipment(Player player, SiegeEquipment SiegeEquipment) {
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
private void giveEquipment(Player player, SiegeEquipment gunnerEquipment) { ItemMeta meta = item.getItemMeta();
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN); meta.setCustomModelData(SiegeEquipment.ReadyModelNumber);
ItemMeta meta = item.getItemMeta(); meta.displayName(ColorParser.of("<yellow>%s Item".formatted(SiegeEquipment.EquipmentName)).build());
meta.setCustomModelData(gunnerEquipment.ReadyModelNumber); List<Component> lore = new ArrayList<>();
meta.displayName(ColorParser.of("<yellow>%s Item".formatted(gunnerEquipment.EquipmentName)).build()); lore.add(ColorParser.of("<yellow>Place as a block to spawn a '%s'".formatted(SiegeEquipment.EquipmentName)).build());
List<Component> lore = new ArrayList<>(); lore.add(ColorParser.of("<yellow>or put on an Armor Stand.").build());
lore.add(ColorParser.of("<yellow>Place as a block to spawn a '%s'".formatted(gunnerEquipment.EquipmentName)).build()); lore.add(ColorParser.of("<yellow>Right click to toggle visibility of stand.").build());
lore.add(ColorParser.of("<yellow>or put on an Armor Stand.").build()); meta.lore(lore);
lore.add(ColorParser.of("<yellow>Right click to toggle visibility of stand.").build()); item.setItemMeta(meta);
meta.lore(lore); player.getInventory().addItem(item);
item.setItemMeta(meta); }
player.getInventory().addItem(item);
}
} }
File diff suppressed because it is too large. Load diff
@@ -1,96 +1,99 @@
package com.github.alathra.siegeengines.listeners; package com.github.alathra.siegeengines.listeners;
import java.util.UUID; import java.util.UUID;
import com.github.alathra.siegeengines.SiegeEngines; import com.github.alathra.siegeengines.SiegeEngines;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack; 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 org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.github.alathra.siegeengines.SiegeEquipment; import com.github.alathra.siegeengines.SiegeEquipment;
import com.github.alathra.siegeengines.config.Config; import com.github.alathra.siegeengines.config.Config;
public class RotationHandler implements Listener { public class RotationHandler implements Listener {
@EventHandler @EventHandler
public void playerMove(PlayerMoveEvent event) { public void playerMove(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons"); NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) { if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
ItemStack itemInHand = player.getInventory().getItemInMainHand(); ItemStack itemInHand = player.getInventory().getItemInMainHand();
if (itemInHand != null) { if (itemInHand != null) {
if (itemInHand.getType() != Config.controlItem) { if (itemInHand.getType() != Config.controlItem) {
// TrackedStands.remove(player.getUniqueId()); // TrackedStands.remove(player.getUniqueId());
return; return;
} }
for (Entity ent : SiegeEngines.TrackedStands.get(player.getUniqueId())) { for (Entity ent : SiegeEngines.TrackedStands.get(player.getUniqueId())) {
if (ent != null) { if (ent != null) {
SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId()); SiegeEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId());
if (ent.isDead()) { if (ent.isDead()) {
continue; continue;
} }
double distance = player.getLocation().distance(ent.getLocation()); double distance = player.getLocation().distance(ent.getLocation());
if (distance <= 250) { if (distance <= 32) {
// player.sendMessage("§egot id"); // player.sendMessage("§egot id");
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());
if (ent.getPersistentDataContainer().has(key, PersistentDataType.STRING)) { if (ent.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING))); Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING)));
Location baseloc = base.getLocation(); Location baseloc = base.getLocation();
baseloc.setDirection(dirBetweenLocations); baseloc.setDirection(dirBetweenLocations);
base.teleport(baseloc); base.teleport(baseloc);
} }
loc.setDirection(dirBetweenLocations); loc.setDirection(dirBetweenLocations);
} }
//loc.setYaw(player.getLocation().getYaw()); //loc.setYaw(player.getLocation().getYaw());
//loc.setPitch(player.getLocation().getPitch()); //loc.setPitch(player.getLocation().getPitch());
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);
} }
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));
} }
} }
living.teleport(loc); living.teleport(loc);
equipment.ShowFireLocation(player); equipment.ShowFireLocation(player);
} } else {
} SiegeEngines.TrackedStands.get(player.getUniqueId()).remove(ent);
} continue;
} }
} }
} }
}
Vector getDirectionBetweenLocations(Location Start, Location End) { }
Vector from = Start.toVector(); }
Vector to = End.toVector();
return to.subtract(from); public Vector getDirectionBetweenLocations(Location Start, Location End) {
} Vector from = Start.toVector();
} Vector to = End.toVector();
return to.subtract(from);
}
}