<commit_before>package ru.beykerykt.lightsource.sources.search;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import ru.beykerykt.lightsource.LightSourceAPI;
import ru.beykerykt.lightsource.items.Item;
import ru.beykerykt.lightsource.items.flags.FlagHelper;
import ru.beykerykt.lightsource.sources.EntityItemSource;
import ru.beykerykt.lightsource.sources.Source;

public class ItemEntitySearchMachine implements SearchTask {

	private double radius = 20;

	public ItemEntitySearchMachine(double radius) {
		this.radius = radius;
	}

	@Override
	public void onTick() {
		for (Player player : Bukkit.getOnlinePlayers()) {
			for (Entity entity : player.getNearbyEntities(radius, radius, radius)) {
				if (LightSourceAPI.getSourceManager().isSource(entity))
					continue;
				if (entity.getType() == EntityType.DROPPED_ITEM) {
					org.bukkit.entity.Item ie = (org.bukkit.entity.Item) entity;
					ItemStack itemStack = ie.getItemStack();
					if (itemStack == null || itemStack.getType() == Material.AIR)
						continue;
					if (!LightSourceAPI.getItemManager().isItem(itemStack))
						continue;
					Item item = LightSourceAPI.getItemManager().getItemFromItemStack(itemStack);
					if (item.getFlagsList().isEmpty())
						continue;
					if (FlagHelper.callRequirementFlags(ie, itemStack, item, false)) { // ?
						Source source = new EntityItemSource(ie, item);
						LightSourceAPI.getSourceManager().addSource(source);
					}
				}
			}
		}
	}
}<commit_msg>sources: now item search task use method from main search machine<commit_after>package ru.beykerykt.lightsource.sources.search;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import ru.beykerykt.lightsource.LightSourceAPI;
import ru.beykerykt.lightsource.items.Item;
import ru.beykerykt.lightsource.sources.EntityItemSource;
import ru.beykerykt.lightsource.sources.Source;

public class ItemEntitySearchMachine implements SearchTask {

	private double radius = 20;

	public ItemEntitySearchMachine(double radius) {
		this.radius = radius;
	}

	@Override
	public void onTick() {
		for (Player player : Bukkit.getOnlinePlayers()) {
			for (Entity entity : player.getNearbyEntities(radius, radius, radius)) {
				if (LightSourceAPI.getSourceManager().isSource(entity))
					continue;
				if (entity.getType() == EntityType.DROPPED_ITEM) {
					org.bukkit.entity.Item ie = (org.bukkit.entity.Item) entity;
					ItemStack itemStack = ie.getItemStack();
					if (itemStack == null || itemStack.getType() == Material.AIR)
						continue;
					if (!LightSourceAPI.getItemManager().isItem(itemStack))
						continue;
					Item item = LightSourceAPI.getItemManager().getItemFromItemStack(itemStack);
					if (item.getFlagsList().isEmpty())
						continue;
					if (LightSourceAPI.getSearchMachine().callRequirementFlags(ie, itemStack, item, null)) { // ?
						Source source = new EntityItemSource(ie, item);
						LightSourceAPI.getSourceManager().addSource(source);
					}
				}
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.11500615006150061, 'fraction_numerical': 0.0012300123001230013, 'mean_word_length': 4.44891122278057, 'pattern_counts': {'":': 0, '<': 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': '4046497', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1002, 'n_words': 190}