<commit_before>package io.github.thatsmusic99.headsplus.listeners;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.api.events.PlayerHeadDropEvent;
import io.github.thatsmusic99.headsplus.config.ConfigMobs;
import io.github.thatsmusic99.headsplus.config.HeadsPlusMessagesManager;
import io.github.thatsmusic99.headsplus.config.MainConfig;
import io.github.thatsmusic99.headsplus.managers.EntityDataManager;
import io.github.thatsmusic99.headsplus.managers.HeadManager;
import io.github.thatsmusic99.headsplus.managers.PersistenceManager;
import io.github.thatsmusic99.headsplus.managers.RestrictionsManager;
import io.github.thatsmusic99.headsplus.util.FlagHandler;
import io.github.thatsmusic99.headsplus.util.HPUtils;
import io.github.thatsmusic99.headsplus.util.events.HeadsPlusEventExecutor;
import io.github.thatsmusic99.headsplus.util.events.HeadsPlusListener;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;

import java.util.Random;

public class PlayerDeathListener extends HeadsPlusListener<PlayerDeathEvent> {

    @Override
    public void init() {
        Bukkit.getPluginManager().registerEvent(PlayerDeathEvent.class, this, EventPriority.NORMAL,
                new HeadsPlusEventExecutor(PlayerDeathEvent.class, "PlayerDeathEvent", this), HeadsPlus.get());
        addPossibleData("player", "<Player>");
        addPossibleData("enabled", "true", "false");
        addPossibleData("is-mythic-mob", "true", "false");
        addPossibleData("not-wg-restricted", "true", "false");
        addPossibleData("amount", "1", "2", "3", "4");
        addPossibleData("killer", "<Player>");
        addPossibleData("fixed-chance", "<Chance>");
        addPossibleData("random-chance", "<Chance>");
    }

    @Override
    public boolean shouldEnable() {
        return MainConfig.get().getMainFeatures().PLAYER_DROPS;
    }

    @Override
    public void onEvent(PlayerDeathEvent event) {
        Player victim = event.getEntity();
        Player killer = victim.getKiller();

        addData("player", victim.getName());
        // Make sure the entity isn't from MythicMobs
        if (addData("is-mythic-mob", HPUtils.isMythicMob(event.getEntity()))) return;
        if (!addData("not-wg-restricted", Bukkit.getPluginManager().getPlugin("WorldGuard") == null
                || FlagHandler.canDrop(event.getEntity().getLocation(), event.getEntity().getType()))) return;
        if (!HPUtils.runBlacklistTests(event.getEntity())) return;
        double fixedChance = addData("fixed-chance", ConfigMobs.get().getPlayerChance(victim.getName()));
        if (fixedChance == 0) return;
        double randomChance = addData("random-chance", new Random().nextDouble() * 100);
        if (killer != null) {<commit_msg>lol wait i didn't check the method used whoops<commit_after>package io.github.thatsmusic99.headsplus.listeners;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.api.events.PlayerHeadDropEvent;
import io.github.thatsmusic99.headsplus.config.ConfigMobs;
import io.github.thatsmusic99.headsplus.config.HeadsPlusMessagesManager;
import io.github.thatsmusic99.headsplus.config.MainConfig;
import io.github.thatsmusic99.headsplus.managers.EntityDataManager;
import io.github.thatsmusic99.headsplus.managers.HeadManager;
import io.github.thatsmusic99.headsplus.managers.PersistenceManager;
import io.github.thatsmusic99.headsplus.managers.RestrictionsManager;
import io.github.thatsmusic99.headsplus.util.FlagHandler;
import io.github.thatsmusic99.headsplus.util.HPUtils;
import io.github.thatsmusic99.headsplus.util.events.HeadsPlusEventExecutor;
import io.github.thatsmusic99.headsplus.util.events.HeadsPlusListener;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;

import java.util.Random;

public class PlayerDeathListener extends HeadsPlusListener<PlayerDeathEvent> {

    @Override
    public void init() {
        Bukkit.getPluginManager().registerEvent(PlayerDeathEvent.class, this, EventPriority.NORMAL,
                new HeadsPlusEventExecutor(PlayerDeathEvent.class, "PlayerDeathEvent", this), HeadsPlus.get());
        addPossibleData("player", "<Player>");
        addPossibleData("enabled", "true", "false");
        addPossibleData("is-mythic-mob", "true", "false");
        addPossibleData("not-wg-restricted", "true", "false");
        addPossibleData("amount", "1", "2", "3", "4");
        addPossibleData("killer", "<Player>");
        addPossibleData("fixed-chance", "<Chance>");
        addPossibleData("random-chance", "<Chance>");
    }

    @Override
    public boolean shouldEnable() {
        return MainConfig.get().getMainFeatures().PLAYER_DROPS;
    }

    @Override
    public void onEvent(PlayerDeathEvent event) {
        Player victim = event.getEntity();
        Player killer = victim.getKiller();

        addData("player", victim.getName());
        // Make sure the entity isn't from MythicMobs
        if (addData("is-mythic-mob", HPUtils.isMythicMob(event.getEntity()))) return;
        if (!addData("not-wg-restricted", Bukkit.getPluginManager().getPlugin("WorldGuard") == null
                || FlagHandler.canDrop(event.getEntity().getLocation(), event.getEntity().getType()))) return;
        if (!shouldDropHead(event.getEntity())) return;
        double fixedChance = addData("fixed-chance", ConfigMobs.get().getPlayerChance(victim.getName()));
        if (fixedChance == 0) return;
        double randomChance = addData("random-chance", new Random().nextDouble() * 100);
        if (killer != null) {
{'fraction_non_alphanumeric': 0.13140916808149405, 'fraction_numerical': 0.012224108658743633, 'mean_word_length': 4.5680529300567105, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '7395233', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1793, 'n_words': 284}