package net.new_liberty.pvpranker.command;

import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import net.new_liberty.pvpranker.PvPRanker;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

/**
 *
 * @author simplyianm
 */
public class PvPTopCommand implements CommandExecutor {
    private final PvPRanker plugin;

    public PvPTopCommand(PvPRanker plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
        String milestone = null;
        if (args.length > 0) {
            milestone = args[0];
        }

        final String theMilestone = milestone;

        // http://i.qkme.me/3ux37g.jpg I'm so funny
        plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
            @Override
            public void run() {
                final LinkedHashMap<String, Integer> map = plugin.generateScoreReport(10, theMilestone);
                Bukkit.getServer().getScheduler().callSyncMethod(plugin, new Callable<Object>() {
                    @Override
                    public Object call() {
                        sender.sendMessage(ChatColor.YELLOW + "== PvP Top Scores ==");
                        if (map.isEmpty()) {
                            sender.sendMessage(ChatColor.GREEN + "Nobody has killed anyone yet.");

                        } else {
                            int i = 1;
                            for (Entry<String, Integer> playerScore : map.entrySet()) {
                                sender.sendMessage(ChatColor.GREEN + Integer.toString(i++) + ") " + playerScore.getKey() + " - " + playerScore.getValue());
                            }
                        }
                        return null;
                    }
                });
            }
        });

        return true;
    }
}

@@ -841,60 +841,8 @@
 e;%0A%0A
-        // http://i.qkme.me/3ux37g.jpg I'm so funny%0A
     
@@ -1089,187 +1089,8 @@
 e);%0A
-                Bukkit.getServer().getScheduler().callSyncMethod(plugin, new Callable%3CObject%3E() %7B%0A                    @Override%0A                    public Object call() %7B%0A        
     
@@ -1180,24 +1180,16 @@
         
- 
-       
 if (map.
@@ -1197,32 +1197,24 @@
 sEmpty()) %7B%0A
-        
             
@@ -1309,24 +1309,16 @@
         
-     
-   
 %7D else %7B
@@ -1318,24 +1318,16 @@
  else %7B%0A
-        
         
@@ -1349,24 +1349,16 @@
  i = 1;%0A
-        
         
@@ -1449,32 +1449,24 @@
             
- 
-       
 sender.sendM
@@ -1581,101 +1581,8 @@
 ));%0A
-                            %7D%0A                        %7D%0A                        return null;%0A
     
@@ -1616,18 +1616,16 @@
        %7D
-);
 %0A       

Remove unnecessary callSync use