Allow chat messages for any equipment slot

This commit is contained in:
fullwall 2019-05-08 21:04:08 +08:00
parent 8ebfc31fce
commit b640788033

View File

@ -47,18 +47,15 @@ public class EquipmentEditor extends Editor {
public void onPlayerChat(final AsyncPlayerChatEvent event) { public void onPlayerChat(final AsyncPlayerChatEvent event) {
if (!event.getPlayer().equals(player)) if (!event.getPlayer().equals(player))
return; return;
EquipmentSlot slot = null; EquipmentSlot slot = Util.matchEnum(EquipmentSlot.values(), event.getMessage());
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;
}
if (slot == null) { if (slot == null) {
return; 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; final EquipmentSlot finalSlot = slot;
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override @Override