<commit_before>package info.tregmine.listeners;

import java.util.EnumSet;
import java.util.Set;

import info.tregmine.Tregmine;
import info.tregmine.api.TregminePlayer;
import info.tregmine.api.Zone;
import info.tregmine.quadtree.Point;
import info.tregmine.zones.ZoneWorld;
import info.tregmine.zones.ZonesPlugin;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

public class ZoneEntityListener implements Listener
{
	private static final Set<EntityType> allowedMobs = 
			EnumSet.of(EntityType.CHICKEN, EntityType.COW, 
					EntityType.PIG, EntityType.SHEEP, 
					EntityType.SQUID, EntityType.WOLF,
					EntityType.VILLAGER, EntityType.MUSHROOM_COW, EntityType.OCELOT);

	private final ZonesPlugin plugin;
	private final Tregmine tregmine;

	public ZoneEntityListener(ZonesPlugin instance) 
	{
		this.plugin = instance;
		this.tregmine = instance.tregmine;
	}

	@EventHandler
	public void onCreatureSpawn(CreatureSpawnEvent event) 
	{
		Entity entity = event.getEntity();

		Location location = event.getLocation();
		Point pos = new Point(location.getBlockX(), location.getBlockZ());

		ZoneWorld world = plugin.getWorld(entity.getWorld());
		Zone zone = world.findZone(pos);
		if (zone == null || zone.hasHostiles()) {
			return;
		}

		if (!allowedMobs.contains(event.getEntityType())) {
			event.setCancelled(true);
		}
	}


	@EventHandler
	public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {	

		if(event.getEntity().getWorld().getName().matches("world_the_end")) {
			return;
		}

		//	public void onEntityDamage(EntityDamageEvent event)	{
		Entity entity = event.getEntity();
		if (!(entity instanceof Player)) {
			return;
		}

		ZoneWorld world = plugin.getWorld(entity.getWorld());

		TregminePlayer player = tregmine.getPlayer((Player)event.getEntity());

		Location location = player.getLocation();
		Point pos = new Point(location.getBlockX(), location.getBlockZ());

		Zone currentZone = player.getCurrentZone();
		if (currentZone == null || !currentZone.contains(pos)) {
			currentZone = world.findZone(pos);
			player.setCurrentZone(currentZone);
		}

		if (currentZone == null || !currentZone.isPvp()) {

			if (event.getEntity() instanceof Player && event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent)event).getDamager() instanceof Player) {
				//				offender.sendMessage(ChatColor.RED + "This is not a PVP zone!");
				event.setCancelled(true);
			}
		}

		if(event.getCause() == DamageCause.ENTITY_ATTACK) {

			EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause();
			EntityDamageByEntityEvent eEvent = (EntityDamageByEntityEvent) damageEvent; 

			if(eEvent.getDamager() instanceof Player) {
				Player offender = (Player) eEvent.getDamager();
				offender.sendMessage(ChatColor.YELLOW + "This is a not a pvp zone!");
				event.setCancelled(true);
			}

		}
		return;
	}
}
<commit_msg>pvp again<commit_after>package info.tregmine.listeners;

import java.util.EnumSet;
import java.util.Set;

import info.tregmine.Tregmine;
import info.tregmine.api.TregminePlayer;
import info.tregmine.api.Zone;
import info.tregmine.quadtree.Point;
import info.tregmine.zones.ZoneWorld;
import info.tregmine.zones.ZonesPlugin;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

public class ZoneEntityListener implements Listener
{
	private static final Set<EntityType> allowedMobs = 
			EnumSet.of(EntityType.CHICKEN, EntityType.COW, 
					EntityType.PIG, EntityType.SHEEP, 
					EntityType.SQUID, EntityType.WOLF,
					EntityType.VILLAGER, EntityType.MUSHROOM_COW, EntityType.OCELOT);

	private final ZonesPlugin plugin;
	private final Tregmine tregmine;

	public ZoneEntityListener(ZonesPlugin instance) 
	{
		this.plugin = instance;
		this.tregmine = instance.tregmine;
	}

	@EventHandler
	public void onCreatureSpawn(CreatureSpawnEvent event) 
	{
		Entity entity = event.getEntity();

		Location location = event.getLocation();
		Point pos = new Point(location.getBlockX(), location.getBlockZ());

		ZoneWorld world = plugin.getWorld(entity.getWorld());
		Zone zone = world.findZone(pos);
		if (zone == null || zone.hasHostiles()) {
			return;
		}

		if (!allowedMobs.contains(event.getEntityType())) {
			event.setCancelled(true);
		}
	}


	@EventHandler
	public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {	

		if(event.getEntity().getWorld().getName().matches("world_the_end")) {
			return;
		}

		//	public void onEntityDamage(EntityDamageEvent event)	{
		Entity entity = event.getEntity();
		if (!(entity instanceof Player)) {
			return;
		}

		ZoneWorld world = plugin.getWorld(entity.getWorld());

		TregminePlayer player = tregmine.getPlayer((Player)event.getEntity());

		Location location = player.getLocation();
		Point pos = new Point(location.getBlockX(), location.getBlockZ());

		Zone currentZone = player.getCurrentZone();
		if (currentZone == null || !currentZone.contains(pos)) {
			currentZone = world.findZone(pos);
			player.setCurrentZone(currentZone);
		}


			if (event.getEntity() instanceof Player && event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent)event).getDamager() instanceof Player) {
				if (currentZone == null || !currentZone.isPvp()) {
					event.setCancelled(true);
				} else {
					event.setCancelled(false);
				}
				
		}
		return;
	}
}

{'fraction_non_alphanumeric': 0.11705577172503243, 'fraction_numerical': 0.0, 'mean_word_length': 4.937439846005775, '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': '3868764', 'n_tokens_mistral': 2207, 'n_tokens_neox': 1993, 'n_words': 365}