package org.royaldev.royalcommands.rcommands;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.royaldev.royalcommands.RUtils;
import org.royaldev.royalcommands.RoyalCommands;

import java.io.File;
import java.util.Map;

public class ListWarns implements CommandExecutor {

    RoyalCommands plugin;

    public ListWarns(RoyalCommands plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender cs, Command cmd, String label,
                             String[] args) {
        if (cmd.getName().equalsIgnoreCase("listwarns")) {
            if (!plugin.isAuthorized(cs, "rcmds.listwarns")) {
                RUtils.dispNoPerms(cs);
                return true;
            }
            if (args.length < 1) {
                File pconfl = new File(plugin.getDataFolder() + "/userdata/" + cs.getName().toLowerCase() + ".yml");
                if (pconfl.exists()) {
                    FileConfiguration pconf = YamlConfiguration.loadConfiguration(pconfl);
                    if (pconf.get("warns") == null) {
                        cs.sendMessage(ChatColor.RED + "You have no warnings!");
                        return true;
                    }
                    final Map<String, Object> opts = pconf.getConfigurationSection("warns").getValues(true);
                    if (opts.values().isEmpty()) {
                        cs.sendMessage(ChatColor.RED + "You have no warnings!");
                        return true;
                    }
                    String homes = opts.values().toString();
                    homes = homes.substring(1, homes.length() - 1);
                    cs.sendMessage(ChatColor.RED + "Warnings:");
                    cs.sendMessage(homes.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
                    return true;
                }
            }
            if (args.length > 0) {
                if (!plugin.isAuthorized(cs, "rcmds.listwarns.others")) {
                    RUtils.dispNoPerms(cs);
                    return true;
                }
                File pconfl = new File(plugin.getDataFolder() + "/userdata/" + args[0].toLowerCase() + ".yml");
                if (pconfl.exists()) {
                    FileConfiguration pconf = YamlConfiguration.loadConfiguration(pconfl);
                    if (pconf.get("warns") == null) {
                        cs.sendMessage(ChatColor.RED + "That user has no warnings!");
                        return true;
                    }
                    final Map<String, Object> opts = pconf.getConfigurationSection("warns").getValues(true);
                    if (opts.values().isEmpty()) {
                        cs.sendMessage(ChatColor.RED + "That user has no warnings!");
                        return true;
                    }
                    String homes = opts.values().toString();
                    homes = homes.substring(1, homes.length() - 1);
                    cs.sendMessage(ChatColor.RED + "User's warnings:");
                    cs.sendMessage(homes.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
                    return true;
                }
            }
        }
        return false;
    }
}

@@ -292,32 +292,65 @@
 lConfiguration;%0A
+import org.bukkit.entity.Player;%0A
 import org.royal
@@ -1001,24 +1001,181 @@
 ngth %3C 1) %7B%0A
+                if (!(cs instanceof Player)) %7B%0A                    cs.sendMessage(cmd.getDescription());%0A                    return false;%0A                %7D%0A
             

Make sure /listwarns yells at console