package de.steamwar.lobby.particle;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;

@RequiredArgsConstructor
@AllArgsConstructor
@Getter
public class ParticleTickData {

    private final World world;
    private final Player player;
    private Location location;
    private final double deg;
    private final boolean isMoving;
    private boolean onlySelf = false;
    private boolean onlyOthers = false;

    public ParticleTickData withLocation(Location location) {
        ParticleTickData particleTickData = copy();
        particleTickData.location = location;
        return particleTickData;
    }

    public ParticleTickData onlySelf() {
        ParticleTickData particleTickData = copy();
        particleTickData.onlySelf = true;
        return particleTickData;
    }

    public ParticleTickData onlyOthers() {
        ParticleTickData particleTickData = copy();
        particleTickData.onlyOthers = true;
        return particleTickData;
    }

    public Location getLocation() {
        if (location == null) {
            return player.getLocation();
        }
        return location;
    }

    public ParticleTickData copy() {
        return new ParticleTickData(world, player, location, deg, isMoving, onlySelf, onlyOthers);
    }
}
