Block removing hats with curse of binding (#3299)

This commit is contained in:
Josh Roy 2020-05-27 15:36:22 -04:00 committed by GitHub
parent 53e7c83254
commit 4c48ccb422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -2,10 +2,12 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.utils.VersionUtil;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.permissions.Permission;
@ -55,6 +57,8 @@ public class Commandhat extends EssentialsCommand {
final ItemStack head = inv.getHelmet();
if (head == null || head.getType() == Material.AIR) {
user.sendMessage(tl("hatEmpty"));
} else if (VersionUtil.getServerBukkitVersion().isHigherThan(VersionUtil.v1_9_4_R01) && head.getEnchantments().containsKey(Enchantment.BINDING_CURSE) && !user.isAuthorized("essentials.hat.ignore-binding")) {
user.sendMessage(tl("hatCurse"));
} else {
final ItemStack air = new ItemStack(Material.AIR);
inv.setHelmet(air);
@ -71,6 +75,10 @@ public class Commandhat extends EssentialsCommand {
if (hand.getType().getMaxDurability() == 0) {
final PlayerInventory inv = user.getBase().getInventory();
final ItemStack head = inv.getHelmet();
if (VersionUtil.getServerBukkitVersion().isHigherThan(VersionUtil.v1_9_4_R01) && head != null && head.getEnchantments().containsKey(Enchantment.BINDING_CURSE) && !user.isAuthorized("essentials.hat.ignore-binding")) {
user.sendMessage(tl("hatCurse"));
return;
}
inv.setHelmet(hand);
inv.setItemInHand(head);
user.sendMessage(tl("hatPlaced"));

View File

@ -163,6 +163,7 @@ godMode=\u00a76God mode\u00a7c {0}\u00a76.
groupDoesNotExist=\u00a74There''s no one online in this group\!
groupNumber=\u00a7c{0}\u00a7f online, for the full list\:\u00a7c /{1} {2}
hatArmor=\u00a74You cannot use this item as a hat\!
hatCurse=\u00a74You cannot remove a hat with the curse of binding\!
hatEmpty=\u00a74You are not wearing a hat.
hatFail=\u00a74You must have something to wear in your hand.
hatPlaced=\u00a76Enjoy your new hat\!