package com.github.games647.flexiblelogin.tasks;

import com.github.games647.flexiblelogin.FlexibleLogin;

import java.util.UUID;

import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.format.TextColors;
import org.spongepowered.api.util.command.CommandSource;

public class UnregisterTask implements Runnable {

    private final FlexibleLogin plugin;
    private final CommandSource src;

    private final Object accountIndentifer;

    public UnregisterTask(FlexibleLogin plugin, CommandSource src, UUID uuid) {
        this.plugin = plugin;
        this.src = src;

        this.accountIndentifer = uuid;
    }

    public UnregisterTask(FlexibleLogin plugin, CommandSource src, String playerName) {
        this.plugin = plugin;
        this.src = src;

        this.accountIndentifer = playerName;
    }

    @Override
    public void run() {
        boolean accountFound;
        if (accountIndentifer instanceof String) {
            accountFound = plugin.getDatabase().deleteAccount((String) accountIndentifer);
        } else {
            accountFound = plugin.getDatabase().deleteAccount((UUID) accountIndentifer);
        }

        if (accountFound) {
            src.sendMessage(Texts.of(TextColors.DARK_GREEN, "Deleted account of: " + accountIndentifer));
        } else {
            src.sendMessage(Texts.of(TextColors.DARK_RED, "Error executing command. See console"));
        }
    }
}

@@ -1367,44 +1367,30 @@
 D, %22
-Error executing command. See console
+User account not found
 %22));

Fix command message if the account wasn't found on deleting.