Skip to content

Commit

Permalink
Make GSON more optional on updater (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Jan 10, 2017
1 parent 115d4af commit 21a086d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/ch/njol/skript/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public class Updater {

public static final String RELEASES_URL = "https://api.github.com/repos/bensku/Skript/releases";

private static final Gson gson = new Gson();
@Nullable
private static Gson gson;

final static AtomicReference<String> error = new AtomicReference<>();
public static volatile UpdateState state = UpdateState.NOT_STARTED;
Expand Down Expand Up @@ -161,6 +162,9 @@ public static List<ResponseEntry> deserialize(String str) {
assert str != null : "Cannot deserialize null string";
@SuppressWarnings("serial")
Type listType = new TypeToken<List<ResponseEntry>>() {}.getType();
if (gson == null) // Initialize GSON if it wasn't initialized before
gson = new Gson();
assert gson != null;
List<ResponseEntry> responses = gson.fromJson(str, listType);
assert responses != null;

Expand Down

0 comments on commit 21a086d

Please sign in to comment.