package com.yaohun.storyline.quest;

import com.yaohun.storyline.Storyline;
import com.yaohun.storyline.core.Quest;
import com.yaohun.storyline.data.PlayerData;
import com.yaohun.storyline.manage.PlayerManager;
import com.yaohun.storyline.manage.QuestManager;
import com.yaohun.storyline.util.QuestType;
import me.Demon.DemonHunHuanSX.Event.HhXiruEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.util.ArrayList;
import java.util.List;

public class HunHuanSXListener implements Listener {

    @EventHandler
    public void onHunHuan(HhXiruEvent e){
        Player player = e.getPlayer();
        String playerName = player.getName();

        PlayerManager playerManager = Storyline.getPlayerManager();
        PlayerData playerData = playerManager.getPlayerData(playerName);

        if(playerData == null) return;

        // 玩家若已完成所有任务则直接返回
        if(playerData.isAllCompleted()){
            return;
        }

        // 获取玩家当前任务
        Quest quest = QuestManager.getQuest(playerData.getCurrentQuest());
        if(quest == null){return;}
        if(quest.getQuestType() == QuestType.HUNHUAN_ENROL){
            playerData.forcCompleteQuest(quest);
        }
    }
}
