<commit_before>package info.tregmine.commands;

import info.tregmine.Tregmine; import info.tregmine.api.GenericPlayer;
import info.tregmine.database.DAOException;
import info.tregmine.database.IContext;
import info.tregmine.database.IPlayerDAO;
import org.bukkit.ChatColor;

import java.util.List;

public class IgnoreCommand extends AbstractCommand {
    public IgnoreCommand(Tregmine tregmine) {
        super(tregmine, "ignore");
    }

    @Override
    public boolean handlePlayer(GenericPlayer player, String args[]) {
        List<String> ignoredPeople;
        try (IContext ctx = tregmine.createContext()) {
            IPlayerDAO playerDAO = ctx.getPlayerDAO();
            ignoredPeople = playerDAO.getIgnored(player);
        } catch (DAOException e) {
            throw new RuntimeException(e);
        }

        if (args.length == 0 || args.length > 2) {

            player.sendMessage(ChatColor.DARK_RED + "Incorrect Syntax:");
            player.sendMessage(
                    ChatColor.AQUA + "/ignore <add/remove> player_name (To add/remove someone to ignore)");
            player.sendMessage(ChatColor.AQUA + "/ignore list (To view everyone your ignoring)");

            return true;
        } else if (args.length == 1 && args[0].equalsIgnoreCase("list")) {

            if (ignoredPeople.size() > 0) {
                player.sendMessage(
                        ChatColor.AQUA + ignoredPeople.toString().replace(",", " ").replace("[", "").replace("]", ""));
            } else {
                player.sendMessage("You are currently not ignoring anyone!");
            }

            return true;
        } else if (args.length == 2 && args[0].equalsIgnoreCase("list")) {

            if (!player.getRank().canViewIgnored())
                return false;

            GenericPlayer target = tregmine.getPlayerOffline(args[1]);

            if (target == null) {
                player.sendMessage(ChatColor.RED + "Could not find player: " + ChatColor.YELLOW + args[1]);
                return true;
            }

            List<String> ignoredPeopleAdmin;
            try (IContext ctx = tregmine.createContext()) {
                IPlayerDAO playerDAO = ctx.getPlayerDAO();
                ignoredPeopleAdmin = playerDAO.getIgnored(target);
            } catch (DAOException e) {
                throw new RuntimeException(e);
            }

            if (ignoredPeopleAdmin.size() > 0) {
                player.sendMessage(ChatColor.AQUA
                        + ignoredPeopleAdmin.toString().replace(",", " ").replace("[", "").replace("]", ""));
            } else {
                player.sendMessage(target.getDisplayName() + " is not ignoring anyone!");
            }

            return true;
        } else if (args.length == 2 && args[0].equalsIgnoreCase("add")) {

            GenericPlayer target = tregmine.getPlayerOffline(args[1]);

            if (target == null) {
                player.sendMessage(ChatColor.RED + "Could not find player: " + ChatColor.YELLOW + args[1]);
                return true;
            }

            if (target.getRank().canNotBeIgnored()) {
                player.sendMessage(ChatColor.RED + "Can not ignore this player!");
                return true;
            }
            if (target.getDelegate() == null) {
                ignoredPeople.add(args[1]);
            } else {
                ignoredPeople.add(target.getChatNameNoHover());
            }

            try (IContext ctx = tregmine.createContext()) {
                IPlayerDAO playerDAO = ctx.getPlayerDAO();
                playerDAO.updateIgnore(player, ignoredPeople);
                player.sendMessage(ChatColor.AQUA + "Now ignoring the player: " + target.getChatNameNoHover());
            } catch (DAOException e) {
                throw new RuntimeException(e);
            }

            return true;
        } else if (args.length == 2 && args[0].equalsIgnoreCase("remove")) {

            if (ignoredPeople.contains(args[1])) {
                ignoredPeople.remove(args[1]);
            } else {
                player.sendMessage(ChatColor.DARK_RED + "You are not ignoring: " + args[1] + "!");<commit_msg>Disable ignoring self<commit_after>package info.tregmine.commands;

import info.tregmine.Tregmine; import info.tregmine.api.GenericPlayer;
import info.tregmine.database.DAOException;
import info.tregmine.database.IContext;
import info.tregmine.database.IPlayerDAO;
import org.bukkit.ChatColor;

import java.util.List;

public class IgnoreCommand extends AbstractCommand {
    public IgnoreCommand(Tregmine tregmine) {
        super(tregmine, "ignore");
    }

    @Override
    public boolean handlePlayer(GenericPlayer player, String args[]) {
        List<String> ignoredPeople;
        try (IContext ctx = tregmine.createContext()) {
            IPlayerDAO playerDAO = ctx.getPlayerDAO();
            ignoredPeople = playerDAO.getIgnored(player);
        } catch (DAOException e) {
            throw new RuntimeException(e);
        }

        if (args.length == 0 || args.length > 2) {

            player.sendMessage(ChatColor.DARK_RED + "Incorrect Syntax:");
            player.sendMessage(
                    ChatColor.AQUA + "/ignore <add/remove> player_name (To add/remove someone to ignore)");
            player.sendMessage(ChatColor.AQUA + "/ignore list (To view everyone your ignoring)");

            return true;
        } else if (args.length == 1 && args[0].equalsIgnoreCase("list")) {

            if (ignoredPeople.size() > 0) {
                player.sendMessage(
                        ChatColor.AQUA + ignoredPeople.toString().replace(",", " ").replace("[", "").replace("]", ""));
            } else {
                player.sendMessage("You are currently not ignoring anyone!");
            }

            return true;
        } else if (args.length == 2 && args[0].equalsIgnoreCase("list")) {

            if (!player.getRank().canViewIgnored())
                return false;

            GenericPlayer target = tregmine.getPlayerOffline(args[1]);

            if (target == null) {
                player.sendMessage(ChatColor.RED + "Could not find player: " + ChatColor.YELLOW + args[1]);
                return true;
            }

            List<String> ignoredPeopleAdmin;
            try (IContext ctx = tregmine.createContext()) {
                IPlayerDAO playerDAO = ctx.getPlayerDAO();
                ignoredPeopleAdmin = playerDAO.getIgnored(target);
            } catch (DAOException e) {
                throw new RuntimeException(e);
            }

            if (ignoredPeopleAdmin.size() > 0) {
                player.sendMessage(ChatColor.AQUA
                        + ignoredPeopleAdmin.toString().replace(",", " ").replace("[", "").replace("]", ""));
            } else {
                player.sendMessage(target.getDisplayName() + " is not ignoring anyone!");
            }

            return true;
        } else if (args.length == 2 && args[0].equalsIgnoreCase("add")) {

            GenericPlayer target = tregmine.getPlayerOffline(args[1]);

            if (target == null) {
                player.sendMessage(ChatColor.RED + "Could not find player: " + ChatColor.YELLOW + args[1]);
                return true;
            }

            if (target.getRank().canNotBeIgnored() || target.getId() == player.getId()) {
                player.sendMessage(ChatColor.RED + "Can not ignore this player!");
                return true;
            }
            if (target.getDelegate() == null) {
                ignoredPeople.add(args[1]);
            } else {
                ignoredPeople.add(target.getChatNameNoHover());
            }

            try (IContext ctx = tregmine.createContext()) {
                IPlayerDAO playerDAO = ctx.getPlayerDAO();
                playerDAO.updateIgnore(player, ignoredPeople);
                player.sendMessage(ChatColor.AQUA + "Now ignoring the player: " + target.getChatNameNoHover());
            } catch (DAOException e) {
                throw new RuntimeException(e);
            }

            return true;
        } else if (args.length == 2 && args[0].equalsIgnoreCase("remove")) {

            if (ignoredPeople.contains(args[1])) {
                ignoredPeople.remove(args[1]);
            } else {
                player.sendMessage(ChatColor.DARK_RED + "You are not ignoring: " + args[1] + "!");
{'fraction_non_alphanumeric': 0.12252209219011226, 'fraction_numerical': 0.004776689754000477, 'mean_word_length': 1.9793667733902527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '5321793', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2220, 'n_words': 464}