mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 22:22:10 +00:00
style: reformat and .editorconfig
This commit is contained in:
11 files changed
+1893
-1468
No files matched your search
@@ -4,7 +4,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EquipmentMagazine {
|
||||
public int LoadedFuel = 0;
|
||||
public int LoadedProjectile = 0;
|
||||
public ItemStack MaterialName = new ItemStack(Material.AIR, 1);
|
||||
public int LoadedFuel = 0;
|
||||
public int LoadedProjectile = 0;
|
||||
public ItemStack MaterialName = new ItemStack(Material.AIR, 1);
|
||||
}
|
||||
@@ -22,261 +22,258 @@ import org.bukkit.util.Vector;
|
||||
//import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
//import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
|
||||
public class GunnerEquipment implements Cloneable {
|
||||
public class GunnerEquipment implements Cloneable {
|
||||
|
||||
@Override
|
||||
public GunnerEquipment clone() throws CloneNotSupportedException {
|
||||
return (GunnerEquipment)super.clone();
|
||||
}
|
||||
public Boolean Enabled = true;
|
||||
public UUID EntityId;
|
||||
public Entity Entity;
|
||||
public Integer shotAmount = 1;
|
||||
@Override
|
||||
public GunnerEquipment clone() throws CloneNotSupportedException {
|
||||
return (GunnerEquipment) super.clone();
|
||||
}
|
||||
|
||||
public HashMap<ItemStack, GunnersProjectile> Projectiles = new HashMap<ItemStack, GunnersProjectile>();
|
||||
public Boolean Enabled = true;
|
||||
public UUID EntityId;
|
||||
public Entity Entity;
|
||||
public Integer shotAmount = 1;
|
||||
|
||||
public String WorldName;
|
||||
public String EquipmentName = "Peckle Gun";
|
||||
public int XOffset = 7;
|
||||
public int YOffset = 0;
|
||||
public int PitchOffset = 0;
|
||||
public int MaxFuel = 5;
|
||||
public double PlacementOffsetY = 0;
|
||||
public float VelocityPerFuel = 1.75f;
|
||||
public ItemStack FuelMaterial = new ItemStack(Material.GUNPOWDER);
|
||||
public long NextShotTime = System.currentTimeMillis();
|
||||
public HashMap<ItemStack, GunnersProjectile> Projectiles = new HashMap<ItemStack, GunnersProjectile>();
|
||||
|
||||
public int MillisecondsBetweenFiringStages;
|
||||
public int MillisecondsBetweenReloadingStages;
|
||||
public String WorldName;
|
||||
public String EquipmentName = "Peckle Gun";
|
||||
public int XOffset = 7;
|
||||
public int YOffset = 0;
|
||||
public int PitchOffset = 0;
|
||||
public int MaxFuel = 5;
|
||||
public double PlacementOffsetY = 0;
|
||||
public float VelocityPerFuel = 1.75f;
|
||||
public ItemStack FuelMaterial = new ItemStack(Material.GUNPOWDER);
|
||||
public long NextShotTime = System.currentTimeMillis();
|
||||
|
||||
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 HaseBaseStand = false;
|
||||
public double BaseStandOffset = 0;
|
||||
public int BaseStandModelNumber = 147;
|
||||
public int TaskNumber;
|
||||
public int MillisecondsBetweenFiringStages;
|
||||
public int MillisecondsBetweenReloadingStages;
|
||||
|
||||
public int ReadyModelNumber;
|
||||
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 HaseBaseStand = false;
|
||||
public double BaseStandOffset = 0;
|
||||
public int BaseStandModelNumber = 147;
|
||||
public int TaskNumber;
|
||||
|
||||
public int NextModelNumber = 0;
|
||||
public int ReadyModelNumber;
|
||||
|
||||
public List<Integer> FiringModelNumbers = new ArrayList<Integer>();
|
||||
public int NextModelNumber = 0;
|
||||
|
||||
public EquipmentMagazine AmmoHolder = new EquipmentMagazine();
|
||||
public List<Integer> FiringModelNumbers = new ArrayList<Integer>();
|
||||
|
||||
public Boolean isLoaded() {
|
||||
if (this.MaxFuel <= 0 && AmmoHolder.LoadedProjectile >= 1)
|
||||
return true;
|
||||
return (AmmoHolder.LoadedFuel > 0 && AmmoHolder.LoadedProjectile >= 1);
|
||||
}
|
||||
public EquipmentMagazine AmmoHolder = new EquipmentMagazine();
|
||||
|
||||
public Boolean CanLoadFuel() {
|
||||
return AmmoHolder.LoadedFuel < MaxFuel;
|
||||
}
|
||||
public Boolean isLoaded() {
|
||||
if (this.MaxFuel <= 0 && AmmoHolder.LoadedProjectile >= 1)
|
||||
return true;
|
||||
return (AmmoHolder.LoadedFuel > 0 && AmmoHolder.LoadedProjectile >= 1);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
public Boolean CanLoadFuel() {
|
||||
return AmmoHolder.LoadedFuel < MaxFuel;
|
||||
}
|
||||
|
||||
return false;
|
||||
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 Ammo to Weapon");
|
||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SaveState() {
|
||||
}
|
||||
|
||||
}
|
||||
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 Ammo to Weapon");
|
||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SaveState() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Location GetFireLocation(LivingEntity living) {
|
||||
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 = 3;
|
||||
float loadedFuel = this.AmmoHolder.LoadedFuel;
|
||||
ItemStack LoadedProjectile = this.AmmoHolder.MaterialName;
|
||||
public Location GetFireLocation(LivingEntity living) {
|
||||
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 = 3;
|
||||
float loadedFuel = this.AmmoHolder.LoadedFuel;
|
||||
ItemStack LoadedProjectile = this.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() != 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);
|
||||
LivingEntity living = (LivingEntity) Entity;
|
||||
if (living == null || living.getEquipment() == null || living.getEquipment().getHelmet() == null || living.getEquipment().getHelmet().getItemMeta() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
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.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(SiegeEngines.plugin, () -> {
|
||||
if (living == null || living.isDead()) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
|
||||
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;
|
||||
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(SiegeEngines.plugin, () -> {
|
||||
if (living == null || living.isDead()) {
|
||||
Bukkit.getServer().getScheduler().cancelTask(this.TaskNumber);
|
||||
return;
|
||||
}
|
||||
|
||||
}else {
|
||||
// plugin.getLogger().log(Level.INFO, "its reloaded");
|
||||
this.HasReloaded = true;
|
||||
}
|
||||
}
|
||||
}, 0, this.MillisecondsBetweenReloadingStages);
|
||||
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 {
|
||||
//firing stages
|
||||
if (this.NextModelNumber < this.FiringModelNumbers.size()) {
|
||||
} else {
|
||||
// plugin.getLogger().log(Level.INFO, "its reloaded");
|
||||
this.HasReloaded = true;
|
||||
}
|
||||
}
|
||||
}, 0, this.MillisecondsBetweenReloadingStages);
|
||||
|
||||
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);
|
||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
||||
}
|
||||
this.NextModelNumber += 1;
|
||||
} else {
|
||||
//firing stages
|
||||
if (this.NextModelNumber < this.FiringModelNumbers.size()) {
|
||||
|
||||
}else {
|
||||
this.HasFired = true;
|
||||
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);
|
||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
||||
}
|
||||
this.NextModelNumber += 1;
|
||||
|
||||
}
|
||||
}
|
||||
}, 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;
|
||||
}
|
||||
} else {
|
||||
this.HasFired = true;
|
||||
|
||||
Location loc = living.getEyeLocation();
|
||||
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
|
||||
}
|
||||
}
|
||||
}, 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;
|
||||
}
|
||||
|
||||
loc.add(direction);
|
||||
Location loc = living.getEyeLocation();
|
||||
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
|
||||
|
||||
this.NextModelNumber = 0;
|
||||
loc.add(direction);
|
||||
|
||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
||||
}, (long) delay);
|
||||
this.NextModelNumber = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Projectiles.get(LoadedProjectile).Shoot(player, this.Entity, this.GetFireLocation(living), loadedFuel * this.VelocityPerFuel);
|
||||
}, (long) delay);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,276 +48,276 @@ import com.github.alathra.siegeengines.projectile.GunnersProjectile;
|
||||
//import GunnersProjectiles.PotionProjectile;
|
||||
|
||||
public class SiegeEngines extends JavaPlugin {
|
||||
public static Plugin plugin;
|
||||
public static MetadataValueAdapter metadata;
|
||||
public static Random random = new Random();
|
||||
private static String Path;
|
||||
public static Plugin plugin;
|
||||
public static MetadataValueAdapter metadata;
|
||||
public static Random random = new Random();
|
||||
private static String Path;
|
||||
|
||||
//public static Towny towny;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for (GunnerEquipment equip : equipment.values()) {
|
||||
if (equip.Entity != null) {
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
equip.AmmoHolder = new EquipmentMagazine();
|
||||
|
||||
meta.setCustomModelData(equip.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + equip.EquipmentName +" Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
//public static Towny towny;
|
||||
|
||||
((LivingEntity) equip.Entity).getEquipment().setHelmet(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
Path = this.getDataFolder().getAbsolutePath();
|
||||
this.getCommand("SiegeEngines").setExecutor(new GunnersCommand());
|
||||
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
|
||||
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
|
||||
//StorageManager.setup(Path, plugin);
|
||||
equipment.clear();
|
||||
TrackedStands.clear();
|
||||
DefinedEquipment.clear();
|
||||
//AddDefaults();
|
||||
//HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>();
|
||||
//GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
|
||||
for (GunnerEquipment i : DefinedEquipment.values()) {
|
||||
System.out.println("§eEnabled Weapon : "+i.EquipmentName);
|
||||
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : "+i.FuelMaterial);
|
||||
for (ItemStack proj : i.Projectiles.keySet()) {
|
||||
System.out.println("§eWeapon Projectile ItemStacks : "+proj);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static FixedMetadataValue addMetaDataValue(Object value) {
|
||||
return new FixedMetadataValue(Bukkit.getServer().getPluginManager().getPlugin("SiegeEngines"),value);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for (GunnerEquipment equip : equipment.values()) {
|
||||
if (equip.Entity != null) {
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
equip.AmmoHolder = new EquipmentMagazine();
|
||||
|
||||
public class GunnersCommand implements CommandExecutor {
|
||||
@Override
|
||||
@EventHandler
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
if (args != null && args.length > 0) {
|
||||
meta.setCustomModelData(equip.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + equip.EquipmentName + " Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "get":
|
||||
if (player == null) {
|
||||
sender.sendMessage("§eonly a player can use this command.");
|
||||
return true;
|
||||
}
|
||||
if (!sender.hasPermission("SiegeEngines.get")) {
|
||||
sender.sendMessage("§eNo perms to SiegeEngines.get");
|
||||
return true;
|
||||
}
|
||||
for (GunnerEquipment i : DefinedEquipment.values()) {
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setCustomModelData(i.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + i.EquipmentName +" Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + i.EquipmentName);
|
||||
Lore.add("§eor put on an Armor Stand.");
|
||||
Lore.add("§eRight click to toggle visibility of stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
break;
|
||||
case "reload":
|
||||
if (!sender.hasPermission("SiegeEngines.reload")) {
|
||||
sender.sendMessage("§eNo perms to SiegeEngines.reload");
|
||||
return true;
|
||||
}
|
||||
equipment.clear();
|
||||
TrackedStands.clear();
|
||||
DefinedEquipment.clear();
|
||||
AddDefaults();
|
||||
HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>();
|
||||
GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
|
||||
for (GunnerEquipment i : DefinedEquipment.values()) {
|
||||
sender.sendMessage("§eEnabled Weapon : "+i.EquipmentName);
|
||||
sender.sendMessage("§eWeapon Propellant/\"Fuel\" ItemStacks : "+i.FuelMaterial);
|
||||
for (ItemStack proj : i.Projectiles.keySet()) {
|
||||
sender.sendMessage("§eWeapon Projectile ItemStacks : "+proj);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§eGunners Core configs reloaded");
|
||||
break;
|
||||
}
|
||||
((LivingEntity) equip.Entity).getEquipment().setHelmet(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
sender.sendMessage("§eIncorrect usage, /SiegeEngines get, /SiegeEngines reload");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
Path = this.getDataFolder().getAbsolutePath();
|
||||
this.getCommand("SiegeEngines").setExecutor(new GunnersCommand());
|
||||
getServer().getPluginManager().registerEvents(new RotationHandler(), this);
|
||||
getServer().getPluginManager().registerEvents(new ClickHandler(), this);
|
||||
//StorageManager.setup(Path, plugin);
|
||||
equipment.clear();
|
||||
TrackedStands.clear();
|
||||
DefinedEquipment.clear();
|
||||
//AddDefaults();
|
||||
//HashMap<ItemStack,GunnersProjectile> projObj = new HashMap<>();
|
||||
//GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
|
||||
for (GunnerEquipment i : DefinedEquipment.values()) {
|
||||
System.out.println("§eEnabled Weapon : " + i.EquipmentName);
|
||||
System.out.println("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
|
||||
for (ItemStack proj : i.Projectiles.keySet()) {
|
||||
System.out.println("§eWeapon Projectile ItemStacks : " + proj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GunnerEquipment CreateClone(Integer ModelId) {
|
||||
try {
|
||||
return DefinedEquipment.get(ModelId).clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
public static FixedMetadataValue addMetaDataValue(Object value) {
|
||||
return new FixedMetadataValue(Bukkit.getServer().getPluginManager().getPlugin("SiegeEngines"), value);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public class GunnersCommand implements CommandExecutor {
|
||||
@Override
|
||||
@EventHandler
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
if (args != null && args.length > 0) {
|
||||
|
||||
public static HashMap<Integer, GunnerEquipment> DefinedEquipment = new HashMap<Integer, GunnerEquipment>();
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "get":
|
||||
if (player == null) {
|
||||
sender.sendMessage("§eonly a player can use this command.");
|
||||
return true;
|
||||
}
|
||||
if (!sender.hasPermission("SiegeEngines.get")) {
|
||||
sender.sendMessage("§eNo perms to SiegeEngines.get");
|
||||
return true;
|
||||
}
|
||||
for (GunnerEquipment i : DefinedEquipment.values()) {
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setCustomModelData(i.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + i.EquipmentName + " Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + i.EquipmentName);
|
||||
Lore.add("§eor put on an Armor Stand.");
|
||||
Lore.add("§eRight click to toggle visibility of stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
break;
|
||||
case "reload":
|
||||
if (!sender.hasPermission("SiegeEngines.reload")) {
|
||||
sender.sendMessage("§eNo perms to SiegeEngines.reload");
|
||||
return true;
|
||||
}
|
||||
equipment.clear();
|
||||
TrackedStands.clear();
|
||||
DefinedEquipment.clear();
|
||||
AddDefaults();
|
||||
HashMap<ItemStack, GunnersProjectile> projObj = new HashMap<>();
|
||||
GunnerEquipment equip = CreateNewGun(null, null, null, null, null, null, projObj);
|
||||
for (GunnerEquipment i : DefinedEquipment.values()) {
|
||||
sender.sendMessage("§eEnabled Weapon : " + i.EquipmentName);
|
||||
sender.sendMessage("§eWeapon Propellant/\"Fuel\" ItemStacks : " + i.FuelMaterial);
|
||||
for (ItemStack proj : i.Projectiles.keySet()) {
|
||||
sender.sendMessage("§eWeapon Projectile ItemStacks : " + proj);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§eGunners Core configs reloaded");
|
||||
break;
|
||||
}
|
||||
|
||||
public static HashMap<UUID, List<Entity>> TrackedStands = new HashMap<UUID, List<Entity>>();
|
||||
} else {
|
||||
sender.sendMessage("§eIncorrect usage, /SiegeEngines get, /SiegeEngines reload");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<UUID, GunnerEquipment> equipment = new HashMap<UUID, GunnerEquipment>();
|
||||
public static GunnerEquipment CreateClone(Integer ModelId) {
|
||||
try {
|
||||
return DefinedEquipment.get(ModelId).clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
||||
public static String convertTime(long time){
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
time -= TimeUnit.DAYS.toMillis(days);
|
||||
public static HashMap<Integer, GunnerEquipment> DefinedEquipment = new HashMap<Integer, GunnerEquipment>();
|
||||
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(time);
|
||||
time -= TimeUnit.HOURS.toMillis(hours);
|
||||
public static HashMap<UUID, List<Entity>> TrackedStands = new HashMap<UUID, List<Entity>>();
|
||||
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
time -= TimeUnit.MINUTES.toMillis(minutes);
|
||||
public static HashMap<UUID, GunnerEquipment> equipment = new HashMap<UUID, GunnerEquipment>();
|
||||
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time);
|
||||
String timeLeftFormatted = String.format("§e" + minutes + " Minutes " +seconds +" Seconds§f");
|
||||
public static String convertTime(long time) {
|
||||
|
||||
return timeLeftFormatted;
|
||||
}
|
||||
|
||||
public static GunnerEquipment CreateNewGun(String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack,GunnersProjectile> projObj) {
|
||||
GunnerEquipment equip = new GunnerEquipment();
|
||||
if (customModelId == null || customModelId == 0)
|
||||
customModelId = 150;
|
||||
if (name == null)
|
||||
name = "Light Turret";
|
||||
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.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;
|
||||
}
|
||||
long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
time -= TimeUnit.DAYS.toMillis(days);
|
||||
|
||||
public static void AddDefaults() {
|
||||
GunnerEquipment equip = new GunnerEquipment();
|
||||
equip.EquipmentName = "Trebuchet";
|
||||
equip.XOffset = 5;
|
||||
equip.YOffset = 5;
|
||||
equip.VelocityPerFuel = 0.3f;
|
||||
ExplosiveProjectile proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 2;
|
||||
equip.shotAmount = 1;
|
||||
equip.RotateStandHead = false;
|
||||
equip.RotateSideways = true;
|
||||
equip.FuelMaterial = new ItemStack(Material.STRING);
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.ReadyModelNumber = 122;
|
||||
equip.ModelNumberToFireAt = 135;
|
||||
equip.MillisecondsBetweenFiringStages = 2;
|
||||
equip.MillisecondsBetweenReloadingStages = 10;
|
||||
equip.FiringModelNumbers = new ArrayList<>(Arrays.asList(
|
||||
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139
|
||||
));
|
||||
equip.CycleThroughModelsBeforeFiring = true;
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
|
||||
equip = new GunnerEquipment();
|
||||
equip.EquipmentName = "Naval Cannon";
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.shotAmount = 1;
|
||||
equip.ReadyModelNumber = 142;
|
||||
equip.ModelNumberToFireAt = 142;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
equip.RotateStandHead = true;
|
||||
equip.RotateSideways = false;
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ProjectilesCount = 3;
|
||||
proj.DelayedFire = true;
|
||||
proj.Inaccuracy = 0.75f;
|
||||
equip.Projectiles.put(new ItemStack(Material.TNT), proj);
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 4;
|
||||
proj.ProjectilesCount = 1;
|
||||
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(time);
|
||||
time -= TimeUnit.HOURS.toMillis(hours);
|
||||
|
||||
EntityProjectile fireProj = new EntityProjectile();
|
||||
fireProj.EntityCount = 2;
|
||||
fireProj.EntityTyp = EntityType.SMALL_FIREBALL;
|
||||
fireProj.ParticleType = Particle.WHITE_ASH;
|
||||
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
|
||||
equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj);
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
equip = new GunnerEquipment();
|
||||
equip.EquipmentName = "Siege Cannon";
|
||||
proj.ExplodePower = 2;
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.shotAmount = 1;
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.ReadyModelNumber = 141;
|
||||
equip.ModelNumberToFireAt = 141;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
equip.RotateStandHead = true;
|
||||
equip.RotateSideways = true;
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ProjectilesCount = 3;
|
||||
proj.DelayedFire = true;
|
||||
proj.Inaccuracy = 0.5f;
|
||||
equip.Projectiles.put(new ItemStack(Material.TNT), proj);
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 4;
|
||||
proj.ProjectilesCount = 1;
|
||||
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj);
|
||||
equip.Projectiles.put(new ItemStack(Material.GRAVEL), new EntityProjectile());
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
time -= TimeUnit.MINUTES.toMillis(minutes);
|
||||
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time);
|
||||
String timeLeftFormatted = String.format("§e" + minutes + " Minutes " + seconds + " Seconds§f");
|
||||
|
||||
return timeLeftFormatted;
|
||||
}
|
||||
|
||||
public static GunnerEquipment CreateNewGun(String name, Integer XOffset, Integer YOffset, Integer fuelMax, Float fuelVelocityMod, Integer customModelId, HashMap<ItemStack, GunnersProjectile> projObj) {
|
||||
GunnerEquipment equip = new GunnerEquipment();
|
||||
if (customModelId == null || customModelId == 0)
|
||||
customModelId = 150;
|
||||
if (name == null)
|
||||
name = "Light Turret";
|
||||
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.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() {
|
||||
GunnerEquipment equip = new GunnerEquipment();
|
||||
equip.EquipmentName = "Trebuchet";
|
||||
equip.XOffset = 5;
|
||||
equip.YOffset = 5;
|
||||
equip.VelocityPerFuel = 0.3f;
|
||||
ExplosiveProjectile proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 2;
|
||||
equip.shotAmount = 1;
|
||||
equip.RotateStandHead = false;
|
||||
equip.RotateSideways = true;
|
||||
equip.FuelMaterial = new ItemStack(Material.STRING);
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.ReadyModelNumber = 122;
|
||||
equip.ModelNumberToFireAt = 135;
|
||||
equip.MillisecondsBetweenFiringStages = 2;
|
||||
equip.MillisecondsBetweenReloadingStages = 10;
|
||||
equip.FiringModelNumbers = new ArrayList<>(Arrays.asList(
|
||||
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139
|
||||
));
|
||||
equip.CycleThroughModelsBeforeFiring = true;
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
|
||||
equip = new GunnerEquipment();
|
||||
equip.EquipmentName = "Naval Cannon";
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.shotAmount = 1;
|
||||
equip.ReadyModelNumber = 142;
|
||||
equip.ModelNumberToFireAt = 142;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
equip.RotateStandHead = true;
|
||||
equip.RotateSideways = false;
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ProjectilesCount = 3;
|
||||
proj.DelayedFire = true;
|
||||
proj.Inaccuracy = 0.75f;
|
||||
equip.Projectiles.put(new ItemStack(Material.TNT), proj);
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 4;
|
||||
proj.ProjectilesCount = 1;
|
||||
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj);
|
||||
|
||||
EntityProjectile fireProj = new EntityProjectile();
|
||||
fireProj.EntityCount = 2;
|
||||
fireProj.EntityTyp = EntityType.SMALL_FIREBALL;
|
||||
fireProj.ParticleType = Particle.WHITE_ASH;
|
||||
fireProj.SoundType = Sound.ENTITY_BLAZE_SHOOT;
|
||||
equip.Projectiles.put(new ItemStack(Material.FIRE_CHARGE), fireProj);
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
equip = new GunnerEquipment();
|
||||
equip.EquipmentName = "Siege Cannon";
|
||||
proj.ExplodePower = 2;
|
||||
equip.Projectiles.put(new ItemStack(Material.COBBLESTONE), proj);
|
||||
equip.shotAmount = 1;
|
||||
equip.PlacementOffsetY = -1;
|
||||
equip.ReadyModelNumber = 141;
|
||||
equip.ModelNumberToFireAt = 141;
|
||||
equip.FiringModelNumbers = new ArrayList<Integer>();
|
||||
equip.RotateStandHead = true;
|
||||
equip.RotateSideways = true;
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 1;
|
||||
proj.ProjectilesCount = 3;
|
||||
proj.DelayedFire = true;
|
||||
proj.Inaccuracy = 0.5f;
|
||||
equip.Projectiles.put(new ItemStack(Material.TNT), proj);
|
||||
proj = new ExplosiveProjectile();
|
||||
proj.ExplodePower = 4;
|
||||
proj.ProjectilesCount = 1;
|
||||
equip.Projectiles.put(new ItemStack(Material.COPPER_BLOCK), proj);
|
||||
equip.Projectiles.put(new ItemStack(Material.GRAVEL), new EntityProjectile());
|
||||
DefinedEquipment.put(equip.ReadyModelNumber, equip);
|
||||
// EntityProjectile pig = new EntityProjectile();
|
||||
// pig.EntityCount = 100;
|
||||
// pig.DelayedFire = true;
|
||||
@@ -328,121 +328,119 @@ public class SiegeEngines extends JavaPlugin {
|
||||
// equip.Projectiles.put(Material.PORKCHOP, pig);
|
||||
// equip.Projectiles.put(Material.BONE, new PotionProjectile());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean CreateCannon(Entity player, int CustomModelData, Location l) {
|
||||
//l.setY(l.getY() - 1);
|
||||
l.add(0.5, 0, 0.5);
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
|
||||
GunnerEquipment equip = CreateClone(CustomModelData);
|
||||
if (equip == null || !equip.Enabled) {
|
||||
return false;
|
||||
}
|
||||
l.setY(l.getY() + 1);
|
||||
int maxNearby = 0;
|
||||
public static Boolean CreateCannon(Entity player, int CustomModelData, Location l) {
|
||||
//l.setY(l.getY() - 1);
|
||||
l.add(0.5, 0, 0.5);
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
|
||||
GunnerEquipment equip = CreateClone(CustomModelData);
|
||||
if (equip == null || !equip.Enabled) {
|
||||
return false;
|
||||
}
|
||||
l.setY(l.getY() + 1);
|
||||
int maxNearby = 0;
|
||||
|
||||
l.setDirection(player.getFacing().getDirection());
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
String id = "";
|
||||
equip.AmmoHolder = new EquipmentMagazine();
|
||||
if (equip.HaseBaseStand) {
|
||||
|
||||
Location l2 = l;
|
||||
l2.setY(l.getY() + equip.BaseStandOffset);
|
||||
Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
|
||||
LivingEntity ent = (LivingEntity) entity3;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
id = entity3.getUniqueId().toString();
|
||||
meta.setCustomModelData(equip.BaseStandModelNumber);
|
||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
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);
|
||||
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.setBasePlate(false);
|
||||
// stand.setSmall(true);
|
||||
item.setItemMeta(meta);
|
||||
stand.setInvisible(equip.AllowInvisibleStand);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
stand.setGravity(false);
|
||||
stand.setMarker(true);
|
||||
}
|
||||
l.setY(l.getY() + equip.PlacementOffsetY);
|
||||
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
if (id != "") {
|
||||
entity2.getPersistentDataContainer().set(key, PersistentDataType.STRING, id);
|
||||
}
|
||||
meta.setCustomModelData(equip.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + equip.EquipmentName +" Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
l.setDirection(player.getFacing().getDirection());
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
String id = "";
|
||||
equip.AmmoHolder = new EquipmentMagazine();
|
||||
if (equip.HaseBaseStand) {
|
||||
|
||||
// entity3.addPassenger(entity2);
|
||||
|
||||
LivingEntity ent = (LivingEntity) entity2;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
equip.Entity = entity2;
|
||||
for (Entity le : l.getNearbyEntities(5, 5, 5)) {
|
||||
if (maxNearby >= 4) {
|
||||
ent.damage(100.0d,player);
|
||||
return false;
|
||||
}
|
||||
if (le instanceof ArmorStand)
|
||||
maxNearby++;
|
||||
}
|
||||
|
||||
equip.EntityId = entity2.getUniqueId();
|
||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
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);
|
||||
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.setInvisible(equip.AllowInvisibleStand);
|
||||
stand.setBasePlate(false);
|
||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
||||
// stand.setSmall(true);
|
||||
|
||||
stand.setGravity(false);
|
||||
//stand.setSmall(true);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
if (TrackedStands.containsKey(player.getUniqueId())) {
|
||||
List<Entity> entities = TrackedStands.get(player.getUniqueId());
|
||||
entities.add(entity2);
|
||||
TrackedStands.put(player.getUniqueId(), entities);
|
||||
}
|
||||
else {
|
||||
List<Entity> newList = new ArrayList<Entity>();
|
||||
newList.add(entity2);
|
||||
TrackedStands.put(player.getUniqueId(), newList);
|
||||
}
|
||||
equipment.put(entity2.getUniqueId(), equip);
|
||||
return true;
|
||||
}
|
||||
Location l2 = l;
|
||||
l2.setY(l.getY() + equip.BaseStandOffset);
|
||||
Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
|
||||
public static void UpdateEntityIdModel(Entity ent, int modelNumber, String WorldName) {
|
||||
if (ent instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity liv = (LivingEntity) ent;
|
||||
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?");
|
||||
}
|
||||
}
|
||||
}
|
||||
LivingEntity ent = (LivingEntity) entity3;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
id = entity3.getUniqueId().toString();
|
||||
meta.setCustomModelData(equip.BaseStandModelNumber);
|
||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
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);
|
||||
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.setBasePlate(false);
|
||||
// stand.setSmall(true);
|
||||
item.setItemMeta(meta);
|
||||
stand.setInvisible(equip.AllowInvisibleStand);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
stand.setGravity(false);
|
||||
stand.setMarker(true);
|
||||
}
|
||||
l.setY(l.getY() + equip.PlacementOffsetY);
|
||||
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
if (id != "") {
|
||||
entity2.getPersistentDataContainer().set(key, PersistentDataType.STRING, id);
|
||||
}
|
||||
meta.setCustomModelData(equip.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + equip.EquipmentName + " Item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
Lore.add("§ePlace as a block to spawn a " + equip.EquipmentName + " or put on an Armor Stand.");
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
// entity3.addPassenger(entity2);
|
||||
|
||||
LivingEntity ent = (LivingEntity) entity2;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
equip.Entity = entity2;
|
||||
for (Entity le : l.getNearbyEntities(5, 5, 5)) {
|
||||
if (maxNearby >= 4) {
|
||||
ent.damage(100.0d, player);
|
||||
return false;
|
||||
}
|
||||
if (le instanceof ArmorStand)
|
||||
maxNearby++;
|
||||
}
|
||||
|
||||
equip.EntityId = entity2.getUniqueId();
|
||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
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);
|
||||
stand.addEquipmentLock(EquipmentSlot.HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.OFF_HAND, LockType.REMOVING_OR_CHANGING);
|
||||
stand.setInvisible(equip.AllowInvisibleStand);
|
||||
stand.setBasePlate(false);
|
||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
||||
// stand.setSmall(true);
|
||||
|
||||
stand.setGravity(false);
|
||||
//stand.setSmall(true);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
if (TrackedStands.containsKey(player.getUniqueId())) {
|
||||
List<Entity> entities = TrackedStands.get(player.getUniqueId());
|
||||
entities.add(entity2);
|
||||
TrackedStands.put(player.getUniqueId(), entities);
|
||||
} else {
|
||||
List<Entity> newList = new ArrayList<Entity>();
|
||||
newList.add(entity2);
|
||||
TrackedStands.put(player.getUniqueId(), newList);
|
||||
}
|
||||
equipment.put(entity2.getUniqueId(), equip);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void UpdateEntityIdModel(Entity ent, int modelNumber, String WorldName) {
|
||||
if (ent instanceof LivingEntity) {
|
||||
LivingEntity liv = (LivingEntity) ent;
|
||||
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?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,74 +23,74 @@ import com.github.alathra.siegeengines.GunnerEquipment;
|
||||
|
||||
public class RotationHandler implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
|
||||
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (itemInHand != null) {
|
||||
if (itemInHand.getType() != Material.COMPASS) {
|
||||
// TrackedStands.remove(player.getUniqueId());
|
||||
@EventHandler
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
NamespacedKey key = new NamespacedKey(SiegeEngines.plugin, "cannons");
|
||||
if (SiegeEngines.TrackedStands.containsKey(player.getUniqueId())) {
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
if (itemInHand != null) {
|
||||
if (itemInHand.getType() != Material.COMPASS) {
|
||||
// TrackedStands.remove(player.getUniqueId());
|
||||
|
||||
return;
|
||||
}
|
||||
for (Entity ent : SiegeEngines.TrackedStands.get(player.getUniqueId())) {
|
||||
if (ent != null) {
|
||||
GunnerEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId());
|
||||
if (ent.isDead()) {
|
||||
continue;
|
||||
}
|
||||
double distance = player.getLocation().distance(ent.getLocation());
|
||||
if (distance <= 250) {
|
||||
// player.sendMessage("§egot id");
|
||||
LivingEntity living = (LivingEntity) ent;
|
||||
Location loc = ent.getLocation();
|
||||
|
||||
if (equipment.RotateSideways) {
|
||||
Location direction = player.getLocation().add(player.getLocation().getDirection().multiply(50));
|
||||
return;
|
||||
}
|
||||
for (Entity ent : SiegeEngines.TrackedStands.get(player.getUniqueId())) {
|
||||
if (ent != null) {
|
||||
GunnerEquipment equipment = SiegeEngines.equipment.get(ent.getUniqueId());
|
||||
if (ent.isDead()) {
|
||||
continue;
|
||||
}
|
||||
double distance = player.getLocation().distance(ent.getLocation());
|
||||
if (distance <= 250) {
|
||||
// player.sendMessage("§egot id");
|
||||
LivingEntity living = (LivingEntity) ent;
|
||||
Location loc = ent.getLocation();
|
||||
|
||||
Vector dirBetweenLocations = direction.toVector().subtract(loc.toVector());
|
||||
if (ent.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
||||
Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING)));
|
||||
Location baseloc = base.getLocation();
|
||||
baseloc.setDirection(dirBetweenLocations);
|
||||
base.teleport(baseloc);
|
||||
}
|
||||
loc.setDirection(dirBetweenLocations);
|
||||
}
|
||||
//loc.setYaw(player.getLocation().getYaw());
|
||||
//loc.setPitch(player.getLocation().getPitch());
|
||||
|
||||
|
||||
ArmorStand stand = (ArmorStand) living;
|
||||
|
||||
if (equipment.RotateUpDown) {
|
||||
loc.setPitch(player.getLocation().getPitch());
|
||||
if (loc.getPitch() < -85) {
|
||||
loc.setPitch(-85);
|
||||
}
|
||||
if (loc.getPitch() > 85) {
|
||||
loc.setPitch(85);
|
||||
}
|
||||
if (equipment.RotateStandHead) {
|
||||
stand.setHeadPose(new EulerAngle(loc.getDirection().getY()*(-1),0,0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
living.teleport(loc);
|
||||
equipment.ShowFireLocation(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector getDirectionBetweenLocations(Location Start, Location End) {
|
||||
Vector from = Start.toVector();
|
||||
Vector to = End.toVector();
|
||||
return to.subtract(from);
|
||||
}
|
||||
if (equipment.RotateSideways) {
|
||||
Location direction = player.getLocation().add(player.getLocation().getDirection().multiply(50));
|
||||
|
||||
Vector dirBetweenLocations = direction.toVector().subtract(loc.toVector());
|
||||
if (ent.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
||||
Entity base = Bukkit.getEntity(UUID.fromString(ent.getPersistentDataContainer().get(key, PersistentDataType.STRING)));
|
||||
Location baseloc = base.getLocation();
|
||||
baseloc.setDirection(dirBetweenLocations);
|
||||
base.teleport(baseloc);
|
||||
}
|
||||
loc.setDirection(dirBetweenLocations);
|
||||
}
|
||||
//loc.setYaw(player.getLocation().getYaw());
|
||||
//loc.setPitch(player.getLocation().getPitch());
|
||||
|
||||
|
||||
ArmorStand stand = (ArmorStand) living;
|
||||
|
||||
if (equipment.RotateUpDown) {
|
||||
loc.setPitch(player.getLocation().getPitch());
|
||||
if (loc.getPitch() < -85) {
|
||||
loc.setPitch(-85);
|
||||
}
|
||||
if (loc.getPitch() > 85) {
|
||||
loc.setPitch(85);
|
||||
}
|
||||
if (equipment.RotateStandHead) {
|
||||
stand.setHeadPose(new EulerAngle(loc.getDirection().getY() * (-1), 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
living.teleport(loc);
|
||||
equipment.ShowFireLocation(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector getDirectionBetweenLocations(Location Start, Location End) {
|
||||
Vector from = Start.toVector();
|
||||
Vector to = End.toVector();
|
||||
return to.subtract(from);
|
||||
}
|
||||
}
|
||||
@@ -12,78 +12,79 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EntityProjectile implements GunnersProjectile{
|
||||
public class EntityProjectile implements GunnersProjectile {
|
||||
|
||||
public String ProjectileType = "Entity";
|
||||
public int EntityCount = 20;
|
||||
public int ArrowOnlyDamage = 6;
|
||||
public Boolean DelayedFire = false;
|
||||
public int DelayTime = 6;
|
||||
public EntityType EntityTyp = EntityType.ARROW;
|
||||
public float Inaccuracy = 0.2f;
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location FireLocation, Float velocity) {
|
||||
PlaySound = true;
|
||||
int baseDelay = 0;
|
||||
for (int i = 0; i < EntityCount; i++) {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
|
||||
|
||||
CreateEntity(entity, FireLocation, velocity, player);
|
||||
}, (long) baseDelay);
|
||||
}
|
||||
else {
|
||||
public String ProjectileType = "Entity";
|
||||
public int EntityCount = 20;
|
||||
public int ArrowOnlyDamage = 6;
|
||||
public Boolean DelayedFire = false;
|
||||
public int DelayTime = 6;
|
||||
public EntityType EntityTyp = EntityType.ARROW;
|
||||
public float Inaccuracy = 0.2f;
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
|
||||
CreateEntity(entity, FireLocation, velocity, player);
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
private boolean PlaySound = true;
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) {
|
||||
World world = entity.getLocation().getWorld();
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location FireLocation, Float velocity) {
|
||||
PlaySound = true;
|
||||
int baseDelay = 0;
|
||||
for (int i = 0; i < EntityCount; i++) {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
|
||||
|
||||
Entity arrow = world.spawnEntity(loc, EntityTyp);
|
||||
if (Inaccuracy != 0f) {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
.subtract(Randomise()));
|
||||
}
|
||||
else {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
arrow.setMetadata("isEntityProj",SiegeEngines.addMetaDataValue("true"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
||||
|
||||
if (arrow instanceof org.bukkit.entity.Projectile) {
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
((org.bukkit.entity.Projectile)arrow).setShooter((org.bukkit.projectiles.ProjectileSource)player);
|
||||
}
|
||||
if (arrow instanceof Arrow) {
|
||||
Arrow arr = (Arrow) arrow;
|
||||
arr.setDamage(8);
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
arr.setShooter((org.bukkit.projectiles.ProjectileSource)player);
|
||||
//arr.setBasePotionData(arg0);
|
||||
}
|
||||
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
|
||||
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
|
||||
if (PlaySound) {
|
||||
world.playSound(loc, this.SoundType, 20, 2);
|
||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
if (!DelayedFire) {
|
||||
PlaySound = false;
|
||||
}
|
||||
}
|
||||
CreateEntity(entity, FireLocation, velocity, player);
|
||||
}, (long) baseDelay);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
private Vector Randomise() {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
||||
}
|
||||
CreateEntity(entity, FireLocation, velocity, player);
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private boolean PlaySound = true;
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) {
|
||||
World world = entity.getLocation().getWorld();
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
|
||||
Entity arrow = world.spawnEntity(loc, EntityTyp);
|
||||
if (Inaccuracy != 0f) {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
.subtract(Randomise()));
|
||||
} else {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
arrow.setMetadata("isEntityProj", SiegeEngines.addMetaDataValue("true"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
||||
|
||||
if (arrow instanceof org.bukkit.entity.Projectile) {
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
((org.bukkit.entity.Projectile) arrow).setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
}
|
||||
if (arrow instanceof Arrow) {
|
||||
Arrow arr = (Arrow) arrow;
|
||||
arr.setDamage(8);
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
arr.setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
//arr.setBasePotionData(arg0);
|
||||
}
|
||||
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
|
||||
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
|
||||
if (PlaySound) {
|
||||
world.playSound(loc, this.SoundType, 20, 2);
|
||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
if (!DelayedFire) {
|
||||
PlaySound = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Vector Randomise() {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,74 +17,73 @@ import org.bukkit.util.Vector;
|
||||
//import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
|
||||
public class ExplosiveProjectile implements GunnersProjectile {
|
||||
|
||||
public String ProjectileType = "Explosive";
|
||||
public Boolean PlaceBlocks = false;
|
||||
public Material BlockToPlace = Material.COBWEB;
|
||||
public int BlocksToPlaceAmount = 3;
|
||||
public float ExplodePower = 2;
|
||||
public float Inaccuracy = 0.3f;
|
||||
public int ProjectilesCount = 1;
|
||||
public Boolean DelayedFire = false;
|
||||
public int DelayTime = 6;
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
private boolean PlaySound = true;
|
||||
public Boolean AlertOnLanding = false;
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||
PlaySound = true;
|
||||
int baseDelay = 0;
|
||||
for (int i = 0; i < ProjectilesCount; i++) {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
|
||||
CreateEntity(entity, loc, velocity, player);
|
||||
}, (long) baseDelay);
|
||||
}
|
||||
else {
|
||||
CreateEntity(entity,loc, velocity, player);
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) {
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
World world = entity.getLocation().getWorld();
|
||||
Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL);
|
||||
Snowball ball = (Snowball) tnt;
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
ball.setShooter((org.bukkit.projectiles.ProjectileSource)player);
|
||||
ClickHandler.projectiles.put(tnt.getUniqueId(), this);
|
||||
|
||||
if (Inaccuracy != 0f) {
|
||||
tnt.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
.subtract(Randomise()));
|
||||
}
|
||||
else {
|
||||
tnt.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
tnt.setMetadata("isExplosiveProj",SiegeEngines.addMetaDataValue("true"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(tnt));
|
||||
public String ProjectileType = "Explosive";
|
||||
public Boolean PlaceBlocks = false;
|
||||
public Material BlockToPlace = Material.COBWEB;
|
||||
public int BlocksToPlaceAmount = 3;
|
||||
public float ExplodePower = 2;
|
||||
public float Inaccuracy = 0.3f;
|
||||
public int ProjectilesCount = 1;
|
||||
public Boolean DelayedFire = false;
|
||||
public int DelayTime = 6;
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
private boolean PlaySound = true;
|
||||
public Boolean AlertOnLanding = false;
|
||||
|
||||
if (PlaySound) {
|
||||
world.playSound(loc, this.SoundType, 20, 2);
|
||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
if (!DelayedFire) {
|
||||
PlaySound = false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||
PlaySound = true;
|
||||
int baseDelay = 0;
|
||||
for (int i = 0; i < ProjectilesCount; i++) {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
|
||||
CreateEntity(entity, loc, velocity, player);
|
||||
}, (long) baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, loc, velocity, player);
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Entity player) {
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
World world = entity.getLocation().getWorld();
|
||||
Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL);
|
||||
Snowball ball = (Snowball) tnt;
|
||||
if (player instanceof org.bukkit.projectiles.ProjectileSource)
|
||||
ball.setShooter((org.bukkit.projectiles.ProjectileSource) player);
|
||||
ClickHandler.projectiles.put(tnt.getUniqueId(), this);
|
||||
|
||||
if (Inaccuracy != 0f) {
|
||||
tnt.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
.subtract(Randomise()));
|
||||
} else {
|
||||
tnt.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
tnt.setMetadata("isExplosiveProj", SiegeEngines.addMetaDataValue("true"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(tnt));
|
||||
|
||||
if (PlaySound) {
|
||||
world.playSound(loc, this.SoundType, 20, 2);
|
||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
if (!DelayedFire) {
|
||||
PlaySound = false;
|
||||
}
|
||||
}
|
||||
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.ARROW);
|
||||
// miscDisguise.setEntity(tnt);
|
||||
// miscDisguise.startDisguise();
|
||||
|
||||
}
|
||||
|
||||
private Vector Randomise() {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
||||
}
|
||||
}
|
||||
|
||||
private Vector Randomise() {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public interface GunnersProjectile {
|
||||
public void Shoot(Entity player, Entity entity, Location fireLocation, Float velocity);
|
||||
public String ProjectileType = "Default";
|
||||
public void Shoot(Entity player, Entity entity, Location fireLocation, Float velocity);
|
||||
|
||||
public String ProjectileType = "Default";
|
||||
}
|
||||
|
||||
@@ -18,58 +18,57 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PotionProjectile implements GunnersProjectile {
|
||||
public String ProjectileType = "Potion";
|
||||
public int EntityCount = 3;
|
||||
public Boolean DelayedFire = false;
|
||||
public int DelayTime = 6;
|
||||
public float Inaccuracy = 0.1f;
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||
//TODO Auto-generated method stub
|
||||
int baseDelay = 0;
|
||||
for (int i = 0; i < EntityCount; i++) {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
|
||||
|
||||
CreateEntity(entity,loc, velocity);
|
||||
}, (long) baseDelay);
|
||||
}
|
||||
else {
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity) {
|
||||
World world = entity.getLocation().getWorld();
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
public String ProjectileType = "Potion";
|
||||
public int EntityCount = 3;
|
||||
public Boolean DelayedFire = false;
|
||||
public int DelayTime = 6;
|
||||
public float Inaccuracy = 0.1f;
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
|
||||
Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION);
|
||||
if (Inaccuracy != 0f) {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()).subtract(Randomise()));
|
||||
}
|
||||
else {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
arrow.setMetadata("isExplosiveProj",SiegeEngines.addMetaDataValue("true"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
||||
ItemStack itemStack = new ItemStack(Material.SPLASH_POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 100, 3, true), true);
|
||||
itemStack.setItemMeta(potionMeta);
|
||||
ThrownPotion potion = (ThrownPotion) arrow;
|
||||
potion.setItem(itemStack);
|
||||
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
|
||||
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
|
||||
world.playSound(loc, this.SoundType, 20, 2);
|
||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
}
|
||||
|
||||
private Vector Randomise() {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1),SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
||||
}
|
||||
@Override
|
||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||
//TODO Auto-generated method stub
|
||||
int baseDelay = 0;
|
||||
for (int i = 0; i < EntityCount; i++) {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.plugin, () -> {
|
||||
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}, (long) baseDelay);
|
||||
} else {
|
||||
CreateEntity(entity, loc, velocity);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity) {
|
||||
World world = entity.getLocation().getWorld();
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
|
||||
Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION);
|
||||
if (Inaccuracy != 0f) {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()).subtract(Randomise()));
|
||||
} else {
|
||||
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
||||
}
|
||||
arrow.setMetadata("isExplosiveProj", SiegeEngines.addMetaDataValue("true"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
||||
ItemStack itemStack = new ItemStack(Material.SPLASH_POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 100, 3, true), true);
|
||||
itemStack.setItemMeta(potionMeta);
|
||||
ThrownPotion potion = (ThrownPotion) arrow;
|
||||
potion.setItem(itemStack);
|
||||
// MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
|
||||
// DisguiseAPI.disguiseEntity(arrow, miscDisguise);
|
||||
world.playSound(loc, this.SoundType, 20, 2);
|
||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
}
|
||||
|
||||
private Vector Randomise() {
|
||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user