package me.nvus.nvus_prison_setup.Listeners;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;

public class PlayerArmor implements Listener {

    // Prevent Armor Unequip??
    @EventHandler(priority = EventPriority.LOWEST)
    public void onInventoryClick(InventoryClickEvent event) {
        if (event.getClickedInventory() != null && event.getClickedInventory().getType() == InventoryType.PLAYER) {
            if (event.getSlotType() == InventoryType.SlotType.ARMOR) {
                Player player = (Player) event.getWhoClicked();
                // Check if the player is an actual prisoner before cancelling ;)
                if (player.hasPermission("nvus.prisoner")) {
                    event.setCancelled(true);
                    player.sendMessage(ChatColor.translateAlternateColorCodes('&',"&c&lSorry inmate! &cYou're a &6&lprisoner &cand cannot change your armor!"));
                }
            }
        }
    }




}
