package com.yaohun.demonskills.component.dragoncore;

import com.yaohun.demonskills.SkillsMain;
import com.yaohun.demonskills.api.SkillComponent;
import eos.moe.dragoncore.api.CoreAPI;
import eos.moe.dragoncore.network.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.UUID;

public class PlayerAnimationComponent implements SkillComponent {

    private String animationKey;
    private long stopTick = -1;

    public PlayerAnimationComponent(String animationKey) {
        this.animationKey = animationKey;
    }

    public PlayerAnimationComponent(String animationKey, long stopTick) {
        this.animationKey = animationKey;
        this.stopTick = stopTick;
    }

    @Override
    public void execute(Player caster) {
        PacketSender.setPlayerAnimation(caster, animationKey);
        if(stopTick >= 5) {
            Bukkit.getScheduler().runTaskLater(SkillsMain.inst(), () -> {
                PacketSender.removePlayerAnimation(caster);
            }, stopTick);
        }
    }

}
