<commit_before>package com.devotedmc.ExilePearl.listener;

import com.devotedmc.ExilePearl.ExilePearl;
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.event.PlayerPearledEvent;
import com.programmerdan.minecraft.banstick.data.BSPlayer;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;

public class BanStickListener extends RuleListener {

    public BanStickListener(ExilePearlApi pearlApi) {
        super(pearlApi);
    }

    /**
     * Prevents alts from logging in if the limit of pearled accounts is reached
     *
     * @param e
     */
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onLoginEvent(AsyncPlayerPreLoginEvent e) {
        if (pearlApi.getPearl(e.getUniqueId()) != null) {
            // dont lock out pearled account
            return;
        }
        if (getPearledAlts(e.getUniqueId()) >= config.maxAltsPearled()) {
            e.setLoginResult(Result.KICK_OTHER);
            e.setKickMessage(config.altBanMessage());
        }
    }

    /**
     * Kicks online alts if the limit of pearled accounts is reached
     *
     * @param e
     */
    public void playerPearl(PlayerPearledEvent e) {
        UUID uuid = e.getPearl().getPlayerId();
        if (getPearledAlts(uuid) < config.maxAltsPearled()) {
            return;
        }
        BSPlayer player = BSPlayer.byUUID(uuid);
        for (BSPlayer alt : player.getTransitiveSharedPlayers(true)) {
            ExilePearl altPearl = pearlApi.getPearl(alt.getUUID());
            if (altPearl == null && !alt.getUUID().equals(uuid)) {
                Player p = Bukkit.getPlayer(alt.getUUID());
                if (p != null) {
                    p.kickPlayer(config.altBanMessage());
                }
            }
        }
    }<commit_msg>Update BanStickListener.java<commit_after>package com.devotedmc.ExilePearl.listener;

import com.devotedmc.ExilePearl.ExilePearl;
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.event.PlayerPearledEvent;
import com.programmerdan.minecraft.banstick.data.BSPlayer;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;

public class BanStickListener extends RuleListener {

    public BanStickListener(ExilePearlApi pearlApi) {
        super(pearlApi);
    }

    /**
     * Prevents alts from logging in if the limit of pearled accounts is reached
     *
     * @param e
     */
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onLoginEvent(AsyncPlayerPreLoginEvent e) {
        if (pearlApi.getPearl(e.getUniqueId()) != null) {
            // dont lock out pearled account
            return;
        }
        if (getPearledAlts(e.getUniqueId()) >= config.maxAltsPearled()) {
            e.setLoginResult(Result.KICK_OTHER);
            e.setKickMessage(config.altBanMessage());
        }
    }

    /**
     * Kicks online alts if the limit of pearled accounts is reached
     *
     * @param e
     */
	@EventHandler
    public void playerPearl(PlayerPearledEvent e) {
        UUID uuid = e.getPearl().getPlayerId();
        if (getPearledAlts(uuid) < config.maxAltsPearled()) {
            return;
        }
        BSPlayer player = BSPlayer.byUUID(uuid);
        for (BSPlayer alt : player.getTransitiveSharedPlayers(true)) {
            ExilePearl altPearl = pearlApi.getPearl(alt.getUUID());
            if (altPearl == null && !alt.getUUID().equals(uuid)) {
                Player p = Bukkit.getPlayer(alt.getUUID());
                if (p != null) {
                    p.kickPlayer(config.altBanMessage());
                }
            }
        }
    }
{'fraction_non_alphanumeric': 0.10439024390243902, 'fraction_numerical': 0.0, 'mean_word_length': 2.6583407671721675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3873490', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1268, 'n_words': 232}