package de.viper.survivalplus.commands;

import de.viper.survivalplus.SurvivalPlus;
import de.viper.survivalplus.listeners.MobLeashLimitListener;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class LeashCountCommand implements CommandExecutor {
    private final SurvivalPlus plugin;
    private final MobLeashLimitListener listener;

    public LeashCountCommand(SurvivalPlus plugin, MobLeashLimitListener listener) {
        this.plugin = plugin;
        this.listener = listener;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(plugin.getMessage("player-only"));
            return true;
        }
        Player player = (Player) sender;
        int count = listener.getLeashCount(player);
        player.sendMessage(plugin.getMessage("leashcount.message").replace("%count%", String.valueOf(count)));
        return true;
    }
}
