package com.loganmagnan.eventcore.commands;

import com.loganmagnan.eventcore.EventCore;
import com.loganmagnan.eventcore.utils.ColorUtils;
import com.loganmagnan.eventcore.utils.Constants;
import com.loganmagnan.eventcore.utils.command.BaseCommand;
import com.loganmagnan.eventcore.utils.command.Command;
import com.loganmagnan.eventcore.utils.command.CommandArguments;
import org.bukkit.entity.Player;

public class BypassModeCommand extends BaseCommand {

    private EventCore main = EventCore.getInstance();

    @Command(name = "bypassmode", permission = "eventcore.command.bypassmode", aliases = {"bypass", "build", "buildmode"})
    @Override
    public void executeAs(CommandArguments command) {
        Player player = command.getPlayer();

        String[] args = command.getArgs();

        if (args.length == 0) {
            if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) {
                this.main.getStaffManager().getPlayersBypassed().remove(player.getUniqueId());

                player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("bypass-mode.disabled").get(0)));
            } else {
                this.main.getStaffManager().getPlayersBypassed().add(player.getUniqueId());

                player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("bypass-mode.enabled").get(0)));
            }
        }
    }
}
