Sending a server message to all clients #3536
Unanswered
AltAccountForNobody
asked this question in
Mod Dev Support
Replies: 1 comment
-
If you need access to the current ServerLifecycleEvents.SERVER_STARTING.register(server -> {
MyMod.server = server;
});
ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
MyMod.server = null;
}); Elsewhere, you can reference if (MyMod.server != null) {
for (ServerPlayerEntity player : MyMod.server.getPlayerManager().getPlayerList()) {
player.sendMessage(Text.literal("Hello, world!"));
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I've been stumped attempting to send a message to all clients connected to a server in my mod because I can't figure out how to access the list of players in a normal function. Is there a way to send a message to all players connected to a server with the mod installed without access to the MinecraftServer instance, or is there a way to obtain the MinecraftServer instance? Any help is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions