<commit_before>package com.gamingmesh.jobs.config;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;

import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
import com.gamingmesh.jobs.CMILib.CMIEntityType;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ConfigReader;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.NameList;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.Util;

public class NameTranslatorManager {

    public HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>();
    public ArrayList<NameList> ListOfEntities = new ArrayList<>();
    public HashMap<String, NameList> ListOfEnchants = new HashMap<>();
    public HashMap<String, NameList> ListOfMMEntities = new HashMap<>();
    public ArrayList<NameList> ListOfColors = new ArrayList<>();

    public String Translate(String materialName, JobInfo info) {
	return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
    }

    public String Translate(String materialName, ActionType action, Integer id, String meta, String mame) {
	// Translating name to user friendly
	if (Jobs.getGCManager().UseCustomNames)
	    switch (action) {
	    case BREAK:
	    case TNTBREAK:
	    case EAT:
	    case CRAFT:
	    case DYE:
	    case COLLECT:
	    case BAKE:
	    case PLACE:
	    case SMELT:
	    case REPAIR:
	    case BREW:
	    case FISH:
	    case STRIPLOGS:
		materialName = materialName.replace(" ", "");

		CMIMaterial mat = CMIMaterial.get(materialName.replace(" ", ""));
		NameList nameLs = ListOfNames.get(mat);
		if (nameLs == null) {
		    return mat.getName();
		}

		if (meta != null && !meta.isEmpty()) {
		    mat = CMIMaterial.get(materialName + ":" + meta);
		    nameLs = ListOfNames.get(mat);
		    if (nameLs == null) {
			return mat.getName();
		    }
		}

		if (id != null && id > 0 && meta != null && !meta.isEmpty()) {
		    mat = CMIMaterial.get(id + ":" + meta);
		    nameLs = ListOfNames.get(mat);
		    if (nameLs == null) {
			return mat.getName();
		    }
		}

		return nameLs.getName();
	    case BREED:
	    case KILL:
	    case MILK:
	    case TAME:
		for (NameList one : ListOfEntities) {
		    String ids = one.getId() + ":" + one.getMeta();
		    if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equalsIgnoreCase("0")) {
			return one.getName();
		    }
		    ids = one.getId();
		    if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equalsIgnoreCase("0")) {
			return one.getName();
		    }
		    ids = one.getMinecraftName();
		    if (ids.equalsIgnoreCase(mame)) {
			return one.getName();
		    }
		}
		break;
	    case ENCHANT:
		String name = materialName;
		String level = "";
		if (name.contains(":")) {
		    name = materialName.split(":")[0];
		    level = ":" + materialName.split(":")[1];
		}
		NameList nameInfo = ListOfEnchants.get(name.toLowerCase().replace("_", ""));
		if (nameInfo != null) {
		    return nameInfo.getMinecraftName() + level;
		}<commit_msg>Fixing material translations<commit_after>package com.gamingmesh.jobs.config;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;

import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
import com.gamingmesh.jobs.CMILib.CMIEntityType;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.CMILib.ConfigReader;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.NameList;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.Util;

public class NameTranslatorManager {

    public HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>();
    public ArrayList<NameList> ListOfEntities = new ArrayList<>();
    public HashMap<String, NameList> ListOfEnchants = new HashMap<>();
    public HashMap<String, NameList> ListOfMMEntities = new HashMap<>();
    public ArrayList<NameList> ListOfColors = new ArrayList<>();

    public String Translate(String materialName, JobInfo info) {
	return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
    }

    public String Translate(String materialName, ActionType action, Integer id, String meta, String mame) {
	// Translating name to user friendly
	if (Jobs.getGCManager().UseCustomNames)
	    switch (action) {
	    case BREAK:
	    case TNTBREAK:
	    case EAT:
	    case CRAFT:
	    case DYE:
	    case COLLECT:
	    case BAKE:
	    case PLACE:
	    case SMELT:
	    case REPAIR:
	    case BREW:
	    case FISH:
	    case STRIPLOGS:
		materialName = materialName.replace(" ", "");

		CMIMaterial mat = CMIMaterial.get(materialName.replace(" ", ""));
		NameList nameLs = ListOfNames.get(mat);

		if (nameLs != null) {
		    return nameLs.getName();
		}

		if (mame != null && !mame.isEmpty()) {
		    mat = CMIMaterial.get(materialName.replace(" ", ""));
		    nameLs = ListOfNames.get(mat);

		    if (nameLs != null) {
			return nameLs.getName();
		    }
		}

		if (meta != null && !meta.isEmpty()) {
		    mat = CMIMaterial.get(materialName + ":" + meta);
		    nameLs = ListOfNames.get(mat);
		    if (nameLs == null) {
			return mat.getName();
		    }
		}

		if (id != null && id > 0 && meta != null && !meta.isEmpty()) {
		    mat = CMIMaterial.get(id + ":" + meta);
		    nameLs = ListOfNames.get(mat);
		    if (nameLs == null) {
			return mat.getName();
		    }
		}

		return mat.getName();
	    case BREED:
	    case KILL:
	    case MILK:
	    case TAME:
		for (NameList one : ListOfEntities) {
		    String ids = one.getId() + ":" + one.getMeta();
		    if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equalsIgnoreCase("0")) {
			return one.getName();
		    }
		    ids = one.getId();
		    if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equalsIgnoreCase("0")) {
			return one.getName();
		    }
		    ids = one.getMinecraftName();
		    if (ids.equalsIgnoreCase(mame)) {
			return one.getName();
		    }
		}
		break;
	    case ENCHANT:
		String name = materialName;
		String level = "";
		if (name.contains(":")) {
		    name = materialName.split(":")[0];
		    level = ":" + materialName.split(":")[1];
		}
		NameList nameInfo = ListOfEnchants.get(name.toLowerCase().replace("_", ""));
		if (nameInfo != null) {
		    return nameInfo.getMinecraftName() + level;
		}
{'fraction_non_alphanumeric': 0.14376260443676175, 'fraction_numerical': 0.0014405070584845865, 'mean_word_length': 3.456354300385109, 'pattern_counts': {'":': 16, '<': 23, '<?xml version=': 0, '>': 25, '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': '4555838', 'n_tokens_mistral': 2504, 'n_tokens_neox': 2270, 'n_words': 483}