Player player = event.getPlayer();
String worldName = player.getWorld().getName();
PermissionUser user = PermissionsEx.getPermissionManager().getUser(player);
if (user == null) {
return;
}
String message = user.getOption(this.optionMessageFormat, worldName, messageFormat);
boolean localChat = user.getOptionBoolean(this.optionRangedMode, worldName, rangedMode);
String chatMessage = event.getMessage();
if (chatMessage.startsWith("!") && user.has("chatmanager.chat.global", worldName)) {
localChat = false;
chatMessage = chatMessage.substring(1);
message = user.getOption(this.optionGlobalMessageFormat, worldName, globalMessageFormat);
}
message = this.translateColorCodes(message);
chatMessage = this.translateColorCodes(chatMessage, user, worldName);
message = message.replace("%message", "%2$s").replace("%displayname", "%1$s");
message = this.replacePlayerPlaceholders(player, message);
message = this.replaceTime(message);
event.setFormat(message);
event.setMessage(chatMessage);
if (localChat) {
double range = user.getOptionDouble(this.optionChatRange, worldName, chatRange);
event.getRecipients().clear();
event.getRecipients().addAll(this.getLocalRecipients(player, message, range));
}
}