<commit_before>package net.craftminecraft.bungee.bungeeban.listener;

import com.google.common.eventbus.Subscribe;

import net.craftminecraft.bungee.bungeeban.BanManager;
import net.craftminecraft.bungee.bungeeban.banstore.BanEntry;
import net.craftminecraft.bungee.bungeeban.util.Utils;
import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.plugin.Listener;

public class ProxiedPlayerListener implements Listener {
	public ProxiedPlayerListener() {
	}
	
	@Subscribe
	public void onPlayerJoin(LoginEvent e) {
		BanEntry ban = BanManager.getBan(e.getConnection().getName(), "(GLOBAL)");
		if (ban != null) {
			e.setCancelled(true);
			e.setCancelReason(Utils.formatMessage(ban.getReason(), ban));
			return;
		}
		ban = BanManager.getBan(e.getConnection().getAddress().getAddress().getHostAddress(), "(GLOBAL)");
		if (ban != null) {
			e.setCancelled(true);
			e.setCancelReason(Utils.formatMessage(ban.getReason(), ban));
		}
	}
	
	@Subscribe
	public void onServerConnect(ServerConnectEvent e) {
		BanEntry ban = BanManager.getBan(e.getPlayer().getName(), e.getTarget().getName());
		if (ban != null) {
			e.getPlayer().disconnect(Utils.formatMessage(ban.getReason(), ban));
			return;
		} 
		ban = BanManager.getBan(e.getPlayer().getAddress().getAddress().getHostAddress(), e.getTarget().getName());
		if (ban != null) {<commit_msg>Use PostLoginEvent so offline-mode bungee servers can still global ban (although I really dislike supporting offline-mode, I need it for testing...)<commit_after>package net.craftminecraft.bungee.bungeeban.listener;

import com.google.common.eventbus.Subscribe;

import net.craftminecraft.bungee.bungeeban.BanManager;
import net.craftminecraft.bungee.bungeeban.banstore.BanEntry;
import net.craftminecraft.bungee.bungeeban.util.Utils;
import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.plugin.Listener;

public class ProxiedPlayerListener implements Listener {
	public ProxiedPlayerListener() {
	}
	
	@Subscribe
	public void onPlayerJoin(PostLoginEvent e) {
		BanEntry ban = BanManager.getBan(e.getPlayer().getName(), "(GLOBAL)");
		if (ban != null) {
			e.getPlayer().disconnect(Utils.formatMessage(ban.getReason(), ban));
			return;
		}
		ban = BanManager.getBan(e.getPlayer().getAddress().getAddress().getHostAddress(), "(GLOBAL)");
		if (ban != null) {
			e.getPlayer().disconnect(Utils.formatMessage(ban.getReason(), ban));
			return;
		}
	}
	
	@Subscribe
	public void onServerConnect(ServerConnectEvent e) {
		BanEntry ban = BanManager.getBan(e.getPlayer().getName(), e.getTarget().getName());
		if (ban != null) {
			e.getPlayer().disconnect(Utils.formatMessage(ban.getReason(), ban));
			return;
		} 
		ban = BanManager.getBan(e.getPlayer().getAddress().getAddress().getHostAddress(), e.getTarget().getName());
		if (ban != null) {
{'fraction_non_alphanumeric': 0.14651397777029304, 'fraction_numerical': 0.0023576961940047153, 'mean_word_length': 5.442516268980477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1377699', 'n_tokens_mistral': 1056, 'n_tokens_neox': 988, 'n_words': 159}