package com.namelessmc.plugin.NamelessSpigot;

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;

public class ServerDataSender extends BukkitRunnable {

	Gson gson = new Gson();
	
	@Override
	public void run() {
		Map<String, Object> map = new HashMap<>();
		map.put("tps", 20); // TODO tps
		map.put("free-memory", Runtime.getRuntime().freeMemory());
		map.put("max-memory", Runtime.getRuntime().maxMemory());
		map.put("allocated-memory", Runtime.getRuntime().totalMemory());
		
		Map<String, Map<String, Object>> players = new HashMap<>();
		
		for (Player player : Bukkit.getOnlinePlayers()) {
			Map<String, Object> playerInfo = new HashMap<>();
			
			map.put("name", player.getName());
			
			Map<String, Object> location = new HashMap<>();
			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());
			
			map.put("location", location);
			map.put("ip", player.getAddress().getAddress().getHostAddress());
			
			players.put(player.getUniqueId().toString().replace("-", ""), playerInfo);
		}
		
		String data = gson.toJson(map);
		
		System.out.println(data);
	}

}

@@ -808,27 +808,34 @@
 %3E();%0A%09%09%09%0A%09%09%09
-map
+playerInfo
 .put(%22name%22,
@@ -1121,27 +1121,34 @@
 ());%0A%09%09%09%0A%09%09%09
-map
+playerInfo
 .put(%22locati
@@ -1166,19 +1166,26 @@
 on);%0A%09%09%09
-map
+playerInfo
 .put(%22ip
@@ -1328,16 +1328,50 @@
 %0A%09%09%7D%0A%09%09%0A
+%09%09map.put(%22players%22, players);%0A%09%09%0A
 %09%09String

Put data in correct maps