public ProjectileSpell(MagicConfig config, String spellName) { super(config, spellName); String projectileType = getConfigString("projectile", "arrow"); if (projectileType.equalsIgnoreCase("arrow")) { projectileClass = Arrow.class; } else if (projectileType.equalsIgnoreCase("snowball")) { projectileClass = Snowball.class; } else if (projectileType.equalsIgnoreCase("egg")) { projectileClass = Egg.class; } else if (projectileType.equalsIgnoreCase("enderpearl")) { projectileClass = EnderPearl.class; } else if (projectileType.equalsIgnoreCase("potion")) { projectileClass = ThrownPotion.class; } else { ItemStack item = Util.getItemStackFromString(projectileType); if (item != null) { item.setAmount(0); projectileItem = item; } } if (projectileClass == null && projectileItem == null) { MagicSpells.error("Invalid projectile type on spell '" + internalName + "'"); } velocity = getConfigFloat("velocity", 0); horizSpread = getConfigFloat("horizontal-spread", 0); vertSpread = getConfigFloat("vertical-spread", 0); applySpellPowerToVelocity = getConfigBoolean("apply-spell-power-to-velocity", false); requireHitEntity = getConfigBoolean("require-hit-entity", false); cancelDamage = getConfigBoolean("cancel-damage", true); removeProjectile = getConfigBoolean("remove-projectile", true); maxDistanceSquared = getConfigInt("max-distance", 0); maxDistanceSquared = maxDistanceSquared * maxDistanceSquared; effectInterval = getConfigInt("effect-interval", 0); spellNames = getConfigStringList("spells", null); aoeRadius = getConfigInt("aoe-radius", 0); targetPlayers = getConfigBoolean("target-players", false); allowTargetChange = getConfigBoolean("allow-target-change", true); projectileHasGravity = getConfigBoolean("gravity", true); strHitCaster = getConfigString("str-hit-caster", ""); strHitTarget = getConfigString("str-hit-target", ""); if (projectileClass != null) { projectiles = new HashMap<Projectile, ProjectileInfo>(); } else if (projectileItem != null) { itemProjectiles = new HashMap<Item, ProjectileSpell.ProjectileInfo>(); } }
public ItemProjectileSpell(MagicConfig config, String spellName) { super(config, spellName); speed = getConfigFloat("speed", 1); vertSpeedUsed = configKeyExists("vert-speed"); vertSpeed = getConfigFloat("vert-speed", 0); hitRadius = getConfigFloat("hit-radius", 1); yOffset = getConfigFloat("y-offset", 0); projectileHasGravity = getConfigBoolean("gravity", true); if (configKeyExists("spell-on-hit-entity")) { spellOnHitEntity = new Subspell(getConfigString("spell-on-hit-entity", "")); } if (configKeyExists("spell-on-hit-ground")) { spellOnHitGround = new Subspell(getConfigString("spell-on-hit-ground", "")); } item = Util.getItemStackFromString(getConfigString("item", "iron_sword")); }