Mojira Archive
MC-127672

Open any files on user's PC

So, in 1.8.8 (maybe wrong?) raw messages was added. It allowed many developers to involve click events in chat, such as: running commands, opening links, command suggestions, etc.
But, everybody maybe did not notice that Minecraft is using using AWT's Desktop class to browse links/URIs. So, If we set the protocol to file:// instead of http:// or https://, we will be able to run an program on client's PC, open files and so on.
Good think is that AWT does not allow us (as It on Windows, don't know if Unix does not support that) to pass the program arguments into the URI.For example, Spigot/Bukkit API:

		Bukkit.getScheduler().runTaskLater(ApiPlugin.instance(), () ->
		{
			p.spigot().sendMessage(
					new ComponentBuilder("Click me").event(new ClickEvent(Action.OPEN_URL, "file://C:/Windows/system32/cmd.exe")).create()
			);
		}, 20L);

This code will send the message w/ click event inside of it. And, if player will click on it - it will open commpoand prompot.

Cannot Reproduce

__xDark

2018-03-27, 11:00 AM

2018-03-27, 07:12 PM

2018-03-27, 01:25 PM

1

2

Unconfirmed

Minecraft 1.12.2

-