mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
the rot rottens
Fixes Desktop.browse not working on Linux
This commit is contained in:
parent
1043470ca6
commit
41140ecf7c
@ -3,10 +3,13 @@ package com.hbm.inventory.gui;
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@ -37,6 +40,17 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
this.autocal = autocal;
|
||||
}
|
||||
|
||||
private void browse(URI uri) throws IOException {
|
||||
// workaround for Java not supporting all platforms, mostly for Linux
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(uri);
|
||||
} else {
|
||||
if (Runtime.getRuntime().exec(new String[] { "which", "xdg-open" }).getInputStream().read() != -1) {
|
||||
Runtime.getRuntime().exec(new String[] { "xdg-open", uri.toString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
@ -71,7 +85,7 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
if(!uploadFolder.exists()) uploadFolder.mkdir();
|
||||
if(!script.exists()) script.createNewFile();
|
||||
script.setExecutable(false);
|
||||
Desktop.getDesktop().browse(script.toURI());
|
||||
browse(script.toURI());
|
||||
} catch(Throwable ex) { MainRegistry.logger.error("Couldn't open link", ex); }
|
||||
}
|
||||
|
||||
@ -89,7 +103,7 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
printer.close();
|
||||
} catch(Throwable e) { }
|
||||
}
|
||||
Desktop.getDesktop().browse(doc.toURI());
|
||||
browse(doc.toURI());
|
||||
} catch(Throwable ex) { MainRegistry.logger.error("Couldn't open link", ex); }
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user