Quick fix for people not being able to send/receive Translated messages. (#868)

Thanks to 7ate9.
This commit is contained in:
Ian William O'Neill
2019-07-03 19:53:44 +01:00
committed by Ganom
parent 781a1cc2a4
commit 9e7d124d49
2 changed files with 9 additions and 12 deletions

View File

@@ -284,11 +284,6 @@
<artifactId>asm-all</artifactId> <artifactId>asm-all</artifactId>
<version>6.0_BETA</version> <version>6.0_BETA</version>
</dependency> </dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -1,6 +1,7 @@
package net.runelite.client.plugins.chattranslation; package net.runelite.client.plugins.chattranslation;
import org.json.JSONArray; import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@@ -33,14 +34,15 @@ public class Translator
return parseResult(response.toString()); return parseResult(response.toString());
} }
private String parseResult(String inputJson) throws Exception private String parseResult(String inputJson)
{ {
//TODO: find a way to do this using google.gson String result;
JSONArray jsonArray = new JSONArray(inputJson); JsonArray jsonArray = new JsonParser().parse(inputJson).getAsJsonArray();
JSONArray jsonArray2 = (JSONArray) jsonArray.get(0); JsonArray jsonArray2 = jsonArray.get(0).getAsJsonArray();
JSONArray jsonArray3 = (JSONArray) jsonArray2.get(0); JsonArray jsonArray3 = jsonArray2.get(0).getAsJsonArray();
result = jsonArray3.get(0).toString();
return jsonArray3.get(0).toString(); return result.substring(1, result.length() - 1);
} }
} }