package com.zerohighdef.geoffrey.Commands; import com.google.gson.JsonElement; import com.zerohighdef.geoffrey.GeoffreyMC; import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback; import com.zerohighdef.geoffrey.Objects.GeoffreyCommand; import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.HashMap; import java.util.Map; public class LocationsCommand extends GeoffreyCommand { public LocationsCommand(GeoffreyMC plugin) { super(plugin); } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { Map params = new HashMap(); params.put("mc_uuid", ((Player) sender).getPlayer().getUniqueId().toString().replace("-", "")); RunCommand("me", params, Method.GET, new CommandCallback(sender)); } else { sender.sendMessage(ChatColor.RED + "Console cannot have locations."); return false; } return true; } private class CommandCallback extends GeoffreyAPICallback { CommandCallback(CommandSender sender) { super(sender); } @Override public void invoke(String s) { try { JsonElement json = parseJSON(s); String msg = ChatColor.BOLD + "You own the following locations:\n" + ChatColor.RESET + locationList(json, 5); commandSender.sendMessage(ChatColor.GREEN + msg); } catch (GeoffreyCommandError e) { return; } } } }