mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 14:38:55 +00:00
style: reformat and .editorconfig
This commit is contained in:
11 files changed
+1893
-1468
No files matched your search
@@ -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?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user