<commit_before>package me.nallar.modpatcher.tasks;

import com.google.common.io.ByteStreams;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;

import java.io.*;
import java.util.*;
import java.util.jar.*;

public class TaskProcessBinary extends DefaultTask {
	private static final HashMap<String, String> classExtends = new HashMap<String, String>();

	@TaskAction
	public void run() throws Exception {
		File f = getProject().getTasksByName("deobfMcMCP", false).iterator().next().getOutputs().getFiles().iterator().next();
		generateMappings(f);
	}

	private static void addClassToExtendsMap(byte[] inputCode) {
		ClassReader classReader = new ClassReader(inputCode);
		ClassNode classNode = new ClassNode();
		classReader.accept(classNode, 0);
		String superName = classNode.superName.replace("/", ".");
		if (superName != null && !superName.equals("java.lang.Object")) {
			classExtends.put(classNode.name.replace("/", "."), superName);
		}
	}

	private static void generateMappings(File jar) throws Exception {
		JarInputStream istream = new JarInputStream(new FileInputStream(jar));
		JarEntry entry;
		while ((entry = istream.getNextJarEntry()) != null) {
			byte[] classBytes = ByteStreams.toByteArray(istream);
			if (entry.getName().endsWith(".class")) {
				addClassToExtendsMap(classBytes);<commit_msg>Skip binary processing if output file does not exist<commit_after>package me.nallar.modpatcher.tasks;

import com.google.common.io.ByteStreams;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;

import java.io.*;
import java.util.*;
import java.util.jar.*;

public class TaskProcessBinary extends DefaultTask {
	private static final HashMap<String, String> classExtends = new HashMap<String, String>();

	@TaskAction
	public void run() throws Exception {
		File f = getProject().getTasksByName("deobfMcMCP", false).iterator().next().getOutputs().getFiles().iterator().next();

		if (!f.exists())
			return;

		generateMappings(f);
	}

	private static void addClassToExtendsMap(byte[] inputCode) {
		ClassReader classReader = new ClassReader(inputCode);
		ClassNode classNode = new ClassNode();
		classReader.accept(classNode, 0);
		String superName = classNode.superName.replace("/", ".");
		if (superName != null && !superName.equals("java.lang.Object")) {
			classExtends.put(classNode.name.replace("/", "."), superName);
		}
	}

	private static void generateMappings(File jar) throws Exception {
		JarInputStream istream = new JarInputStream(new FileInputStream(jar));
		JarEntry entry;
		while ((entry = istream.getNextJarEntry()) != null) {
			byte[] classBytes = ByteStreams.toByteArray(istream);
			if (entry.getName().endsWith(".class")) {
				addClassToExtendsMap(classBytes);
{'fraction_non_alphanumeric': 0.13794289645682833, 'fraction_numerical': 0.0006879944960440316, 'mean_word_length': 5.491071428571429, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4554673', 'n_tokens_mistral': 928, 'n_tokens_neox': 868, 'n_words': 192}