package com.newhive.scammerradar.commands.subcommands;

import com.newhive.scammerradar.ScammerRadarAddon;
import com.newhive.scammerradar.config.ScammerRadarConfig;
import com.newhive.scammerradar.exceptions.ProfileNotFoundException;
import java.io.IOException;
import net.labymod.api.client.chat.command.SubCommand;
import net.labymod.api.util.I18n;

public class RemoveSubCommand extends SubCommand {
   private final ScammerRadarAddon addon;

   public RemoveSubCommand(ScammerRadarAddon addon) {
      super("remove", new String[]{"r"});
      this.addon = addon;
   }

   public boolean execute(String prefix, String[] arguments) {
      if (!(Boolean)((ScammerRadarConfig)this.addon.configuration()).enabled().get()) {
         return false;
      } else {
         if (arguments.length == 1) {
            try {
               this.addon.getHelper().removeScammer(arguments[0]);
               this.addon.getHelper().displayNotification(I18n.translate("scammerradar.commands.remove.success", new Object[0]).replace("<user>", arguments[0]));
            } catch (IOException | ProfileNotFoundException e) {
               this.addon.getHelper().displayNotification(e);
               this.addon.logger().error(((Exception)e).getMessage(), new Object[0]);
            }
         } else {
            this.addon.getHelper().displayNotification(I18n.translate("scammerradar.commands.remove.usage", new Object[0]));
         }

         return true;
      }
   }
}
