Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
replace gson with global gson
Browse files Browse the repository at this point in the history
  • Loading branch information
Paddyk45 committed Nov 8, 2023
1 parent c825e7a commit ac5b61b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/main/java/de/damcraft/serverseeker/DiscordAvatar.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.damcraft.serverseeker;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.mojang.blaze3d.systems.RenderSystem;
import de.damcraft.serverseeker.ssapi.responses.UserInfoResponse;
Expand All @@ -15,6 +14,8 @@
import java.io.InputStream;
import java.nio.ByteBuffer;

import static de.damcraft.serverseeker.ServerSeeker.gson;

public class DiscordAvatar extends Texture {
public DiscordAvatar(String url) {
BufferedImage avatar;
Expand All @@ -27,7 +28,7 @@ public DiscordAvatar(String url) {

String jsonResp = SmallHttp.post("https://api.serverseeker.net/user_info", params.toString());

UserInfoResponse userInfo = new Gson().fromJson(jsonResp, UserInfoResponse.class);
UserInfoResponse userInfo = gson.fromJson(jsonResp, UserInfoResponse.class);
if (userInfo.isError()) {
System.out.println("Error: " + userInfo.error);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.damcraft.serverseeker.gui;

import com.google.common.net.HostAndPort;
import com.google.gson.Gson;
import de.damcraft.serverseeker.ServerSeeker;
import de.damcraft.serverseeker.SmallHttp;
import de.damcraft.serverseeker.country.Country;
Expand All @@ -26,6 +25,8 @@

import java.util.List;

import static de.damcraft.serverseeker.ServerSeeker.gson;

public class FindNewServersScreen extends WindowScreen {
private int timer;
public WButton findButton;
Expand Down Expand Up @@ -293,7 +294,6 @@ public void initWidgets() {

MeteorExecutor.execute(() -> {
String jsonResp = SmallHttp.post("https://api.serverseeker.net/servers", request.json());
Gson gson = new Gson();

ServersResponse resp = gson.fromJson(jsonResp, ServersResponse.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.damcraft.serverseeker.gui;

import com.google.common.net.HostAndPort;
import com.google.gson.Gson;
import de.damcraft.serverseeker.SmallHttp;
import de.damcraft.serverseeker.ssapi.requests.WhereisRequest;
import de.damcraft.serverseeker.ssapi.responses.WhereisResponse;
Expand All @@ -25,6 +24,7 @@
import java.time.format.FormatStyle;
import java.util.List;

import static de.damcraft.serverseeker.ServerSeeker.gson;
import static meteordevelopment.meteorclient.MeteorClient.mc;

public class FindPlayerScreen extends WindowScreen {
Expand Down Expand Up @@ -86,7 +86,6 @@ public void initWidgets() {

String jsonResponse = SmallHttp.post("https://api.serverseeker.net/whereis", request.json());

Gson gson = new Gson();
WhereisResponse resp = gson.fromJson(jsonResponse, WhereisResponse.class);

// Set error message if there is one
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.damcraft.serverseeker.gui;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import de.damcraft.serverseeker.SmallHttp;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -19,6 +18,8 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import static de.damcraft.serverseeker.ServerSeeker.gson;

public class InstallMeteorScreen extends Screen {
public InstallMeteorScreen() {
super(Text.of("Meteor Client is not installed!"));
Expand Down Expand Up @@ -54,7 +55,7 @@ private void install() {
this.displayError("Failed to get install meteor automatically! Please install it manually.");
return;
}
Gson gson = new Gson();

JsonObject json = gson.fromJson(result, JsonObject.class);
String currentVersion = SharedConstants.getGameVersion().getName();
String stableVersion = json.get("mc_version").getAsString();
Expand Down

0 comments on commit ac5b61b

Please sign in to comment.