-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
CraftBukkit version 3563-Spigot-2183145-1e3bf58 (MC: 1.19.1) (Implementing API version 1.19.1-R0.1-SNAPSHOT)
-
Yes
When the list of the recipients is changed, the sent message is received as a system message on the client. Here's a minimal example that causes it.
import org.bukkit.Server; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatPreviewEvent; import org.jetbrains.annotations.NotNull; import java.util.stream.Collectors; public class DebugChatListener implements Listener { private final @NotNull Server server; public DebugChatListener(@NotNull Server server) { this.server = server; } private void HandleEvent(@NotNull AsyncPlayerChatEvent event) { event.getRecipients().clear(); event.getRecipients().addAll(server.getOnlinePlayers().stream() .filter(player -> player.getWorld() == event.getPlayer().getWorld() && player.getLocation().distance(event.getPlayer() .getLocation()) < 100) .collect(Collectors.toSet())); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void OnAsyncPlayerChat(@NotNull AsyncPlayerChatEvent event) { HandleEvent(event); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void OnAsyncPlayerChatPreview(@NotNull AsyncPlayerChatPreviewEvent event) { HandleEvent(event); } }