<commit_before>package net.simpvp.Misc;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;

/**
 * Logs death messages to console
 */
public class ConsoleDeathLog implements Listener {

	public ConsoleDeathLog(Misc plugin) {
		plugin.getServer().getPluginManager().registerEvents(this, plugin);
	}

	@EventHandler
	public void onPlayerDeath(PlayerDeathEvent event){
		Location loc = event.getEntity().getLocation();

		String death_msg = String.format("%s at '%d %d %d %s' (%s died)",
				event.getDeathMessage(),
				loc.getBlockX(),
				loc.getBlockY(),
				loc.getBlockZ(),
				loc.getWorld().getName(),
				event.getEntity().getName());
		/* Log player level and inventory contents just in case.
		 * The output log format should be consistent with the
		 * /eventrestore command format */
		String sInventoryContents = "";

		for (ItemStack itemStack : event.getEntity().getInventory().getContents()) {
			if (itemStack == null)
				continue;

			String tmp = itemStack.getType().toString()
				+ "." + itemStack.getAmount()
				+ "." + itemStack.getDurability()
				+ "." + itemStack.getEnchantments().toString();
			tmp = tmp.replaceAll(" ", "");
			sInventoryContents += " " + tmp;
		}

		/* Intentional use of bukkit logger */
		Bukkit.getLogger().info(death_msg + ": " + event.getEntity().getLevel() + sInventoryContents);
	}<commit_msg>Switch deathlog to new eventrestore format<commit_after>package net.simpvp.Misc;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.util.Base64;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectOutputStream;

/**
 * Logs death messages to console
 */
public class ConsoleDeathLog implements Listener {

	public ConsoleDeathLog(Misc plugin) {
		plugin.getServer().getPluginManager().registerEvents(this, plugin);
	}

	@EventHandler
	public void onPlayerDeath(PlayerDeathEvent event){
		Location loc = event.getEntity().getLocation();

		String death_msg = String.format("%s at '%d %d %d %s' (%s died)",
				event.getDeathMessage(),
				loc.getBlockX(),
				loc.getBlockY(),
				loc.getBlockZ(),
				loc.getWorld().getName(),
				event.getEntity().getName());
		/* Log player level and inventory contents just in case.
		 * The output log format should be consistent with the
		 * /eventrestore command format */
		ItemStack[] inventory = event.getEntity().getInventory().getContents();
		String inventoryString;
		try {
			ByteArrayOutputStream bytearray = new ByteArrayOutputStream();
			OutputStream base64 = Base64.getEncoder().wrap(bytearray);
			BukkitObjectOutputStream bukkitstream = new BukkitObjectOutputStream(base64);

			int len = 0;
			for (ItemStack itemStack : inventory) {
				if (itemStack == null) {
					continue;
				}
				len += 1;
			}
			bukkitstream.writeInt(len);

			for (ItemStack itemStack : inventory) {
				if (itemStack == null) {
					continue;
				}

				bukkitstream.writeObject(itemStack);
			}

			bukkitstream.close();
			base64.close();

			inventoryString = new String(bytearray.toByteArray());
		} catch (Exception e) {
			throw new RuntimeException(e);
		}

		/* Intentional use of bukkit logger */
		Bukkit.getLogger().info(String.format("%s: %d %s", death_msg, event.getEntity().getLevel(), inventoryString));
	}
{'fraction_non_alphanumeric': 0.1303501945525292, 'fraction_numerical': 0.0033351862145636463, 'mean_word_length': 4.215942028985507, 'pattern_counts': {'":': 1, '<': 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': '6031805', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1075, 'n_words': 251}