Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to using the hypixel-data dependency #653

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions hypixel-api-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
</properties>

<dependencies>
<dependency>
<groupId>net.hypixel</groupId>
<artifactId>hypixel-data</artifactId>
<version>0.1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.hypixel.api.adapters;

import com.google.gson.*;
import net.hypixel.api.data.type.GameType;
import net.hypixel.data.type.GameType;

import java.lang.reflect.Type;

Expand All @@ -19,12 +19,12 @@ public JsonElement serialize(GameType src, Type typeOfSrc, JsonSerializationCont
@Override
public GameType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber()) {
return GameType.fromId(json.getAsInt());
return GameType.getById(json.getAsInt()).orElse(null);
}

String raw = json.getAsString();
try {
return GameType.fromId(Integer.parseInt(raw));
return GameType.getById(Integer.parseInt(raw)).orElse(null);
} catch (NumberFormatException ignored) {
}

Expand All @@ -33,6 +33,11 @@ public GameType deserialize(JsonElement json, Type typeOfT, JsonDeserializationC
} catch (IllegalArgumentException ignored) {
}

try {
return GameType.getByDatabaseName(raw).orElse(null);
} catch (IllegalArgumentException ignored) {
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.hypixel.api.adapters;

import com.google.gson.*;
import net.hypixel.api.data.type.GameType;
import net.hypixel.api.data.type.ServerType;
import net.hypixel.data.type.GameType;
import net.hypixel.data.type.ServerType;

import java.lang.reflect.Type;

Expand All @@ -17,10 +17,10 @@ public JsonElement serialize(ServerType src, Type typeOfSrc, JsonSerializationCo
public ServerType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String raw = json.getAsString();
try {
return GameType.fromId(Integer.parseInt(raw));
return GameType.getById(Integer.parseInt(raw)).orElse(null);
} catch (NumberFormatException ignored) {
}
return ServerType.valueOf(raw);
return ServerType.valueOf(raw).orElse(null);
}

}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.hypixel.api.reply;

import net.hypixel.api.data.type.GameType;
import net.hypixel.data.type.GameType;

import java.time.ZonedDateTime;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.hypixel.api.reply;

import com.google.gson.annotations.SerializedName;
import net.hypixel.api.data.type.GameType;
import net.hypixel.api.data.type.GuildAchievement;
import net.hypixel.api.reply.PlayerReply.Player;
import net.hypixel.api.util.Banner;
import net.hypixel.data.type.GameType;

import java.time.LocalDate;
import java.time.ZonedDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.hypixel.api.reply;

import net.hypixel.api.data.type.GameType;
import net.hypixel.data.type.GameType;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import net.hypixel.api.HypixelAPI;
import net.hypixel.api.data.type.GameType;
import net.hypixel.api.pets.IPetRepository;
import net.hypixel.api.pets.PetStats;
import net.hypixel.api.pets.impl.compatibility.BackwardsCompatibilityPetRepositoryImpl;
import net.hypixel.api.util.ILeveling;
import net.hypixel.api.util.UnstableHypixelObject;
import net.hypixel.api.util.Utilities;
import net.hypixel.data.type.GameType;

import java.lang.reflect.Type;
import java.time.ZonedDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.hypixel.api.reply;

import net.hypixel.api.data.type.GameType;
import net.hypixel.data.type.GameType;

import java.time.ZonedDateTime;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.hypixel.api.reply;

import com.google.gson.annotations.SerializedName;
import net.hypixel.api.data.type.ServerType;
import net.hypixel.data.type.ServerType;

public class StatusReply extends RateLimitedReply {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.hypixel.api.adapters.*;
import net.hypixel.api.data.type.GameType;
import net.hypixel.api.data.type.ServerType;
import net.hypixel.api.reply.BoostersReply;
import net.hypixel.api.reply.PlayerReply.Player;
import net.hypixel.data.type.GameType;
import net.hypixel.data.type.ServerType;

import java.time.Instant;
import java.time.ZoneId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package net.hypixel.api.example;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ExecutionException;
import net.hypixel.api.HypixelAPI;
import net.hypixel.api.data.type.GameType;
import net.hypixel.api.data.type.GuildAchievement;
import net.hypixel.api.reply.GuildReply;
import net.hypixel.api.reply.GuildReply.Guild;
import net.hypixel.api.reply.GuildReply.Guild.Member;
import net.hypixel.api.reply.GuildReply.Guild.Rank;
import net.hypixel.api.util.IGuildLeveling;
import net.hypixel.data.type.GameType;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
* A sample app for demonstrating how guilds can be fetched & used from the Hypixel API.
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
</repository>
</distributionManagement>

<repositories>
<repository>
<id>Hypixel</id>
<url>https://repo.hypixel.net/repository/Hypixel/</url>
</repository>
</repositories>

<build>
<plugins>
<plugin>
Expand Down