Fix toggleshout causing issues with question/local chat

This commit is contained in:
Josh Roy 2021-09-29 21:05:12 -04:00
parent 4bf4bd432a
commit cbb012853c
2 changed files with 12 additions and 2 deletions

View File

@ -36,10 +36,15 @@ public abstract class EssentialsChatPlayer implements Listener {
}
final char prefix = message.charAt(0);
if (prefix == ess.getSettings().getChatShout() || user.isToggleShout()) {
if (prefix == ess.getSettings().getChatShout()) {
if (user.isToggleShout()) {
return "";
}
return message.length() > 1 ? "shout" : "";
} else if (ess.getSettings().isChatQuestionEnabled() && prefix == ess.getSettings().getChatQuestion()) {
return message.length() > 1 ? "question" : "";
} else if (user.isToggleShout()) {
return message.length() > 1 ? "shout" : "";
} else {
return "";
}

View File

@ -50,12 +50,17 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer {
event.setCancelled(true);
return;
}
if (user.isToggleShout() && event.getMessage().length() > 1 && event.getMessage().charAt(0) == ess.getSettings().getChatShout()) {
event.setMessage(event.getMessage().substring(1));
}
event.getRecipients().removeIf(player -> !ess.getUser(player).isAuthorized("essentials.chat.receive.local"));
} else {
final String permission = "essentials.chat." + chatStore.getType();
if (user.isAuthorized(permission)) {
if (event.getMessage().charAt(0) == ess.getSettings().getChatShout() || event.getMessage().charAt(0) == ess.getSettings().getChatQuestion()) {
if (event.getMessage().charAt(0) == ess.getSettings().getChatShout() || (event.getMessage().charAt(0) == ess.getSettings().getChatQuestion() && ess.getSettings().isChatQuestionEnabled())) {
event.setMessage(event.getMessage().substring(1));
}
event.setFormat(tl(chatStore.getType() + "Format", event.getFormat()));