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

import java.util.UUID;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Listener;

import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.ExileRule;
import com.devotedmc.ExilePearl.Lang;
import com.devotedmc.ExilePearl.config.PearlConfig;

import vg.civcraft.mc.civmodcore.util.Guard;

import static vg.civcraft.mc.civmodcore.util.TextUtil.msg;

public class RuleListener implements Listener {
	
	protected final ExilePearlApi pearlApi;
	protected final PearlConfig config;
	  
	/**
	 * Creates a new ExileListener instance
	 * @param pearlApi The PearlApi instance
	 */
	public RuleListener(final ExilePearlApi pearlApi) {
		Guard.ArgumentNotNull(pearlApi, "pearlApi");
		
		this.pearlApi = pearlApi;
		this.config = pearlApi.getPearlConfig();
	}
	
	/**
	 * Gets whether a rule is active for the given player
	 * @param rule The exile rule
	 * @param playerId The player to check
	 * @return true if the rule is active for the player
	 */
	protected boolean isRuleActive(ExileRule rule, UUID playerId) {
		return pearlApi.isPlayerExiled(playerId) && !config.canPerform(rule);
	}
	
	
	/**
	 * Checks if a rule is active for a given player and cancels it<commit_msg>exile rules only affect exiled players<commit_after>package com.devotedmc.ExilePearl.listener;

import java.util.UUID;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Listener;

import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.ExileRule;
import com.devotedmc.ExilePearl.Lang;
import com.devotedmc.ExilePearl.PearlType;
import com.devotedmc.ExilePearl.config.PearlConfig;

import vg.civcraft.mc.civmodcore.util.Guard;

import static vg.civcraft.mc.civmodcore.util.TextUtil.msg;

public class RuleListener implements Listener {
	
	protected final ExilePearlApi pearlApi;
	protected final PearlConfig config;
	  
	/**
	 * Creates a new ExileListener instance
	 * @param pearlApi The PearlApi instance
	 */
	public RuleListener(final ExilePearlApi pearlApi) {
		Guard.ArgumentNotNull(pearlApi, "pearlApi");
		
		this.pearlApi = pearlApi;
		this.config = pearlApi.getPearlConfig();
	}
	
	/**
	 * Gets whether a rule is active for the given player
	 * @param rule The exile rule
	 * @param playerId The player to check
	 * @return true if the rule is active for the player
	 */
	protected boolean isRuleActive(ExileRule rule, UUID playerId) {
		return pearlApi.isPlayerExiled(playerId) && !config.canPerform(rule) && pearlApi.getPearl(playerId).getPearlType() == PearlType.EXILE;
	}
	
	
	/**
	 * Checks if a rule is active for a given player and cancels it
{'fraction_non_alphanumeric': 0.08930540242557883, 'fraction_numerical': 0.0, 'mean_word_length': 4.62396694214876, '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': '7589823', 'n_tokens_mistral': 973, 'n_tokens_neox': 892, 'n_words': 226}