Last active
April 2, 2024 08:33
-
-
Save Densamisten/22bdf1b79361c77c893f0cbf11b67e8d to your computer and use it in GitHub Desktop.
Overwrites console text limit by pasting the clipboard directly to the console. Usage /vsay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.densamisten.command; | |
| import com.mojang.brigadier.CommandDispatcher; | |
| import com.mojang.brigadier.context.CommandContext; | |
| import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | |
| import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; | |
| import net.minecraft.client.util.Clipboard; | |
| import net.minecraft.command.argument.ColorArgumentType; | |
| import net.minecraft.text.Text; | |
| import net.minecraft.util.Formatting; | |
| import org.lwjgl.glfw.GLFW; | |
| import org.lwjgl.glfw.GLFWErrorCallback; | |
| import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; | |
| import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; | |
| public class VerboseSayCommand { | |
| private static final Clipboard clipboardManager = new Clipboard(); | |
| public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) { | |
| dispatcher.register(literal("vsay") | |
| .executes(VerboseSayCommand::sendClipboardMessage)); | |
| } | |
| public static int sendClipboardMessage(CommandContext<FabricClientCommandSource> context) { | |
| String clipboardContents = clipboardManager.getClipboard(GLFW.glfwGetCurrentContext(), GLFWErrorCallback.createPrint(System.err)); | |
| Text clipboardText = Text.literal(clipboardContents); | |
| context.getSource().sendFeedback(clipboardText); | |
| return 1; // Return 1 to indicate successful execution | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.densamisten.troubleshootingmod.command; | |
| import com.mojang.blaze3d.platform.ClipboardManager; | |
| import com.mojang.brigadier.CommandDispatcher; | |
| import net.minecraft.ChatFormatting; | |
| import net.minecraft.client.Minecraft; | |
| import net.minecraft.commands.CommandSourceStack; | |
| import net.minecraft.commands.Commands; | |
| import net.minecraft.commands.arguments.ColorArgument; | |
| import net.minecraft.network.chat.Component; | |
| import net.minecraft.network.chat.OutgoingChatMessage; | |
| import net.minecraft.network.chat.PlayerChatMessage; | |
| import org.lwjgl.glfw.GLFW; | |
| import org.lwjgl.glfw.GLFWErrorCallback; | |
| public class VerboseSayCommand { | |
| private static final ClipboardManager clipboardManager = new ClipboardManager(); | |
| public VerboseSayCommand(CommandDispatcher<CommandSourceStack> dispatcher) { | |
| dispatcher.register(Commands.literal("vsay") | |
| .then(Commands.argument("color", ColorArgument.color()) | |
| .executes(context -> sendVerboseMessage(context.getSource(), ColorArgument.getColor(context, "color"))))); | |
| } | |
| // Our executing method | |
| private static int sendVerboseMessage(CommandSourceStack source, ChatFormatting color) { | |
| // Get the clipboard contents | |
| String clipboardContents = clipboardManager.getClipboard(GLFW.glfwGetCurrentContext(), GLFWErrorCallback.createPrint(System.err)); | |
| // Perform send message action along given style allowed with ChatFormatting | |
| source.sendSuccess(() -> Component.literal(clipboardContents).withStyle(color), false); | |
| // Return 1 for success | |
| return 1; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment