From 2502f5e6f216d3b6f0bd1cdb98e971e7847e408b Mon Sep 17 00:00:00 2001 From: Glare Date: Mon, 5 Aug 2019 10:19:03 -0500 Subject: [PATCH] Check if user has a permission to block putting X item on their head. (#2574) Closes #2550. * Check if user has a permission to block putting X item on their head. * Forced the material name to be lower case. * Fixed a typo in the message. * Updated permission node and added check to the EssentialsPlayerListener. --- .../src/com/earth2me/essentials/EssentialsPlayerListener.java | 2 +- .../src/com/earth2me/essentials/commands/Commandhat.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 3892343e4..e22f471b6 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -735,7 +735,7 @@ public class EssentialsPlayerListener implements Listener { if (ess.getSettings().isDirectHatAllowed() && event.getClick() == ClickType.LEFT && event.getSlot() == 39 && event.getCursor().getType() != Material.AIR && event.getCursor().getType().getMaxDurability() == 0 && !MaterialUtil.isSkull(event.getCursor().getType()) - && ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat")) { + && ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat") && !ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat.prevent-type." + event.getCursor().getType().name().toLowerCase())) { event.setCancelled(true); final PlayerInventory inv = (PlayerInventory) clickedInventory; final ItemStack head = inv.getHelmet(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java index 4ba918945..da9d547a5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java @@ -35,6 +35,10 @@ public class Commandhat extends EssentialsCommand { } else { final ItemStack hand = user.getItemInHand(); if (hand != null && hand.getType() != Material.AIR) { + if (user.isAuthorized("essentials.hat.prevent-type." + hand.getType().name().toLowerCase())) { + user.sendMessage(tl("hatFail")); + return; + } if (hand.getType().getMaxDurability() == 0) { final PlayerInventory inv = user.getBase().getInventory(); final ItemStack head = inv.getHelmet();