Skip to content

Commit

Permalink
Fixed folder & file open options
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTas committed Oct 25, 2023
1 parent c5524d3 commit 1128a78
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
23 changes: 19 additions & 4 deletions src/main/java/dev/stardust/modules/ChatSigns.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,28 @@ private void openBlacklistFile() {
Path meteorFolder = FabricLoader.getInstance().getGameDir().resolve("meteor-client");
File blackListFile = meteorFolder.resolve("chatsigns-blacklist.txt").toFile();

EventQueue.invokeLater(() -> {
if (Desktop.isDesktopSupported()) {
EventQueue.invokeLater(() -> {
try {
Desktop.getDesktop().open(blackListFile);
}catch (IOException err) {
Stardust.LOG.error("[Stardust] Failed to open chatsigns-blacklist.txt - "+err);
}
});
} else {
try {
Desktop.getDesktop().open(blackListFile);
}catch (IOException err) {
Runtime runtime = Runtime.getRuntime();
if (System.getenv("OS") == null) return;
if (System.getenv("OS").contains("Windows")) {
runtime.exec("rundll32 url.dll, FileProtocolHandler " + blackListFile.getAbsolutePath());
}else {
runtime.exec("xdg-open " + blackListFile.getAbsolutePath());
}
} catch (IOException err) {
Stardust.LOG.error("[Stardust] Failed to open chatsigns-blacklist.txt - "+err);
if (mc.player != null) mc.player.sendMessage(Text.of("§8<"+StardustUtil.rCC()+"✨§8> §4§oFailed to open chatsigns-blacklist.txt§7."));
}
});
}

this.openBlacklistFile.set(false);
}
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/dev/stardust/modules/SignatureSign.java
Original file line number Diff line number Diff line change
Expand Up @@ -716,13 +716,29 @@ private void openMeteorFolder() {
Path meteorFolder = FabricLoader.getInstance().getGameDir().resolve("meteor-client");
File folder = meteorFolder.toFile();

EventQueue.invokeLater(() -> {
if (Desktop.isDesktopSupported()) {
EventQueue.invokeLater(() -> {
try {
Desktop.getDesktop().open(folder);
}catch (IOException err) {
Stardust.LOG.error("[Stardust] Failed to open meteor-client folder - "+err);
}
});
} else {
try {
Desktop.getDesktop().open(folder);
}catch (IOException err) {
Runtime runtime = Runtime.getRuntime();
if (System.getenv("OS") == null) return;
if (System.getenv("OS").contains("Windows")) {
runtime.exec("rundll32 url.dll, FileProtocolHandler " + folder.getAbsolutePath());
} else {
runtime.exec("xdg-open " + folder.getAbsolutePath());
}
} catch (IOException err) {
Stardust.LOG.error("[Stardust] Failed to open meteor-client folder - "+err);
if (mc.player != null) mc.player.sendMessage(Text.of("§8<"+StardustUtil.rCC()+"✨§8> §4§oFailed to open meteor-client folder§7."));
}
});

}

this.openFolder.set(false);
}
Expand Down

0 comments on commit 1128a78

Please sign in to comment.