<commit_before>package info.faceland.strife.effects;

import info.faceland.strife.StrifePlugin;
import info.faceland.strife.attributes.StrifeAttribute;
import info.faceland.strife.data.AttributedEntity;
import info.faceland.strife.util.LogUtil;
import java.util.List;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.ShulkerBullet;
import org.bukkit.entity.SmallFireball;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;

public class ShootProjectile extends Effect {

  private EntityType projectileEntity;
  private boolean targeted;
  private boolean seeking;
  private int quantity;
  private double speed;
  private double spread;
  private double verticalBonus;
  private boolean bounce;
  private boolean ignite;
  private float yield;
  private List<String> hitEffects;

  @Override
  public void apply(AttributedEntity caster, AttributedEntity target) {
    double projectiles = quantity * (1 + caster.getAttribute(StrifeAttribute.MULTISHOT) / 100);
    if (projectileEntity == EntityType.FIREBALL) {
      projectiles = 1;
    }
    Vector castDirection;
    if (caster == target) {
      LogUtil.printWarning("Skipping self targeted projectile launched by " + getName());
      return;
    }
    if (targeted) {
      castDirection = target.getEntity().getLocation().toVector()
          .subtract(caster.getEntity().getEyeLocation().toVector()).normalize();
      LogUtil.printDebug("Fetched direction to target: " + castDirection.toString());
    } else {
      castDirection = caster.getEntity().getEyeLocation().getDirection();
      LogUtil.printDebug("Fetched direction caster is facing: " + castDirection.toString());
    }
    double adjustedSpread = (projectiles - 1) * spread;
    for (int i = 0; i < projectiles; i++) {
      Projectile projectile = (Projectile) caster.getEntity().getWorld()
          .spawnEntity(caster.getEntity().getEyeLocation(), projectileEntity);
      projectile.setShooter(caster.getEntity());
      Vector direction = castDirection.clone();
      direction.add(new Vector(
          adjustedSpread - 2 * adjustedSpread * Math.random(),
          adjustedSpread - 2 * adjustedSpread * Math.random() + verticalBonus,
          adjustedSpread - 2 * adjustedSpread * Math.random()));
      direction = direction.normalize();
      LogUtil.printDebug("Post spread and vert bonus direction: " + direction.toString());
      LogUtil.printDebug("Final projectile velocity: " + direction.clone().multiply(speed));
      projectile.setVelocity(direction.multiply(speed));
      if (projectileEntity == EntityType.FIREBALL) {
        ((Fireball) projectile).setYield(yield);
        ((Fireball) projectile).setIsIncendiary(ignite);
      } else if (projectileEntity == EntityType.SMALL_FIREBALL) {
        ((SmallFireball) projectile).setIsIncendiary(ignite);<commit_msg>Self targeted projectiles now just shoot like normal ones if target mode is false<commit_after>package info.faceland.strife.effects;

import info.faceland.strife.StrifePlugin;
import info.faceland.strife.attributes.StrifeAttribute;
import info.faceland.strife.data.AttributedEntity;
import info.faceland.strife.util.LogUtil;
import java.util.List;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.ShulkerBullet;
import org.bukkit.entity.SmallFireball;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;

public class ShootProjectile extends Effect {

  private EntityType projectileEntity;
  private boolean targeted;
  private boolean seeking;
  private int quantity;
  private double speed;
  private double spread;
  private double verticalBonus;
  private boolean bounce;
  private boolean ignite;
  private float yield;
  private List<String> hitEffects;

  @Override
  public void apply(AttributedEntity caster, AttributedEntity target) {
    double projectiles = 1;
    if (projectileEntity != EntityType.FIREBALL) {
      projectiles = quantity * (1 + caster.getAttribute(StrifeAttribute.MULTISHOT) / 100);
    }
    Vector castDirection;
    if (targeted) {
      if (caster == target) {
        LogUtil.printWarning("Skipping self targeted projectile launched by " + getName());
        return;
      }
      castDirection = target.getEntity().getLocation().toVector()
          .subtract(caster.getEntity().getEyeLocation().toVector()).normalize();
      LogUtil.printDebug("Fetched direction to target: " + castDirection.toString());
    } else {
      castDirection = caster.getEntity().getEyeLocation().getDirection();
      LogUtil.printDebug("Fetched direction caster is facing: " + castDirection.toString());
    }
    double adjustedSpread = (projectiles - 1) * spread;
    for (int i = 0; i < projectiles; i++) {
      Projectile projectile = (Projectile) caster.getEntity().getWorld()
          .spawnEntity(caster.getEntity().getEyeLocation(), projectileEntity);
      projectile.setShooter(caster.getEntity());
      Vector direction = castDirection.clone();
      direction.add(new Vector(
          adjustedSpread - 2 * adjustedSpread * Math.random(),
          adjustedSpread - 2 * adjustedSpread * Math.random() + verticalBonus,
          adjustedSpread - 2 * adjustedSpread * Math.random()));
      direction = direction.normalize();
      LogUtil.printDebug("Post spread and vert bonus direction: " + direction.toString());
      LogUtil.printDebug("Final projectile velocity: " + direction.clone().multiply(speed));
      projectile.setVelocity(direction.multiply(speed));
      if (projectileEntity == EntityType.FIREBALL) {
        ((Fireball) projectile).setYield(yield);
        ((Fireball) projectile).setIsIncendiary(ignite);
      } else if (projectileEntity == EntityType.SMALL_FIREBALL) {
        ((SmallFireball) projectile).setIsIncendiary(ignite);
{'fraction_non_alphanumeric': 0.1100607697501688, 'fraction_numerical': 0.00337609723160027, 'mean_word_length': 4.098967297762479, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6345313', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1656, 'n_words': 368}