diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 516f78ed0..98ff5e7d8 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -833,8 +833,9 @@ noPlacePermission=\u00a74You do not have permission to place a block near that s noPotionEffectPerm=\u00a74You do not have permission to apply potion effect \u00a7c{0} \u00a74to this potion. noPowerTools=\u00a76You have no power tools assigned. notAcceptingPay=\u00a74{0} \u00a74is not accepting payment. -notAllowedToQuestion=\u00a74You are not authorized to use question. -notAllowedToShout=\u00a74You are not authorized to shout. +notAllowedToLocal=\u00a74You don't have permission to speak in local chat. +notAllowedToQuestion=\u00a74You don't have permission to use question. +notAllowedToShout=\u00a74You don't have permission to shout. notEnoughExperience=\u00a74You do not have enough experience. notEnoughMoney=\u00a74You do not have sufficient funds. notFlying=not flying diff --git a/EssentialsChat/src/main/java/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java b/EssentialsChat/src/main/java/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java index 1adbf2438..fc77e2341 100644 --- a/EssentialsChat/src/main/java/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java +++ b/EssentialsChat/src/main/java/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java @@ -43,21 +43,29 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer { final User user = chatStore.getUser(); chatStore.setRadius(radius); - if (event.getMessage().length() > 1 && chatStore.getType().length() > 0) { - final StringBuilder permission = new StringBuilder(); - permission.append("essentials.chat.").append(chatStore.getType()); - - if (user.isAuthorized(permission.toString())) { - if (event.getMessage().charAt(0) == ess.getSettings().getChatShout() || event.getMessage().charAt(0) == ess.getSettings().getChatQuestion()) { - event.setMessage(event.getMessage().substring(1)); + if (event.getMessage().length() > 1) { + if (chatStore.getType().isEmpty()) { + if (!user.isAuthorized("essentials.chat.local")) { + user.sendMessage(tl("notAllowedToLocal")); + event.setCancelled(true); + return; } - event.setFormat(tl(chatStore.getType() + "Format", event.getFormat())); + } else { + final StringBuilder permission = new StringBuilder(); + permission.append("essentials.chat.").append(chatStore.getType()); + + if (user.isAuthorized(permission.toString())) { + if (event.getMessage().charAt(0) == ess.getSettings().getChatShout() || event.getMessage().charAt(0) == ess.getSettings().getChatQuestion()) { + event.setMessage(event.getMessage().substring(1)); + } + event.setFormat(tl(chatStore.getType() + "Format", event.getFormat())); + return; + } + + user.sendMessage(tl("notAllowedTo" + chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH) + chatStore.getType().substring(1))); + event.setCancelled(true); return; } - - user.sendMessage(tl("notAllowedTo" + chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH) + chatStore.getType().substring(1))); - event.setCancelled(true); - return; } final Location loc = user.getLocation(); diff --git a/EssentialsChat/src/main/resources/plugin.yml b/EssentialsChat/src/main/resources/plugin.yml index 68ba61920..632644568 100644 --- a/EssentialsChat/src/main/resources/plugin.yml +++ b/EssentialsChat/src/main/resources/plugin.yml @@ -13,3 +13,6 @@ commands: description: Toggles whether you are talking in shout mode usage: / [player] [on|off] aliases: [etoggleshout] +permissions: + essentials.chat.local: + default: true