Bump Version (0.8.5)

Potential fix for regular armor stands.
This commit is contained in:
C_Corp2002 authored and GitHub committed 2024-02-24 14:43:26 -05:00
1 parent 40c7e39024
commit fedc87e7ce
8 files changed
+121 -43

No files matched your search

+1 -3
View File
@@ -6,10 +6,8 @@
<groupId>com.github.alathra</groupId> <groupId>com.github.alathra</groupId>
<artifactId>SiegeEngines</artifactId> <artifactId>SiegeEngines</artifactId>
<version>0.8.3</version> <version>0.8.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SiegeEngines</name>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -68,6 +68,7 @@ public class SiegeEngine implements Cloneable {
private int readyModelNumber; private int readyModelNumber;
private int nextModelNumber; // Internal private int nextModelNumber; // Internal
private int preFireModelNumber; private int preFireModelNumber;
private int preLoadModelNumber;
private SiegeEngineAmmoHolder ammoHolder; private SiegeEngineAmmoHolder ammoHolder;
// Optional variables // Optional variables
@@ -111,6 +112,7 @@ public class SiegeEngine implements Cloneable {
setReadyModelNumber(customModelID); setReadyModelNumber(customModelID);
setModelNumberToFireAt(customModelID); setModelNumberToFireAt(customModelID);
setPreFireModelNumber(customModelID); setPreFireModelNumber(customModelID);
setPreLoadModelNumber(customModelID);
setFiringModelNumbers(new ArrayList<Integer>()); setFiringModelNumbers(new ArrayList<Integer>());
setAmmoHolder(new SiegeEngineAmmoHolder()); setAmmoHolder(new SiegeEngineAmmoHolder());
//fuelItem = new ItemStack(Material.GUNPOWDER); //fuelItem = new ItemStack(Material.GUNPOWDER);
@@ -682,6 +684,14 @@ public class SiegeEngine implements Cloneable {
this.preFireModelNumber = preFireModelNumber; this.preFireModelNumber = preFireModelNumber;
} }
public int getPreLoadModelNumber() {
return preLoadModelNumber;
}
public void setPreLoadModelNumber(int preLoadModelNumber) {
this.preLoadModelNumber = preLoadModelNumber;
}
public SiegeEngineAmmoHolder getAmmoHolder() { public SiegeEngineAmmoHolder getAmmoHolder() {
return ammoHolder; return ammoHolder;
} }
@@ -9,7 +9,6 @@ import java.util.UUID;
import com.github.alathra.siegeengines.command.CommandHandler; import com.github.alathra.siegeengines.command.CommandHandler;
import com.github.alathra.siegeengines.config.Config; import com.github.alathra.siegeengines.config.Config;
import com.github.alathra.siegeengines.crafting.CraftingRecipes;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@@ -70,11 +69,6 @@ public class SiegeEngines extends JavaPlugin {
} }
} }
commandHandler.onEnable(); commandHandler.onEnable();
// load crafting recipes if enabled in config
if (Config.craftingRecipes) {
CraftingRecipes.loadCraftingRecipes();
}
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@@ -144,7 +138,7 @@ public class SiegeEngines extends JavaPlugin {
// Ballista // Ballista
SiegeEngine ballista = new SiegeEngine("Ballista", Config.ballistaProjectiles, new ItemStack(Material.STRING), SiegeEngine ballista = new SiegeEngine("Ballista", Config.ballistaProjectiles, new ItemStack(Material.STRING),
145); 146);
// config options // config options
ballista.setType(SiegeEngineType.BALLISTA); ballista.setType(SiegeEngineType.BALLISTA);
ballista.setItemName(Config.ballistaItemName); ballista.setItemName(Config.ballistaItemName);
@@ -157,14 +151,15 @@ public class SiegeEngines extends JavaPlugin {
ballista.setHealth(Config.ballistaHealth); ballista.setHealth(Config.ballistaHealth);
ballista.setXOffset(1); ballista.setXOffset(1);
ballista.setYOffset(1); ballista.setYOffset(1);
ballista.setPlacementOffsetY(-0.75); ballista.setPlacementOffsetY(-1.25);
ballista.setRotateStandHead(true); ballista.setRotateStandHead(true);
ballista.setRotateSideways(true); ballista.setRotateSideways(true);
ballista.setSetModelNumberWhenFullyLoaded(true); ballista.setSetModelNumberWhenFullyLoaded(true);
ballista.setReadyModelNumber(145); ballista.setReadyModelNumber(146);
ballista.setModelNumberToFireAt(145); ballista.setModelNumberToFireAt(146);
ballista.setPreFireModelNumber(143); ballista.setPreFireModelNumber(143);
ballista.setFiringModelNumbers(new ArrayList<>(Arrays.asList(143, 144, 145))); ballista.setPreLoadModelNumber(144);
ballista.setFiringModelNumbers(new ArrayList<>(Arrays.asList(143, 144, 145, 146)));
ballista.setCycleThroughModelsWhileFiring(true); ballista.setCycleThroughModelsWhileFiring(true);
ballista.setMountable(Config.ballistaCanMount); ballista.setMountable(Config.ballistaCanMount);
definedSiegeEngines.put(ballista.getReadyModelNumber(), ballista); definedSiegeEngines.put(ballista.getReadyModelNumber(), ballista);
@@ -182,6 +177,7 @@ public class SiegeEngines extends JavaPlugin {
swivelCannon.setFuelItem(new ItemStack(Config.swivelCannonFuelItem)); swivelCannon.setFuelItem(new ItemStack(Config.swivelCannonFuelItem));
swivelCannon.setProjectiles(Config.swivelCannonProjectiles); swivelCannon.setProjectiles(Config.swivelCannonProjectiles);
swivelCannon.setHealth(Config.swivelCannonHealth); swivelCannon.setHealth(Config.swivelCannonHealth);
swivelCannon.setXOffset(1);
swivelCannon.setPlacementOffsetY(-1); swivelCannon.setPlacementOffsetY(-1);
swivelCannon.setReadyModelNumber(141); swivelCannon.setReadyModelNumber(141);
swivelCannon.setModelNumberToFireAt(141); swivelCannon.setModelNumberToFireAt(141);
@@ -204,6 +200,7 @@ public class SiegeEngines extends JavaPlugin {
breachCannon.setFuelItem(new ItemStack(Config.breachCannonFuelItem)); breachCannon.setFuelItem(new ItemStack(Config.breachCannonFuelItem));
breachCannon.setProjectiles(Config.breachCannonProjectiles); breachCannon.setProjectiles(Config.breachCannonProjectiles);
breachCannon.setHealth(Config.breachCannonHealth); breachCannon.setHealth(Config.breachCannonHealth);
breachCannon.setXOffset(1);
breachCannon.setPlacementOffsetY(-1); breachCannon.setPlacementOffsetY(-1);
breachCannon.setReadyModelNumber(142); breachCannon.setReadyModelNumber(142);
breachCannon.setModelNumberToFireAt(142); breachCannon.setModelNumberToFireAt(142);
@@ -17,9 +17,11 @@ import org.bukkit.inventory.ItemStack;
import com.github.alathra.siegeengines.SiegeEngines; import com.github.alathra.siegeengines.SiegeEngines;
import com.github.alathra.siegeengines.SiegeEnginesLogger; import com.github.alathra.siegeengines.SiegeEnginesLogger;
import com.github.alathra.siegeengines.SiegeEnginesUtil; import com.github.alathra.siegeengines.SiegeEnginesUtil;
import com.github.alathra.siegeengines.crafting.CraftingRecipes;
import com.github.alathra.siegeengines.projectile.EntityProjectile; import com.github.alathra.siegeengines.projectile.EntityProjectile;
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile; import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
import com.github.alathra.siegeengines.projectile.FireworkProjectile; import com.github.alathra.siegeengines.projectile.FireworkProjectile;
import com.github.alathra.siegeengines.projectile.PotionProjectile;
import com.github.alathra.siegeengines.projectile.ProjectileType; import com.github.alathra.siegeengines.projectile.ProjectileType;
import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile; import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile;
@@ -307,6 +309,22 @@ public class Config {
.getDouble("Projectiles." + projectileName + ".VelocityFactor"); .getDouble("Projectiles." + projectileName + ".VelocityFactor");
projectileMap.put(projectileName, fireworkProjectile); projectileMap.put(projectileName, fireworkProjectile);
break; break;
case POTION:
PotionProjectile potionProjectile = new PotionProjectile(new ItemStack(
Material.getMaterial(config.getString("Projectiles." + projectileName + ".AmmoItem"))));
potionProjectile.inaccuracy = (float) config
.getDouble("Projectiles." + projectileName + ".Inaccuracy");
potionProjectile.entityCount = config.getInt("Projectiles." + projectileName + ".EntityCount");
potionProjectile.delayTime = config.getInt("Projectiles." + projectileName + ".EntityCount");
if (potionProjectile.delayTime <= 0) {
potionProjectile.delayedFire = false;
} else {
potionProjectile.delayedFire = true;
}
potionProjectile.velocityFactor = (float) config
.getDouble("Projectiles." + projectileName + ".VelocityFactor");
projectileMap.put(projectileName, potionProjectile);
break;
default: default:
continue; continue;
} }
@@ -321,6 +339,17 @@ public class Config {
SiegeEngines.getInstance().reloadConfig(); SiegeEngines.getInstance().reloadConfig();
SiegeEngines.getInstance().saveDefaultConfig(); SiegeEngines.getInstance().saveDefaultConfig();
initConfigVals(); initConfigVals();
// load crafting recipes if enabled in config
if (Config.craftingRecipes) {
if (!CraftingRecipes.areLoaded()) {
CraftingRecipes.loadCraftingRecipes();
}
} else {
if (CraftingRecipes.areLoaded()) {
CraftingRecipes.unloadCraftingRecipes();
}
}
} }
public FileConfiguration getConfig() { public FileConfiguration getConfig() {
@@ -12,6 +12,8 @@ import com.github.alathra.siegeengines.api.SiegeEnginesAPI;
public class CraftingRecipes { public class CraftingRecipes {
private static boolean areLoaded = false;
public static Recipe trebuchetRecipe() { public static Recipe trebuchetRecipe() {
ItemStack trebuchet = SiegeEnginesAPI.getTrebuchetItem(); ItemStack trebuchet = SiegeEnginesAPI.getTrebuchetItem();
NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(), NamespacedKey key = new NamespacedKey(SiegeEngines.getInstance(),
@@ -23,7 +25,6 @@ public class CraftingRecipes {
trebuchetRecipe.setIngredient('#', Material.OAK_TRAPDOOR); trebuchetRecipe.setIngredient('#', Material.OAK_TRAPDOOR);
trebuchetRecipe.setIngredient('$', Material.STRING); trebuchetRecipe.setIngredient('$', Material.STRING);
trebuchetRecipe.setIngredient('^', Material.BOWL); trebuchetRecipe.setIngredient('^', Material.BOWL);
SiegeEngines.getInstance().getServer().addRecipe(trebuchetRecipe);
return trebuchetRecipe; return trebuchetRecipe;
} }
@@ -37,7 +38,6 @@ public class CraftingRecipes {
ballistaRecipe.setIngredient('%', Material.STICK); ballistaRecipe.setIngredient('%', Material.STICK);
ballistaRecipe.setIngredient('#', Material.OAK_PLANKS); ballistaRecipe.setIngredient('#', Material.OAK_PLANKS);
ballistaRecipe.setIngredient('$', Material.OAK_LOG); ballistaRecipe.setIngredient('$', Material.OAK_LOG);
SiegeEngines.getInstance().getServer().addRecipe(ballistaRecipe);
return ballistaRecipe; return ballistaRecipe;
} }
@@ -51,7 +51,6 @@ public class CraftingRecipes {
swivelCannonRecipe.setIngredient('%', Material.IRON_BLOCK); swivelCannonRecipe.setIngredient('%', Material.IRON_BLOCK);
swivelCannonRecipe.setIngredient('#', Material.CAULDRON); swivelCannonRecipe.setIngredient('#', Material.CAULDRON);
swivelCannonRecipe.setIngredient('$', Material.ANVIL); swivelCannonRecipe.setIngredient('$', Material.ANVIL);
SiegeEngines.getInstance().getServer().addRecipe(swivelCannonRecipe);
return swivelCannonRecipe; return swivelCannonRecipe;
} }
@@ -65,15 +64,31 @@ public class CraftingRecipes {
breachCannonRecipe.setIngredient('%', SiegeEnginesAPI.getSwivelCannonItem()); breachCannonRecipe.setIngredient('%', SiegeEnginesAPI.getSwivelCannonItem());
breachCannonRecipe.setIngredient('#', Material.CAULDRON); breachCannonRecipe.setIngredient('#', Material.CAULDRON);
breachCannonRecipe.setIngredient('$', Material.ANVIL); breachCannonRecipe.setIngredient('$', Material.ANVIL);
SiegeEngines.getInstance().getServer().addRecipe(breachCannonRecipe);
return breachCannonRecipe; return breachCannonRecipe;
} }
public static void loadCraftingRecipes() { public static void loadCraftingRecipes() {
trebuchetRecipe(); SiegeEngines.getInstance().getServer().addRecipe(trebuchetRecipe());
ballistaRecipe(); SiegeEngines.getInstance().getServer().addRecipe(ballistaRecipe());
swivelCannonRecipe(); SiegeEngines.getInstance().getServer().addRecipe(swivelCannonRecipe());
breachCannonRecipe(); SiegeEngines.getInstance().getServer().addRecipe(breachCannonRecipe());
areLoaded = true;
}
public static void unloadCraftingRecipes() {
SiegeEngines.getInstance().getServer().removeRecipe(new NamespacedKey(SiegeEngines.getInstance(),
SiegeEngines.getInstance().getName() + "trebuchetRecipe"));
SiegeEngines.getInstance().getServer().removeRecipe(new NamespacedKey(SiegeEngines.getInstance(),
SiegeEngines.getInstance().getName() + "ballistaRecipe"));
SiegeEngines.getInstance().getServer().removeRecipe(new NamespacedKey(SiegeEngines.getInstance(),
SiegeEngines.getInstance().getName() + "swivelCannonRecipe"));
SiegeEngines.getInstance().getServer().removeRecipe(new NamespacedKey(SiegeEngines.getInstance(),
SiegeEngines.getInstance().getName() + "breachCannonRecipe"));
areLoaded = false;
}
public static boolean areLoaded() {
return areLoaded;
} }
} }
@@ -17,6 +17,7 @@ import com.github.alathra.siegeengines.SiegeEnginesUtil;
import com.github.alathra.siegeengines.SiegeEngine; import com.github.alathra.siegeengines.SiegeEngine;
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile; import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
import com.github.alathra.siegeengines.projectile.FireworkProjectile; import com.github.alathra.siegeengines.projectile.FireworkProjectile;
import com.github.alathra.siegeengines.projectile.PotionProjectile;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@@ -39,7 +40,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
@@ -298,7 +298,8 @@ public class ClickHandler implements Listener {
return true; return true;
} }
inventoryItem = inventoryItem.clone(); inventoryItem = inventoryItem.clone();
if (!(stack.isSimilar(inventoryItem)) && (stack.getType() != Material.FIREWORK_ROCKET)) if (!(stack.isSimilar(inventoryItem)) && (stack.getType() != Material.FIREWORK_ROCKET)
&& (stack.getType() != Material.SPLASH_POTION))
continue; continue;
inventoryItem.setAmount(1); inventoryItem.setAmount(1);
if (stack.getType() != Material.FIREWORK_ROCKET && stack.isSimilar(inventoryItem) if (stack.getType() != Material.FIREWORK_ROCKET && stack.isSimilar(inventoryItem)
@@ -317,6 +318,15 @@ public class ClickHandler implements Listener {
siegeEngine.getProjectiles().put(inventoryItem, proj); siegeEngine.getProjectiles().put(inventoryItem, proj);
return true; return true;
} }
if (stack.getType() == Material.SPLASH_POTION && inventoryItem.getType() == stack.getType()
&& siegeEngine.getAmmoHolder().getLoadedProjectile() == 0) {
siegeEngine.getAmmoHolder().setLoadedProjectile(1);
siegeEngine.getAmmoHolder().setMaterialName(inventoryItem);
state.getInventory().removeItem(inventoryItem);
PotionProjectile proj = new PotionProjectile(inventoryItem);
siegeEngine.getProjectiles().put(inventoryItem, proj);
return true;
}
continue; continue;
} }
return false; return false;
@@ -619,10 +629,12 @@ public class ClickHandler implements Listener {
} }
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.NORMAL)
public void onEngineDamage(EntityDamageByEntityEvent event) { public void onEngineDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof ArmorStand) { if (event.getEntity() instanceof ArmorStand) {
ArmorStand stand = (ArmorStand)event.getEntity(); ArmorStand stand = (ArmorStand)event.getEntity();
if (isSiegeEngine(stand,false)) return;
if (event.isCancelled()) return;
if (event.getDamager() instanceof Player) { if (event.getDamager() instanceof Player) {
PlayerHandler.releasePlayerSiegeEngine((Player)(event.getDamager()),event.getEntity()); PlayerHandler.releasePlayerSiegeEngine((Player)(event.getDamager()),event.getEntity());
} }
@@ -650,6 +662,7 @@ public class ClickHandler implements Listener {
} }
final List<UUID> keys = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.keySet()); final List<UUID> keys = new ArrayList<>(SiegeEngines.siegeEngineEntitiesPerPlayer.keySet());
int numPilots = 0; int numPilots = 0;
if (add) {
for (UUID player : keys) { for (UUID player : keys) {
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player) != null) { if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player) != null) {
if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player).contains(entity)) { if (SiegeEngines.siegeEngineEntitiesPerPlayer.get(player).contains(entity)) {
@@ -658,6 +671,7 @@ public class ClickHandler implements Listener {
numPilots++; numPilots++;
} }
} }
}
// Can only have one pilot // Can only have one pilot
} }
@@ -1108,13 +1122,17 @@ public class ClickHandler implements Listener {
sendSiegeEngineHelpMSG(player, siegeEngine); sendSiegeEngineHelpMSG(player, siegeEngine);
// If fully loaded && requires change in animation when loaded (i.e. ballista) // If fully loaded && requires change in animation when loaded (i.e. ballista)
if (!siegeEngine.canLoadFuel() && siegeEngine.isSetModelNumberWhenFullyLoaded()) { if (!siegeEngine.canLoadFuel() && siegeEngine.isSetModelNumberWhenFullyLoaded()) {
SiegeEnginesUtil.UpdateEntityIdModel(siegeEngine.getEntity(), siegeEngine.getPreFireModelNumber(), siegeEngine.getWorldName()); SiegeEnginesUtil.UpdateEntityIdModel(siegeEngine.getEntity(), siegeEngine.getPreLoadModelNumber(), siegeEngine.getWorldName());
} }
} }
} }
} }
if (pulledHeldAmmoFromPlayer(player, siegeEngine)) { if (pulledHeldAmmoFromPlayer(player, siegeEngine)) {
player.sendMessage("§eAdded ammunition to this Siege Engine."); player.sendMessage("§eAdded ammunition to this Siege Engine.");
// If requires change in animation when loaded with a projectile (i.e. ballista)
if (siegeEngine.isSetModelNumberWhenFullyLoaded()) {
SiegeEnginesUtil.UpdateEntityIdModel(siegeEngine.getEntity(), siegeEngine.getPreFireModelNumber(), siegeEngine.getWorldName());
}
return; return;
} }
if (itemInHand == null || itemInHand.getType() == Material.AIR if (itemInHand == null || itemInHand.getType() == Material.AIR
@@ -20,12 +20,13 @@ import org.bukkit.util.Vector;
public class PotionProjectile extends SiegeEngineProjectile { public class PotionProjectile extends SiegeEngineProjectile {
public int EntityCount = 3; public int entityCount = 3;
public Boolean DelayedFire = false; public Boolean delayedFire = false;
public int DelayTime = 6; public int delayTime = 6;
public float Inaccuracy = 0.1f; public float inaccuracy = 0.1f;
public Particle ParticleType = Particle.EXPLOSION_LARGE; public Particle particleType = Particle.EXPLOSION_LARGE;
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE; public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
public float velocityFactor = 1.0f;
public PotionProjectile(ItemStack ammunitionItem) { public PotionProjectile(ItemStack ammunitionItem) {
super(ProjectileType.POTION, ammunitionItem); super(ProjectileType.POTION, ammunitionItem);
@@ -35,9 +36,9 @@ public class PotionProjectile extends SiegeEngineProjectile {
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) { public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
//TODO Auto-generated method stub //TODO Auto-generated method stub
int baseDelay = 0; int baseDelay = 0;
for (int i = 0; i < EntityCount; i++) { for (int i = 0; i < entityCount; i++) {
if (DelayedFire) { if (delayedFire) {
baseDelay += DelayTime; baseDelay += delayTime;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
CreateEntity(entity, loc, velocity); CreateEntity(entity, loc, velocity);
@@ -52,25 +53,27 @@ public class PotionProjectile extends SiegeEngineProjectile {
World world = entity.getLocation().getWorld(); World world = entity.getLocation().getWorld();
Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION); Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION);
if (Inaccuracy != 0f) { if (inaccuracy != 0f) {
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()).subtract(Randomise())); arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()).subtract(Randomise()));
} else { } else {
arrow.setVelocity(loc.getDirection().multiply(velocity)); arrow.setVelocity(loc.getDirection().multiply(velocity));
} }
arrow.setMetadata("isPotionProj", SiegeEnginesUtil.addMetaDataValue("true")); arrow.setMetadata("isPotionProj", SiegeEnginesUtil.addMetaDataValue("true"));
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow)); Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
ItemStack itemStack = new ItemStack(Material.SPLASH_POTION); ItemStack itemStack = this.getAmmuinitionItem();
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta(); PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 100, 3, true), true); System.out.println(potionMeta.toString());
System.out.println(itemStack.toString());
potionMeta.getBasePotionData();
itemStack.setItemMeta(potionMeta); itemStack.setItemMeta(potionMeta);
ThrownPotion potion = (ThrownPotion) arrow; ThrownPotion potion = (ThrownPotion) arrow;
potion.setItem(itemStack); potion.setItem(itemStack);
world.playSound(loc, this.SoundType, 20, 2); world.playSound(loc, this.soundType, 20, 2);
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0); world.spawnParticle(this.particleType, loc.getX(), loc.getY(), loc.getZ(), 0);
} }
private Vector Randomise() { 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)); 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));
} }
public ProjectileType getProjectileType() { public ProjectileType getProjectileType() {
+10 -2
View File
@@ -34,8 +34,7 @@ RotateDistance: 16
# The maximum siege engines a player can control at the same time # The maximum siege engines a player can control at the same time
MaxSiegeEnginesControlled: 1 MaxSiegeEnginesControlled: 1
# Whether or not the crafting recipes for siege engines will be enabled # Whether or not the crafting recipes for siege engines are enabled
# Requires a server restart to go into effect
CraftingRecipes: true CraftingRecipes: true
# The auto-reload feature by shift-clicking # The auto-reload feature by shift-clicking
@@ -114,6 +113,14 @@ Projectiles:
EntityCount: 1 EntityCount: 1
VelocityFactor: 0.5 VelocityFactor: 0.5
Delay: 5 Delay: 5
SplashPotionProjectile:
ProjectileType: POTION
Inaccuracy: 0.0125
EntityCount: 1
VelocityFactor: 0.5
ArrowDamageFactor: 1.0
AmmoItem: SPLASH_POTION
FireSound: ITEM_CROSSBOW_SHOOT
SiegeEngines: SiegeEngines:
Trebuchet: Trebuchet:
@@ -142,6 +149,7 @@ SiegeEngines:
- ScatterShot - ScatterShot
- DragonsBreath - DragonsBreath
- FireworkShot - FireworkShot
- SplashPotionProjectile
ItemName: "&e&lBallista" ItemName: "&e&lBallista"
Lore: Lore:
- "&ePlace as a block to spawn a Ballista" - "&ePlace as a block to spawn a Ballista"