<commit_before>package de.iani.cubequest.quests;

import de.iani.cubequest.CubeQuest;
import de.iani.cubequest.PlayerData;
import de.iani.cubequest.QuestManager;
import de.iani.cubequest.Reward;
import de.iani.cubequest.questStates.QuestState;
import de.iani.cubequest.questStates.QuestState.Status;
import de.iani.cubequest.util.ChatAndTextUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimerTask;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.entity.Player;

@DelegateDeserialization(Quest.class)
public class WaitForDateQuest extends Quest {
    
    private long dateInMs;
    private boolean done = false;
    private TimerTask task = null;
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, String failMessage, Reward successReward, Reward failReward,
            long dateInMs) {
        super(id, name, displayMessage, giveMessage, successMessage, failMessage, successReward,
                failReward);
        this.dateInMs = dateInMs;
    }
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, Reward successReward, long dateInMs) {
        this(id, name, displayMessage, giveMessage, successMessage, null, successReward, null,
                dateInMs);
    }
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, String failMessage, Reward successReward, Reward failReward,
            Date date) {
        this(id, name, displayMessage, giveMessage, successMessage, failMessage, successReward,
                failReward, date.getTime());
    }
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, Reward successReward, Date date) {
        this(id, name, displayMessage, giveMessage, successMessage, null, successReward, null,
                date.getTime());
    }
    
    public WaitForDateQuest(int id) {
        this(id, null, null, null, null, null, 0);
    }
    
    @Override
    public void deserialize(YamlConfiguration yc) throws InvalidConfigurationException {
        super.deserialize(yc);
        
        this.dateInMs = yc.getLong("dateInMs");
        
        checkTime();
    }
    
    @Override
    protected String serializeToString(YamlConfiguration yc) {
        yc.set("dateInMs", this.dateInMs);
        
        return super.serializeToString(yc);
    }
    
    @Override
    public void giveToPlayer(Player player) {
        super.giveToPlayer(player);
        
        if (System.currentTimeMillis() >= this.dateInMs) {
            onSuccess(player);
        }
    }
    
    @Override
    public boolean isLegal() {
        return this.dateInMs > 0;
    }
    
    @Override
    public void setReady(boolean val) {
        boolean before = isReady();
        super.setReady(val);
        
        if (before != isReady()) {
            checkTime();
        }
    }
    
    @Override
    public List<BaseComponent[]> getQuestInfo() {
        List<BaseComponent[]> result = super.getQuestInfo();
        
        result.add(new ComponentBuilder(
                ChatColor.DARK_AQUA + "Datum: " + ChatAndTextUtil.formatDate(this.dateInMs))
                        .create());<commit_msg>Illegal date for WaitForDateQuest now red in quest info.<commit_after>package de.iani.cubequest.quests;

import de.iani.cubequest.CubeQuest;
import de.iani.cubequest.PlayerData;
import de.iani.cubequest.QuestManager;
import de.iani.cubequest.Reward;
import de.iani.cubequest.questStates.QuestState;
import de.iani.cubequest.questStates.QuestState.Status;
import de.iani.cubequest.util.ChatAndTextUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimerTask;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.entity.Player;

@DelegateDeserialization(Quest.class)
public class WaitForDateQuest extends Quest {
    
    private long dateInMs;
    private boolean done = false;
    private TimerTask task = null;
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, String failMessage, Reward successReward, Reward failReward,
            long dateInMs) {
        super(id, name, displayMessage, giveMessage, successMessage, failMessage, successReward,
                failReward);
        this.dateInMs = dateInMs;
    }
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, Reward successReward, long dateInMs) {
        this(id, name, displayMessage, giveMessage, successMessage, null, successReward, null,
                dateInMs);
    }
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, String failMessage, Reward successReward, Reward failReward,
            Date date) {
        this(id, name, displayMessage, giveMessage, successMessage, failMessage, successReward,
                failReward, date.getTime());
    }
    
    public WaitForDateQuest(int id, String name, String displayMessage, String giveMessage,
            String successMessage, Reward successReward, Date date) {
        this(id, name, displayMessage, giveMessage, successMessage, null, successReward, null,
                date.getTime());
    }
    
    public WaitForDateQuest(int id) {
        this(id, null, null, null, null, null, 0);
    }
    
    @Override
    public void deserialize(YamlConfiguration yc) throws InvalidConfigurationException {
        super.deserialize(yc);
        
        this.dateInMs = yc.getLong("dateInMs");
        
        checkTime();
    }
    
    @Override
    protected String serializeToString(YamlConfiguration yc) {
        yc.set("dateInMs", this.dateInMs);
        
        return super.serializeToString(yc);
    }
    
    @Override
    public void giveToPlayer(Player player) {
        super.giveToPlayer(player);
        
        if (System.currentTimeMillis() >= this.dateInMs) {
            onSuccess(player);
        }
    }
    
    @Override
    public boolean isLegal() {
        return this.dateInMs > 0;
    }
    
    @Override
    public void setReady(boolean val) {
        boolean before = isReady();
        super.setReady(val);
        
        if (before != isReady()) {
            checkTime();
        }
    }
    
    @Override
    public List<BaseComponent[]> getQuestInfo() {
        List<BaseComponent[]> result = super.getQuestInfo();
        
        result.add(new ComponentBuilder(ChatColor.DARK_AQUA + "Datum: "
                + (this.dateInMs > 0 ? ChatColor.GREEN : ChatColor.RED)
                + ChatAndTextUtil.formatDate(this.dateInMs)).create());
{'fraction_non_alphanumeric': 0.0902455209024552, 'fraction_numerical': 0.00145985401459854, 'mean_word_length': 2.890552400619515, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '3434128', 'n_tokens_mistral': 2182, 'n_tokens_neox': 2150, 'n_words': 479}