package org.atmospheregames.network.command;

import com.google.gson.JsonObject;
import com.jonahseguin.drink.annotation.Command;
import com.jonahseguin.drink.annotation.Sender;
import org.atmospheregames.network.Network;
import org.bukkit.command.CommandSender;

public class NetworkCommand {

    private final Network plugin;

    public NetworkCommand(Network plugin) {
        this.plugin = plugin;
    }

    @Command(name = "info", desc = "Find information about a server", usage = "<server>")
    public void networkInfo(@Sender CommandSender sender, String target) {
        JsonObject object = plugin.getRedisClient().getRedisListener().getCachedMessages().get(target);

        if(object == null) {
            sender.sendMessage("Failed to find a server with the name: " + target);
            return;
        }

        sender.sendMessage("Server Information: " + target);
        sender.sendMessage(object.get("online").getAsString());
        sender.sendMessage(object.get("whitelisted").getAsString());
        sender.sendMessage(object.get("onlinePlayers").getAsString());
        sender.sendMessage(object.get("onlinePlayerLimit").getAsString());
        sender.sendMessage(object.get("ticksPerSecond").getAsString());
    }

}
