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); 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" : ""; return message.length() > 1 ? "shout" : "";
} else if (ess.getSettings().isChatQuestionEnabled() && prefix == ess.getSettings().getChatQuestion()) { } else if (ess.getSettings().isChatQuestionEnabled() && prefix == ess.getSettings().getChatQuestion()) {
return message.length() > 1 ? "question" : ""; return message.length() > 1 ? "question" : "";
} else if (user.isToggleShout()) {
return message.length() > 1 ? "shout" : "";
} else { } else {
return ""; return "";
} }

View File

@ -50,12 +50,17 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer {
event.setCancelled(true); event.setCancelled(true);
return; 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")); event.getRecipients().removeIf(player -> !ess.getUser(player).isAuthorized("essentials.chat.receive.local"));
} else { } else {
final String permission = "essentials.chat." + chatStore.getType(); final String permission = "essentials.chat." + chatStore.getType();
if (user.isAuthorized(permission)) { 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.setMessage(event.getMessage().substring(1));
} }
event.setFormat(tl(chatStore.getType() + "Format", event.getFormat())); event.setFormat(tl(chatStore.getType() + "Format", event.getFormat()));