<commit_before>package com.namelessmc.plugin.spigot;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import com.google.gson.Gson;
import com.namelessmc.java_api.ApiError;
import com.namelessmc.java_api.NamelessException;

public class ServerDataSender extends BukkitRunnable {

	Gson gson = new Gson();
	
	@Override
	public void run() {
		final int serverId = Config.MAIN.getConfig().getInt("server-id");
		if (serverId < 1) {
			return;
		}
		
		final Map<String, Object> map = new HashMap<>();
		map.put("tps", 20); // TODO tps
		map.put("time", System.currentTimeMillis());
		map.put("free-memory", Runtime.getRuntime().freeMemory());
		map.put("max-memory", Runtime.getRuntime().maxMemory());
		map.put("allocated-memory", Runtime.getRuntime().totalMemory());
		map.put("server-id", serverId);
		
		final Map<String, Map<String, Object>> players = new HashMap<>();
		
		for (final Player player : Bukkit.getOnlinePlayers()) {
			final Map<String, Object> playerInfo = new HashMap<>();
			
			playerInfo.put("name", player.getName());
			
			final Map<String, Object> location = new HashMap<>();
			final Location loc = player.getLocation();
			location.put("world", loc.getWorld().getName());
			location.put("x", loc.getBlockX());
			location.put("y", loc.getBlockY());
			location.put("z", loc.getBlockZ());
			
			playerInfo.put("location", location);
			playerInfo.put("ip", player.getAddress().getAddress().getHostAddress());
			
			try {
				if (NamelessPlugin.permissions != null) {
					playerInfo.put("rank", NamelessPlugin.permissions.getPrimaryGroup(player));
				}
			} catch (final UnsupportedOperationException e) {}
			
			try {
				if (NamelessPlugin.economy != null) {
					playerInfo.put("balance", NamelessPlugin.economy.getBalance(player));
				}
			} catch (final UnsupportedOperationException e) {}
			
			final Map<String, String> placeholders = new HashMap<>();
			
			Config.MAIN.getConfig().getStringList("upload-placeholders")
				.forEach(placeholder ->
				placeholders.put(placeholder, NamelessPlugin.getInstance().papiParser.parse(player, placeholder)));
			
			playerInfo.put("placeholders", placeholders);<commit_msg>Send playtime<commit_after>package com.namelessmc.plugin.spigot;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import com.google.gson.Gson;
import com.namelessmc.java_api.ApiError;
import com.namelessmc.java_api.NamelessException;

public class ServerDataSender extends BukkitRunnable {

	Gson gson = new Gson();
	
	@Override
	public void run() {
		final int serverId = Config.MAIN.getConfig().getInt("server-id");
		if (serverId < 1) {
			return;
		}
		
		final Map<String, Object> map = new HashMap<>();
		map.put("tps", 20); // TODO tps
		map.put("time", System.currentTimeMillis());
		map.put("free-memory", Runtime.getRuntime().freeMemory());
		map.put("max-memory", Runtime.getRuntime().maxMemory());
		map.put("allocated-memory", Runtime.getRuntime().totalMemory());
		map.put("server-id", serverId);
		
		final Map<String, Map<String, Object>> players = new HashMap<>();
		
		for (final Player player : Bukkit.getOnlinePlayers()) {
			final Map<String, Object> playerInfo = new HashMap<>();
			
			playerInfo.put("name", player.getName());
			
			final Map<String, Object> location = new HashMap<>();
			final Location loc = player.getLocation();
			location.put("world", loc.getWorld().getName());
			location.put("x", loc.getBlockX());
			location.put("y", loc.getBlockY());
			location.put("z", loc.getBlockZ());
			
			playerInfo.put("location", location);
			playerInfo.put("ip", player.getAddress().getAddress().getHostAddress());
			playerInfo.put("playtime", player.getStatistic(Statistic.PLAY_ONE_TICK) / 120);
			
			try {
				if (NamelessPlugin.permissions != null) {
					playerInfo.put("rank", NamelessPlugin.permissions.getPrimaryGroup(player));
				}
			} catch (final UnsupportedOperationException e) {}
			
			try {
				if (NamelessPlugin.economy != null) {
					playerInfo.put("balance", NamelessPlugin.economy.getBalance(player));
				}
			} catch (final UnsupportedOperationException e) {}
			
			final Map<String, String> placeholders = new HashMap<>();
			
			Config.MAIN.getConfig().getStringList("upload-placeholders")
				.forEach(placeholder ->
				placeholders.put(placeholder, NamelessPlugin.getInstance().papiParser.parse(player, placeholder)));
			
			playerInfo.put("placeholders", placeholders);
{'fraction_non_alphanumeric': 0.1542235494880546, 'fraction_numerical': 0.0019197952218430034, 'mean_word_length': 4.562277580071174, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '1694887', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1429, 'n_words': 277}