mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
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.
This commit is contained in:
parent
95f2852cf3
commit
2502f5e6f2
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user