Wiki linking doesn't work on some Linux machines
natronium opened this issue · 1 comments
Java's awt.Desktop#browse
doesn't seem to play nice with linux setups that aren't "whatever ubuntu's doing". The regular Minecraft experience works around Java's jankiness by offering a "copy to clipboard" option when clicking on links in chat.
It looks like net.minecraft.client.gui.GuiConfirmOpenLink
is the class that's responsible for the regular minecraft experience. I'm not at all familiar with minecraft modding, or minecraft's guts, otherwise I would've submitted an actual PR, but it looks like you'd just need to do something like:
GuiYesNoCallback yesNoCallback = new GuiYesNoCallback{
public void confirmClicked(boolean yes, int id){
if(yes){
try {
Desktop.getDesktop().browse(new URI(url));
} catch(Exception e) {
e.printStackTrace();
}
}
}
};
Minecraft.getMinecraft().displayGuiScreen(new GuiConfirmOpenLink(yesNoCallback, url, 0, true));
If you want to avoid using the Minecraft UI for this, the Accepted Stack Overflow Answer™ seems to be something along the lines of "if (linux) {exec("xdg-open " + url)}
".