<commit_before>package me.lilmac.cNoHacks.ForceField;

import me.lilmac.cNoHacks.Main;
import me.lilmac.cNoHacks.Config.ConfigManager;
import me.lilmac.cNoHacks.Utils.Utils;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class ForceField implements CommandExecutor, Listener {

	public Main plugin;

	public ForceField(Main instance) {
		plugin = instance;
	}

	@EventHandler
	public void onEntityDamage(EntityDamageEvent event) {
		if(event.getEntity() instanceof Villager) {
 			event.setCancelled(true);
		}
	}

	@EventHandler
	public void onVillagerDamage(EntityDamageByEntityEvent event) {
		if(event.getDamager() instanceof Player && event.getEntity() instanceof Villager) {
			Villager villager = (Villager) event.getEntity();
			Player damager = (Player) event.getDamager();
			if(villager.getCustomName().equals(damager.getName())) {
				for(Player online : Bukkit.getOnlinePlayers()) {
					if(online.hasPermission("cnohacks.view") || online.isOp()) {
						if (ConfigManager.contains("alerts.yml", online.getName())) {
							if (ConfigManager.get("alerts.yml").getBoolean(online.getName() + ".Alerts")) {
								online.sendMessage(Utils.getPrefix() + damager.getDisplayName() + " 7might be using cForcefield");
							}
						}
					}
				}
			}
		}
	}

	@EventHandler
	public void onVillagerInteract(PlayerInteractEntityEvent event) { 
		if(event.getRightClicked() instanceof Villager) {
			Villager villager = (Villager) event.getRightClicked();
			if(villager.getCustomName() != null) {
				event.setCancelled(true);
			}
		}
	}	

	@EventHandler
	public void onJoin(PlayerJoinEvent e) {
		if (!(ConfigManager.contains("alerts.yml", e.getPlayer().getName()))) {
			ConfigManager.set("alerts.yml", e.getPlayer().getName() + ".Alerts", false);
			ConfigManager.save(plugin, "alerts.yml");
		}
	}
	
	public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
		if (tag.equalsIgnoreCase("test")) {
				for (Player online : Bukkit.getOnlinePlayers()) {
					final Villager villager = (Villager) online.getLocation().getWorld().spawnEntity(online.getLocation().subtract(3,0,3), EntityType.VILLAGER);
					villager.setCustomName(online.getName());
					villager.setCustomNameVisible(true);
					villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
					Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
						public void run() {
							villager.remove();
						}
					}, 10);
				}
			}
		return false;
	}
}<commit_msg>Update ForceField.java<commit_after>package me.lilmac.cNoHacks.ForceField;

import me.lilmac.cNoHacks.Main;
import me.lilmac.cNoHacks.Config.ConfigManager;
import me.lilmac.cNoHacks.Utils.Utils;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class ForceField implements CommandExecutor, Listener {

	public Main plugin;

	public ForceField(Main instance) {
		plugin = instance;
	}

	@EventHandler
	public void onEntityDamage(EntityDamageEvent event) {
		if(event.getEntity() instanceof Villager && event.getEntity().hasMetaData("cancel")) {
 			event.setCancelled(true);
		}
	}

	@EventHandler
	public void onVillagerDamage(EntityDamageByEntityEvent event) {
		if(event.getDamager() instanceof Player && event.getEntity() instanceof Villager) {
			Villager villager = (Villager) event.getEntity();
			Player damager = (Player) event.getDamager();
			if(villager.getCustomName().equals(damager.getName())) {
				for(Player online : Bukkit.getOnlinePlayers()) {
					if(online.hasPermission("cnohacks.view") || online.isOp()) {
						if (ConfigManager.contains("alerts.yml", online.getName())) {
							if (ConfigManager.get("alerts.yml").getBoolean(online.getName() + ".Alerts")) {
								online.sendMessage(Utils.getPrefix() + damager.getDisplayName() + " §7might be using §cForcefield");
							}
						}
					}
				}
			}
		}
	}

	@EventHandler
	public void onVillagerInteract(PlayerInteractEntityEvent event) { 
		if(event.getRightClicked() instanceof Villager) {
			Villager villager = (Villager) event.getRightClicked();
			if(villager.getCustomName() != null) {
				event.setCancelled(true);
			}
		}
	}	

	@EventHandler
	public void onJoin(PlayerJoinEvent e) {
		if (!(ConfigManager.contains("alerts.yml", e.getPlayer().getName()))) {
			ConfigManager.set("alerts.yml", e.getPlayer().getName() + ".Alerts", false);
			ConfigManager.save(plugin, "alerts.yml");
		}
	}
	
	public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
		if (tag.equalsIgnoreCase("test")) {
				for (Player online : Bukkit.getOnlinePlayers()) {
					final Villager villager = (Villager) online.getLocation().getWorld().spawnEntity(online.getLocation().subtract(3,0,3), EntityType.VILLAGER);
					villager.setCustomName(online.getName());
					villager.setCustomNameVisible(true);
					villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
					villager.setMetadata("cancel", (MetadataValue)new FixedMetadataValue((Plugin)plugin, (Object)true));
					Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
						public void run() {
							vilager.removeMetaData("cancel");
							villager.remove();
						}
					}, 10);
				}
			}
		return false;
	}
}
{'fraction_non_alphanumeric': 0.131129562901457, 'fraction_numerical': 0.0021933260222465924, 'mean_word_length': 4.793103448275862, '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': '2396228', 'n_tokens_mistral': 2398, 'n_tokens_neox': 2037, 'n_words': 337}