diff --git a/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java b/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java index 42db2ae..0f18e46 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java +++ b/src/main/java/land/chipmunk/chipmunkmod/commands/SayCommand.java @@ -3,14 +3,12 @@ package land.chipmunk.chipmunkmod.commands; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; - -import static com.mojang.brigadier.arguments.StringArgumentType.getString; -import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; -import static land.chipmunk.chipmunkmod.command.CommandManager.argument; import static land.chipmunk.chipmunkmod.command.CommandManager.literal; +import static land.chipmunk.chipmunkmod.command.CommandManager.argument; +import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; +import static com.mojang.brigadier.arguments.StringArgumentType.getString; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.text.Text; public class SayCommand { public static void register (CommandDispatcher dispatcher) { @@ -18,15 +16,14 @@ public class SayCommand { literal("say") .then( argument("message", greedyString()) - .executes(m -> say(m)) + .executes(SayCommand::say) ) ); } public static int say (CommandContext context) { - final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler(); - - networkHandler.sendChatMessage(getString(context, "message")); + final FabricClientCommandSource source = context.getSource(); + source.getClient().getNetworkHandler().sendChatMessage(getString(context, "message")); return Command.SINGLE_SUCCESS; }