package xyz.benw.plugins.fouriermc.command;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration;
import xyz.benw.plugins.fouriermc.FourierMC;

import java.util.*;

/**
 * Basic config related commands
 *
 * @author bcbwilla
 */
public class FourierCommands implements CommandExecutor {

    private FourierMC plugin;
    private FileConfiguration config;

    public FourierCommands(FourierMC plugin) {
        this.plugin = plugin;
        this.config = plugin.getConfig();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("fmc")) {

            if (!sender.hasPermission("fmc")) {
                sender.sendMessage(ChatColor.RED + "You don't have permission.");
                return true;
            }

            if(args.length == 1 && args[0].equalsIgnoreCase("list")) {
                Map<String, Object> configParams = config.getValues(true);

                sender.sendMessage(ChatColor.DARK_AQUA + "FourierMC Config Settings:");
                for (Map.Entry<String, Object> entry : configParams.entrySet()) {
                    String key = entry.getKey();
                    Object value = entry.getValue();

                    if(!(value instanceof MemorySection)) {
                        sender.sendMessage(" " + key + ": " + value.toString());
                    }
                }
                return true;

            } else if(args.length == 2 && args[0].equalsIgnoreCase("get")) {
                sender.sendMessage(args[1] + ": " + config.get(args[1]));
                return true;

            } else if(args.length == 1 && args[0].equalsIgnoreCase("reloadconfig")) {
                plugin.reloadConfig();
                sender.sendMessage("Reloaded config for FourierMC.");
                return true;
            }

        }
        return false;
    }

}

@@ -38,16 +38,42 @@
 mmand;%0A%0A
+import org.bukkit.Bukkit;%0A
 import o
@@ -359,16 +359,311 @@
 urierMC;
+%0Aimport xyz.benw.plugins.fouriermc.player.PlayerData;%0Aimport xyz.benw.plugins.fouriermc.violation.AbstractViolation;%0Aimport xyz.benw.plugins.fouriermc.violation.AggregatedViolation;%0Aimport xyz.benw.plugins.fouriermc.violation.Violation;%0Aimport xyz.benw.plugins.fouriermc.violation.ViolationType;
 %0A%0Aimport
@@ -2360,32 +2360,1128 @@
    return true;%0A
+%0A%0A            %7D else if(args.length == 2 && args%5B0%5D.equalsIgnoreCase(%22info%22)) %7B%0A%0A                String nameString = args%5B1%5D;%0A                UUID targetID = Bukkit.getPlayer(nameString).getUniqueId(); // Is there a better way to do this?%0A%0A                PlayerData playerData = plugin.getPlayerData(targetID);%0A%0A                String msg = ChatColor.UNDERLINE + %22Violation Report for %22 + nameString + %22%5Cn %22;%0A                for(ViolationType vt : ViolationType.values()) %7B%0A%0A                    double velocity = 0;%0A                    int timesFailed = 0;%0A                    for(AggregatedViolation av : playerData.getAggregatedViolations(vt)) %7B%0A                        timesFailed += av.getTimesFailed();%0A                        velocity += av.getFailedVelocity();%0A                    %7D%0A%0A                    msg += vt.name() + %22: %5Cn%22;%0A                    msg += %22  Times Failed: %22 + Integer.toString(timesFailed) + %22%5Cn%22;%0A                    msg += %22  Velocity: %22 + Double.toString(velocity) + %22%5Cn%5Cn%22;%0A%0A                %7D%0A%0A                sender.sendMessage(msg);%0A                return true;%0A%0A
             %7D%0A%0A 

add information lookup command