<commit_before>package net.nunnerycode.bukkit.mythicdrops.utils;

import net.nunnerycode.bukkit.mythicdrops.MythicDropsPlugin;
import net.nunnerycode.bukkit.mythicdrops.socketting.SocketGem;
import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public final class SocketGemUtil {

	private SocketGemUtil() {
		// do nothing;
	}

	public static ItemStack addSockets(ItemStack stack, int amount) {
		Validate.notNull(stack, "ItemStack cannot be null");

		ItemStack is = stack;
		for (int i = 0; i < amount; i++) {
			is = addSocket(is);
		}
		return is;
	}

	public static SocketGem getSocketGemFromName(String name) {
		for (SocketGem sg : MythicDropsPlugin.getInstance().getSockettingSettings().getSocketGemMap().values()) {
			if (sg.getName().equalsIgnoreCase(name)) {
				return sg;
			}
		}
		return null;
	}

	public static ItemStack addSocket(ItemStack stack) {<commit_msg>adding multiple methods for commands<commit_after>package net.nunnerycode.bukkit.mythicdrops.utils;

import net.nunnerycode.bukkit.mythicdrops.MythicDropsPlugin;
import net.nunnerycode.bukkit.mythicdrops.socketting.SocketGem;
import org.apache.commons.lang.math.RandomUtils;
import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class SocketGemUtil {

	private SocketGemUtil() {
		// do nothing;
	}

	public static ItemStack addSockets(ItemStack stack, int amount) {
		Validate.notNull(stack, "ItemStack cannot be null");

		ItemStack is = stack;
		for (int i = 0; i < amount; i++) {
			is = addSocket(is);
		}
		return is;
	}

	public static SocketGem getSocketGemFromName(String name) {
		for (SocketGem sg : MythicDropsPlugin.getInstance().getSockettingSettings().getSocketGemMap().values()) {
			if (sg.getName().equalsIgnoreCase(name)) {
				return sg;
			}
		}
		return null;
	}

	public static SocketGem getRandomSocketGemWithChance() {
		Map<String, SocketGem> socketGemMap = MythicDropsPlugin.getInstance().getSockettingSettings().getSocketGemMap
				();
		if (socketGemMap == null || socketGemMap.isEmpty()) {
			return null;
		}
		Set<SocketGem> zeroChanceSocketGems = new HashSet<>();
		while (zeroChanceSocketGems.size() != socketGemMap.size()) {
			for (SocketGem socket : socketGemMap.values()) {
				if (socket.getChance() <= 0.0D) {
					zeroChanceSocketGems.add(socket);
					continue;
				}
				if (RandomUtils.nextDouble() < socket.getChance()) {
					return socket;
				}
			}
		}
		return null;
	}

	public static MaterialData getRandomSocketGemMaterial() {
		List<MaterialData> materialDatas = MythicDropsPlugin.getInstance().getSockettingSettings()
				.getSocketGemMaterialDatas();
		if (materialDatas == null || materialDatas.isEmpty()) {
			return null;
		}
		return materialDatas.get(RandomUtils.nextInt(materialDatas.size()));
	}

	public static ItemStack addSocket(ItemStack stack) {
{'fraction_non_alphanumeric': 0.11632970451010886, 'fraction_numerical': 0.0018662519440124418, 'mean_word_length': 4.742857142857143, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1922883', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1087, 'n_words': 213}