Removed unnecessary json dependency.

This commit is contained in:
Jeremy Wood 2019-01-31 22:09:09 -05:00
parent 8b358b0955
commit 6ebc1188e8
2 changed files with 15 additions and 27 deletions

View File

@ -327,12 +327,6 @@
<artifactId>Logging</artifactId>
<version>1.1.1</version>
</dependency>
<!-- JSON dependency -->
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.8</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>

View File

@ -1,7 +1,8 @@
package com.onarandombox.MultiverseCore.utils.webpaste;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import java.io.BufferedReader;
import java.io.IOException;
@ -30,24 +31,18 @@ public class GithubPasteService implements PasteService {
@Override
public String encodeData(Map<String, String> files) {
JSONObject root = new JSONObject();
String result = "";
try {
root.put("description", "Multiverse-Core Debug Info");
root.put("public", !this.isPrivate);
JSONObject fileList = new JSONObject();
for (Map.Entry<String, String> entry : files.entrySet())
{
JSONObject fileObject = new JSONObject();
fileObject.put("content", entry.getValue());
fileList.put(entry.getKey(), fileObject);
}
root.put("files", fileList);
result = root.toString();
} catch (JSONException e) {
e.printStackTrace();
JsonObject root = new JsonObject();
root.add("description", new JsonPrimitive("Multiverse-Core Debug Info"));
root.add("public", new JsonPrimitive(!this.isPrivate));
JsonObject fileList = new JsonObject();
for (Map.Entry<String, String> entry : files.entrySet())
{
JsonObject fileObject = new JsonObject();
fileObject.add("content", new JsonPrimitive(entry.getValue()));
fileList.add(entry.getKey(), fileObject);
}
return result;
root.add("files", fileList);
return root.toString();
}
@Override
@ -80,8 +75,7 @@ public class GithubPasteService implements PasteService {
while ((line = rd.readLine()) != null) {
responseString.append(line);
}
JSONObject response = new JSONObject(responseString.toString());
return response.get("html_url").toString();
return new JsonParser().parse(responseString.toString()).getAsJsonObject().get("html_url").getAsString();
} catch (Exception e) {
throw new PasteFailedException(e);
} finally {