From 3dc77492c0fd747dd0e3df7cbd3d389fb5db14f3 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 7 Nov 2018 17:20:30 +0100 Subject: [PATCH] bugfix --- G-Earth/src/main/java/gearth/misc/Cacher.java | 7 ++++++- .../memory/habboclient/windows/WindowsHabboClient.java | 5 +++-- .../ui/extensions/executer/NormalExtensionRunner.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/G-Earth/src/main/java/gearth/misc/Cacher.java b/G-Earth/src/main/java/gearth/misc/Cacher.java index 2866e0e..5538ee1 100644 --- a/G-Earth/src/main/java/gearth/misc/Cacher.java +++ b/G-Earth/src/main/java/gearth/misc/Cacher.java @@ -7,6 +7,7 @@ import org.json.JSONObject; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.net.URISyntaxException; import java.nio.file.Files; import java.util.List; @@ -18,7 +19,11 @@ public class Cacher { private static final String CACHE_FILENAME = "cache.json"; private static String getCacheDir() { - return new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); + try { + return new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); + } catch (URISyntaxException e) { + return null; + } } private static boolean cacheFileExists() { diff --git a/G-Earth/src/main/java/gearth/protocol/memory/habboclient/windows/WindowsHabboClient.java b/G-Earth/src/main/java/gearth/protocol/memory/habboclient/windows/WindowsHabboClient.java index dcd4d42..eafa8e3 100644 --- a/G-Earth/src/main/java/gearth/protocol/memory/habboclient/windows/WindowsHabboClient.java +++ b/G-Earth/src/main/java/gearth/protocol/memory/habboclient/windows/WindowsHabboClient.java @@ -79,10 +79,11 @@ public class WindowsHabboClient extends HabboClient { } } + String g_winmem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "\\G-WinMem.exe"; if (!useCache) - pb = new ProcessBuilder(new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "\\G-WinMem.exe", hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort())); + pb = new ProcessBuilder(g_winmem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort())); else - pb = new ProcessBuilder(new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "\\G-WinMem.exe", hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort()), "-c" + joiner.toString()); + pb = new ProcessBuilder(g_winmem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort()), "-c" + joiner.toString()); Process p = pb.start(); diff --git a/G-Earth/src/main/java/gearth/ui/extensions/executer/NormalExtensionRunner.java b/G-Earth/src/main/java/gearth/ui/extensions/executer/NormalExtensionRunner.java index a1a49b1..2d9bcfe 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/executer/NormalExtensionRunner.java +++ b/G-Earth/src/main/java/gearth/ui/extensions/executer/NormalExtensionRunner.java @@ -20,7 +20,7 @@ public class NormalExtensionRunner implements ExtensionRunner { static { String value; try { - value = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParent(); + value = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); } catch (URISyntaxException e) { value = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(); e.printStackTrace();