<commit_before>package info.tregmine.listeners;

import info.tregmine.Tregmine;
import info.tregmine.api.PlayerReport;
import info.tregmine.api.PlayerReport.Action;
import info.tregmine.api.TregminePlayer;
import info.tregmine.database.DAOException;
import info.tregmine.database.IContext;
import info.tregmine.database.ILogDAO;
import info.tregmine.database.IPlayerReportDAO;
import java.text.SimpleDateFormat;
import java.util.List;

import java.util.Set;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class PlayerLookupListener implements Listener
{
    private Tregmine plugin;

    public PlayerLookupListener(Tregmine instance)
    {
        plugin = instance;
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event)
    {
        TregminePlayer player = plugin.getPlayer(event.getPlayer());
        if (player == null) {
            event.getPlayer().kickPlayer("Something went wrong");
            Tregmine.LOGGER.info(event.getPlayer().getName() + " was not found " +
                    "in players map.");
            return;
        }
        
        try (IContext ctx = plugin.createContext()) {
            IPlayerReportDAO report = ctx.getPlayerReportDAO();
            List<PlayerReport> list = report.getReportsBySubject(player);
            if (list.size() > 0) {
                player.sendMessage(ChatColor.RED + 
                            "You have been reported:");
                for(PlayerReport i : list){
                    if (i.getAction() == Action.COMMENT){
                        continue;
                    }
                    
                    SimpleDateFormat dfm = new SimpleDateFormat("dd/MM/yy hh:mm:ss a");
                    player.sendMessage(ChatColor.RED +
                            "[" + i.getAction() + "]" +
                            i.getMessage() + " - Valid until: " +
                            dfm.format(i.getTimestamp()));
                }
            }
        } catch (DAOException e) {
            throw new RuntimeException(e);
        }
        if (player.hasFlag(TregminePlayer.Flags.INVISIBLE)) {

            for (TregminePlayer to : plugin.getOnlinePlayers()) {<commit_msg>Limiting warn on login to only latest warning<commit_after>package info.tregmine.listeners;

import java.util.Set;
import java.util.Date;

import info.tregmine.Tregmine;
import info.tregmine.api.PlayerReport;
import info.tregmine.api.PlayerReport.Action;
import info.tregmine.api.TregminePlayer;
import info.tregmine.database.DAOException;
import info.tregmine.database.IContext;
import info.tregmine.database.ILogDAO;
import info.tregmine.database.IPlayerReportDAO;
import java.text.SimpleDateFormat;
import java.util.List;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class PlayerLookupListener implements Listener
{
    private Tregmine plugin;

    public PlayerLookupListener(Tregmine instance)
    {
        plugin = instance;
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event)
    {
        TregminePlayer player = plugin.getPlayer(event.getPlayer());
        if (player == null) {
            event.getPlayer().kickPlayer("Something went wrong");
            Tregmine.LOGGER.info(event.getPlayer().getName() + " was not found " +
                    "in players map.");
            return;
        }

        try (IContext ctx = plugin.createContext()) {
            IPlayerReportDAO report = ctx.getPlayerReportDAO();
            List<PlayerReport> list = report.getReportsBySubject(player);
            if (list.size() > 0) {
                player.sendMessage(ChatColor.RED +
                            "You have been reported:");
                for (PlayerReport i : list) {
                    if (i.getAction() != Action.HARDWARN &&
                        i.getAction() != Action.SOFTWARN) {
                        continue;
                    }
                    Date validUntil = i.getValidUntil();
                    if (validUntil == null) {
                        continue;
                    }
                    if (validUntil.getTime() < System.currentTimeMillis()) {
                        continue;
                    }

                    SimpleDateFormat dfm = new SimpleDateFormat("dd/MM/yy hh:mm:ss a");
                    player.sendMessage(ChatColor.RED +
                            "[" + i.getAction() + "]" +
                            i.getMessage() + " - Valid until: " +
                            dfm.format(i.getTimestamp()));
                    break;
                }
            }
        } catch (DAOException e) {
            throw new RuntimeException(e);
        }

        if (player.hasFlag(TregminePlayer.Flags.INVISIBLE)) {

            for (TregminePlayer to : plugin.getOnlinePlayers()) {
{'fraction_non_alphanumeric': 0.10152487961476725, 'fraction_numerical': 0.0004012841091492777, 'mean_word_length': 1.9067055393586005, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2137391', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1332, 'n_words': 256}