|
|
|
@ -17,20 +17,21 @@ public class ChatListener implements Listener {
|
|
|
|
|
String message = e.getMessage(); |
|
|
|
|
Player player = e.getPlayer(); |
|
|
|
|
String formated = ChatUtil.translateColorCodes(formatLocal); |
|
|
|
|
Chat chat = message.startsWith("!") ? Chat.LOCAL : Chat.GLOBAL; |
|
|
|
|
Chat chat = message.startsWith("!") ? Chat.GLOBAL : Chat.LOCAL; |
|
|
|
|
|
|
|
|
|
if (chat == Chat.LOCAL) { |
|
|
|
|
Bukkit.getOnlinePlayers().stream().filter((p) -> (p.getLocation().distance(player.getLocation()) <= 100)).forEachOrdered((p) -> { |
|
|
|
|
e.getRecipients().clear(); |
|
|
|
|
Bukkit.getOnlinePlayers().stream().filter((p) -> (p.getLocation().distance(player.getLocation()) <= 100)).forEachOrdered((p) -> { |
|
|
|
|
e.getRecipients().add(p); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
message = message.replaceFirst("!", ""); |
|
|
|
|
e.setMessage(message.replaceFirst("!", "")); |
|
|
|
|
formated = ChatUtil.translateColorCodes(formatGlobl); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
formated = formated.replace("%chatPrefix", chat.getPrefix()); |
|
|
|
|
formated = formated.replace(" ", ""); |
|
|
|
|
formated = formated.replace(":", ": "); |
|
|
|
|
formated = formated.replace("%player", player.getDisplayName()); |
|
|
|
|
formated = formated.replace("%message", message); |
|
|
|
|
formated = formated.replace("%message", "%2$s").replace("%player", "%1$s"); |
|
|
|
|
System.out.println(formated); |
|
|
|
|
e.setFormat(formated); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|