<commit_before>package us.corenetwork.tradecraft;

import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;

/**
 * Created by Matej on 24.2.2014.
 */
public class TradeCraftListener implements Listener {

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onCreatureSpawn(CreatureSpawnEvent event)
    {
        //Replace spawned villager if new one spawns
        if (event.getEntityType() == EntityType.VILLAGER)
        {
            final Entity villager = event.getEntity();
            if (!NMSVillagerManager.isCustomVillager(villager))
            {
                Bukkit.getScheduler().runTask(TradeCraftPlugin.instance, new Runnable() {
                    @Override
                    public void run() {
                        NMSVillagerManager.convert(villager);
                    }
                });
            }
        }
    }
}<commit_msg>#26 Added removing villies from db on death<commit_after>package us.corenetwork.tradecraft;

import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDeathEvent;

import us.corenetwork.tradecraft.db.DbWorker;
import us.corenetwork.tradecraft.db.RemoveVillagerTask;

/**
 * Created by Matej on 24.2.2014.
 */
public class TradeCraftListener implements Listener {

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onCreatureSpawn(CreatureSpawnEvent event)
    {
        //Replace spawned villager if new one spawns
        if (event.getEntityType() == EntityType.VILLAGER)
        {
            final Entity villager = event.getEntity();
            if (!NMSVillagerManager.isCustomVillager(villager))
            {
                Bukkit.getScheduler().runTask(TradeCraftPlugin.instance, new Runnable() {
                    @Override
                    public void run() {
                        NMSVillagerManager.convert(villager);
                    }
                });
            }
        }
    }
    
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void EntityDeathEvent(EntityDeathEvent event)
    {
        if (event.getEntityType() == EntityType.VILLAGER)
        {
            final Entity villager = event.getEntity();
            DbWorker.queue.add(new RemoveVillagerTask(villager.getUniqueId().toString()));
        }
    }
}
{'fraction_non_alphanumeric': 0.09415584415584416, 'fraction_numerical': 0.005772005772005772, 'mean_word_length': 2.4968474148802016, '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': '975520', 'n_tokens_mistral': 847, 'n_tokens_neox': 786, 'n_words': 146}