From b640788033e357d3910aae4e2ebcea4468d4092b Mon Sep 17 00:00:00 2001 From: fullwall Date: Wed, 8 May 2019 21:04:08 +0800 Subject: [PATCH] Allow chat messages for any equipment slot --- .../net/citizensnpcs/editor/EquipmentEditor.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java b/main/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java index 4779b87c3..f2fdfa340 100644 --- a/main/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java +++ b/main/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java @@ -47,18 +47,15 @@ public class EquipmentEditor extends Editor { public void onPlayerChat(final AsyncPlayerChatEvent event) { if (!event.getPlayer().equals(player)) return; - EquipmentSlot slot = null; - if (event.getMessage().contains("helmet") - && event.getPlayer().hasPermission("citizens.npc.edit.equip.any-helmet")) { - slot = EquipmentSlot.HELMET; - } - if (event.getMessage().contains("offhand") - && event.getPlayer().hasPermission("citizens.npc.edit.equip.offhand")) { - slot = EquipmentSlot.OFF_HAND; - } + EquipmentSlot slot = Util.matchEnum(EquipmentSlot.values(), event.getMessage()); if (slot == null) { return; } + if (!event.getPlayer().hasPermission("citizens.npc.edit.equip." + slot.name().toLowerCase().replace(" ", "")) + && (slot != EquipmentSlot.HELMET + || !event.getPlayer().hasPermission("citizens.npc.edit.equip.any-helmet"))) { + return; + } final EquipmentSlot finalSlot = slot; Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override