Added permission check to PlayerArmor listener

This commit is contained in:
WildInterloper 2024-03-05 00:31:18 -05:00
parent 2e7ebf3791
commit 94f96bbd40
2 changed files with 10 additions and 12 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.NVus</groupId>
<artifactId>NVus_Prison_Setup</artifactId>
<version>0.1-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PrisonSetup</name>

View File

@ -1,5 +1,6 @@
package me.nvus.nvus_prison_setup.Listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -10,18 +11,15 @@ public class PlayerArmor implements Listener {
// Prevent Armor Unequip??
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getClickedInventory().getType() == InventoryType.PLAYER)
{
if (event.getSlotType() == InventoryType.SlotType.ARMOR)
{
event.setCancelled(true);
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);
}
}
}
}
}