raynerepic

Make me a mod in donut smp 26.2 java message a random person that does not have the inly accepts messages from friends or followed players by saying /msg random

Kodari AI
KodariOct 31 at 7:59 am 1
RandomMessenger
A Minecraft Fabric mod for version 26.2 that adds a "/msg random" command. When executed, the mod selects a random online player who does not have the "only accepts messages from friends or followed players" privacy setting enabled. The mod then opens a private message channel between the sender and that random player, allowing them to chat directly. The command filters out players with restricted messaging settings and ensures the random target is not the sender themselves. The mod integrates with the vanilla messaging system, displaying the message in the standard private message format with the sender's and recipient's names. It provides a fun and spontaneous way to connect with other players on the server, encouraging social interaction and discovery of new friends. The mod is lightweight, client-side compatible, and works seamlessly with existing chat features.

I’ll add a client-side /msg random <message> command that picks an online player and lets Donut SMP enforce its DM privacy settings.

Created a client-side Fabric 26.2 mod with /msg random <message>. It picks a random online player other than you and sends the message; regular /msg <player> <message> commands are forwarded normally.

The mod can’t see Donut SMP’s friend/follow-only DM setting, so it can’t guarantee the random player accepts messages. The server will enforce that setting and may reject the message.

raynerepic

Crashed my game

Kodari AI
KodariOct 31 at 8:04 am 1

Please attach the crash report from .minecraft/crash-reports. If there isn’t one, send .minecraft/logs/latest.log from the crash. The Caused by section should identify what needs fixing; I can’t safely pinpoint the cause from the mod code alone.

raynerepic

Its too long file too big

Kodari AI
KodariOct 31 at 8:05 am 1

No need to send the whole file. Open latest.log, search for Caused by:, and paste that line plus the next 10–20 lines. If there’s no such line, paste the last 30 lines of the log.

raynerepic

Whwre is .latest log

Kodari AI
KodariOct 31 at 8:06 am 1

The file is named latest.log—there’s no dot before latest.

On Windows, press Win + R, type %appdata%\.minecraft\logs, and press Enter. Open latest.log in that folder. Paste the last 30 lines here.

raynerepic

I dont have win on keyboard

Kodari AI
KodariOct 31 at 8:06 am 1

No Windows key needed: open File Explorer, click the address bar at the top, type %appdata%\.minecraft\logs, and press Enter. Open latest.log.

raynerepic

How do i find the exact line caused by in such a long long text

Kodari AI
KodariOct 31 at 8:10 am 1

Open latest.log in Notepad, press Ctrl + F, type Caused by:, then press Enter. If it finds a match, copy that line and about 10 lines below it and paste them here.

If it finds nothing, press Ctrl + End and copy the last 20–30 lines instead.

raynerepic

Chatgpt just said this the file is too long to sedn to u so this is summary

📎 1 file 1,550 chars
📄
pasted-code-1793434653112.txt
txt 30 lines
▶
Your Minecraft crash is caused by a recursive command loop in the RandomDM mod, not Minecraft itself.

The important part of your crash report is:
java.lang.StackOverflowError: keyPressed event handler

at com.kodari.randomdm.RandomDmClient.forwardMessageCommand(RandomDmClient.java:63)
at com.kodari.randomdm.RandomDmClient.lambda$onInitializeClient$3(RandomDmClient.java:28)


What is happening?
Your RandomDM mod appears to be repeatedly sending a command through Minecraft's command system.

The sequence is:
1. You press a key or send a message.
2. RandomDM intercepts the command.
3. It calls forwardMessageCommand() to forward the message.
4. Minecraft processes the forwarded command.
5. RandomDM intercepts that command again.
6. The process repeats endlessly.
Eventually, Minecraft runs out of available stack space and crashes with StackOverflowError.
How to fix it
Try these steps in order:
1. Disable RandomDM temporarily. Remove its .jar file from your Minecraft mods folder.
2. Launch Minecraft again and test whether the crash disappears.
3. Check whether you have the latest compatible version of RandomDM.
4. If you're the developer of RandomDM, inspect RandomDmClient.java, particularly lines 28 and 63.
If you're developing RandomDM
The likely problem is that your forwarding function calls sendCommand(), which triggers the same command interception callback again.

You'll need to prevent forwarded commands from being intercepted a second time. For example, use a guard to distinguish original commands from forwarded commands.
Kodari AI
KodariOct 31 at 8:23 am 1

Fixed the recursive forwarding: the client /msg command no longer catches and re-sends every other /msg command. /msg random <message> still picks a player, while ordinary /msg <player> <message> can pass through to the server.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 129
src/client/java/com/kodari/randomdm/RandomDmClient.java
package com.kodari.randomdm;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.arguments.StringArgumentType;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.ClientCommands;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.network.chat.Component;

public class RandomDmClient implements ClientModInitializer {
	@Override
	public void onInitializeClient() {
		ClientCommandRegistrationCallback.EVENT.register((dispatcher, buildContext) ->
			dispatcher.register(ClientCommands.literal("msg")
				.then(ClientCommands.literal("random")
					.then(ClientCommands.argument("message", StringArgumentType.greedyString())
						.executes(context -> sendRandomMessage(context))))
			)
		);
	}

	private static int sendRandomMessage(CommandContext<FabricClientCommandSource> context) {
		FabricClientCommandSource source = context.getSource();
		ClientPacketListener connection = getConnection(source);
		if (connection == null) {
			return 0;
		}

		List<String> targets = connection.getOnlinePlayers().stream()
			.map(PlayerInfo -> PlayerInfo.getProfile().name())
			.filter(name -> !name.equals(connection.getLocalGameProfile().name()))
			.toList();
		if (targets.isEmpty()) {
			source.sendFeedback(Component.literal("No other online players are available."));
			return 0;
		}

		String target = targets.get(ThreadLocalRandom.current().nextInt(targets.size()));
		String message = StringArgumentType.getString(context, "message");
		connection.sendCommand("msg " + target + " " + message);
		source.sendFeedback(Component.literal("Sent a message to " + target + "."));
		return Command.SINGLE_SUCCESS;
	}

	private static ClientPacketListener getConnection(FabricClientCommandSource source) {
		ClientPacketListener connection = source.getClient().getConnection();
		if (connection == null) {
			source.sendFeedback(Component.literal("You must be connected to a server."));
		}
		return connection;
	}
}