Issue with Join Event
Hi, i cant seem to suppress the default join message whatever i try. Another plugin seems to use the same evnt (AddPlayerToWorldEvent). https://github.com/rmaafs/WelcomeTale/blob/2a6feb3768d328e71e621fec9983acad070ea1ce/src/main/java/com/rmaafs/welcometale/listeners/PlayerEvents.java#L35
and according to the docs it should be possible too.
Here's what i tried:
import { type PlayerConnectEvent, type AddPlayerToWorldEvent, EventListener, Colors } from "@hytalejs.com/core";
export class PlayerConnectHandler {
@EventListener("PlayerConnectEvent")
onPlayerJoin(event: PlayerConnectEvent): void {
const player = event.getPlayer();
const playerRef = event.getPlayerRef();
const worldName = event.getWorld().getName();
logger.info("Player " + playerRef.getUsername() + " joined world: " + worldName);
player.sendMessage(
Message.raw("Welcome to the server, " + playerRef.getUsername() + "!")
.color(Colors.GREEN)
.bold(true),
);
player.sendMessage(Message.raw("Players online: " + Universe.get().getPlayerCount()).color(Colors.GOLD));
Universe.get().sendMessage(Message.raw(playerRef.getUsername() + " has joined the server!"));
}
@EventListener("AddPlayerToWorldEvent")
onPlayerConnect(event: AddPlayerToWorldEvent): void {
event.shouldBroadcastJoinMessage(false);
event.setBroadcastJoinMessage(false);
event.setCancelled(true);
}
}
i'm not sure if this is the case, but i recently encountered the same issue. the documentation indicated that something was possible, but it didn't work in the code. it turns out that the documentation updates with the live branch (main), but that doesn't mean it's available yet, as it has to be released. for example, the last change was made 11 hours ago, but the latest release was last week. therefore, many apis that appear in the documentation are not available yet.