package net.piratjsk.sddls;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.PluginDescriptionFile;

public final class SddlsCommand implements CommandExecutor {

    private static final String TAG = "&6[Sddls] &r";
    private final Sddls sddls;

    public SddlsCommand(final Sddls sddlsPlugin) {
        this.sddls = sddlsPlugin;
    }

    public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
        if (args.length > 0 && args[0].equalsIgnoreCase("reload")){
            if (sender instanceof ConsoleCommandSender || sender.hasPermission("sddls.reload")) {
                sddls.reloadConfig();
                sendMsg(sender, "Reloaded!");
                return true;
            }
        }
        this.sendPluginInfo(sender);
        if (sender.hasPermission("sddls.reload"))
            sendMsg(sender, "/sddls reload &7- reloads config");
        return true;
    }

    private void sendPluginInfo(final CommandSender recipient) {
        final PluginDescriptionFile info = sddls.getDescription();
        sendMsg(recipient, info.getFullName() + " v" + info.getVersion());
        sendMsg(recipient, "by " + info.getAuthors());
        sendMsg(recipient, info.getDescription());
        sendMsg(recipient, "&7"+ info.getWebsite());
    }

    private static void sendMsg(final CommandSender recipient, final String message) {
        recipient.sendMessage(ChatColor.translateAlternateColorCodes('&', TAG + message));
    }

}

@@ -1290,35 +1290,8 @@
 me()
- + %22 v%22 + info.getVersion()
 );%0A 
@@ -1323,16 +1323,34 @@
  %22by %22 +
+ String.join(%22, %22,
  info.ge
@@ -1360,16 +1360,17 @@
 thors())
+)
 ;%0A      

improve message sent by command /sddls