Add permission for local channel chat

This commit is contained in:
Josh Roy 2021-09-28 21:26:47 -04:00
parent 88c8ccd29b
commit 2f5c24d114
3 changed files with 26 additions and 14 deletions

View File

@ -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

View File

@ -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();

View File

@ -13,3 +13,6 @@ commands:
description: Toggles whether you are talking in shout mode
usage: /<command> [player] [on|off]
aliases: [etoggleshout]
permissions:
essentials.chat.local:
default: true