Skip to content

Information configuration #679

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.java]
ij_java_imports_layout = *,|,javax.**,java.**,|,$*

ij_java_use_single_class_imports = true

ij_java_class_count_to_use_import_on_demand = 999999999
ij_java_names_count_to_use_import_on_demand = 999999999
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
target
Example/target
Website/javadocs
hypixel-api-example/src/main/resources/config.properties
18 changes: 16 additions & 2 deletions hypixel-api-core/src/main/java/net/hypixel/api/HypixelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@
import net.hypixel.api.http.HypixelHttpResponse;
import net.hypixel.api.pets.IPetRepository;
import net.hypixel.api.pets.impl.PetRepositoryImpl;
import net.hypixel.api.reply.*;
import net.hypixel.api.reply.skyblock.*;
import net.hypixel.api.reply.AbstractReply;
import net.hypixel.api.reply.BoostersReply;
import net.hypixel.api.reply.CountsReply;
import net.hypixel.api.reply.GuildReply;
import net.hypixel.api.reply.LeaderboardsReply;
import net.hypixel.api.reply.PlayerReply;
import net.hypixel.api.reply.PunishmentStatsReply;
import net.hypixel.api.reply.RateLimitedReply;
import net.hypixel.api.reply.RecentGamesReply;
import net.hypixel.api.reply.ResourceReply;
import net.hypixel.api.reply.StatusReply;
import net.hypixel.api.reply.skyblock.SkyBlockAuctionsReply;
import net.hypixel.api.reply.skyblock.SkyBlockBazaarReply;
import net.hypixel.api.reply.skyblock.SkyBlockNewsReply;
import net.hypixel.api.reply.skyblock.SkyBlockProfileReply;
import net.hypixel.api.reply.skyblock.SkyBlockProfilesReply;
import net.hypixel.api.reply.skyblock.bingo.SkyBlockBingoDataReply;
import net.hypixel.api.reply.skyblock.firesales.SkyBlockFireSalesReply;
import net.hypixel.api.util.PropertyFilter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package net.hypixel.api.adapters;

import com.google.gson.*;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.hypixel.api.util.Utilities;

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

import com.google.gson.*;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.hypixel.api.data.type.GameType;

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

import com.google.gson.*;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.hypixel.api.data.type.GameType;
import net.hypixel.api.data.type.ServerType;

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

import com.google.gson.*;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.hypixel.api.util.Utilities;

import java.lang.reflect.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

public interface ServerType {

String name();

String getName();

static ServerType valueOf(String value) {
try {
return GameType.valueOf(value);
Expand All @@ -22,4 +18,8 @@ static ServerType valueOf(String value) {
return null;
}

String name();

String getName();

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

public class HTTPQueryParams {

public static HTTPQueryParams create() {
return new HTTPQueryParams();
}

private final Map<String, Object> params = new HashMap<>();

private HTTPQueryParams() {

}

public static HTTPQueryParams create() {
return new HTTPQueryParams();
}

public HTTPQueryParams add(String key, Object value) {
this.params.put(key, value);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface IPetRepository {
/**
* Gets if a player has unlocked the specified {@link IPetType}
*
* @param type the pet type the player must have
* @param type the pet type the player must have
* @param player the player to check against
* @return {@code true} if the player has unlocked the pet, otherwise {@code false}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PetStats(IPetRepository petRepository, Map<String, Map<String, Object>> p
*
* <b>Note:</b> If this returns {@code null}, it <b>doesn't</b> mean that the player hasn't unlocked the pet.
* What it does mean though, is that the player hasn't given any attributes nor a name to the pet
*
* <p>
* To check if a player has unlocked a pet, use {@link IPetRepository#hasPlayerUnlocked(IPetType, PlayerReply.Player)}
*
* @param type the pet type to retrieve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* The old and deprecated enum for the pet types
*
* @deprecated Consider using the {@link IPetRepository}
*/
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public int getPlayerCount() {
return playerCount;
}

@Override
public String toString() {
return "GameCountsReply{" +
"games=" + games +
", playerCount=" + playerCount +
"} " + super.toString();
}

public static class GameCount {
private Map<String, Integer> modes;
private int players;
Expand All @@ -34,12 +42,4 @@ public String toString() {
'}';
}
}

@Override
public String toString() {
return "GameCountsReply{" +
"games=" + games +
", playerCount=" + playerCount +
"} " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;

// Suppressed because most fields are assigned by Gson via reflection.
@SuppressWarnings({"unused", "RedundantSuppression", "MismatchedQueryAndUpdateOfCollection"})
Expand All @@ -23,8 +28,8 @@ public Guild getGuild() {
@Override
public String toString() {
return "GuildReply{" +
"guild=" + guild +
"} " + super.toString();
"guild=" + guild +
"} " + super.toString();
}

public static class Guild {
Expand Down Expand Up @@ -153,8 +158,8 @@ public Banner getBanner() {
*/
public List<Member> getMembers() {
return members == null
? Collections.emptyList()
: Collections.unmodifiableList(members);
? Collections.emptyList()
: Collections.unmodifiableList(members);
}

/**
Expand All @@ -174,8 +179,8 @@ public List<Member> getMembers() {
*/
public List<Rank> getRanks() {
return ranks == null
? Collections.emptyList()
: Collections.unmodifiableList(ranks);
? Collections.emptyList()
: Collections.unmodifiableList(ranks);
}

/**
Expand All @@ -186,8 +191,8 @@ public List<Rank> getRanks() {
*/
public List<GameType> getPreferredGames() {
return preferredGames == null
? Collections.emptyList()
: Collections.unmodifiableList(preferredGames);
? Collections.emptyList()
: Collections.unmodifiableList(preferredGames);
}

/**
Expand All @@ -204,8 +209,8 @@ public long getExperienceForGame(GameType game) {
}

return Optional.ofNullable(guildExpByGameType)
.map(expByGame -> expByGame.get(game))
.orElse(0L);
.map(expByGame -> expByGame.get(game))
.orElse(0L);
}

/**
Expand All @@ -221,8 +226,8 @@ public int getAchievementHighScore(GuildAchievement achievement) {
throw new IllegalArgumentException("Cannot get high-score for null achievement");
}
return Optional.ofNullable(achievements)
.map(highScores -> highScores.get(achievement))
.orElse(0);
.map(highScores -> highScores.get(achievement))
.orElse(0);
}

/**
Expand Down Expand Up @@ -316,29 +321,29 @@ public int getCoinsEver() {
*/
public int getLegacyRanking() {
return Optional.ofNullable(legacyRanking)
.map(ranking -> ranking + 1)
.orElse(-1);
.map(ranking -> ranking + 1)
.orElse(-1);
}

@Override
public String toString() {
return "Guild{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", creationDate=" + creationDate +
", tag='" + tag + '\'' +
", tagColor='" + tagColor + '\'' +
", banner=" + banner +
", members=" + members +
", ranks=" + ranks +
", experience=" + experience +
", isPubliclyListed=" + isPubliclyListed +
", isJoinable=" + isJoinable +
", coins=" + coins +
", coinsEver=" + coinsEver +
", legacyRanking=" + legacyRanking +
'}';
"id='" + id + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", creationDate=" + creationDate +
", tag='" + tag + '\'' +
", tagColor='" + tagColor + '\'' +
", banner=" + banner +
", members=" + members +
", ranks=" + ranks +
", experience=" + experience +
", isPubliclyListed=" + isPubliclyListed +
", isJoinable=" + isJoinable +
", coins=" + coins +
", coinsEver=" + coinsEver +
", legacyRanking=" + legacyRanking +
'}';
}

@Override
Expand Down Expand Up @@ -414,8 +419,8 @@ public int getExperienceEarned(LocalDate date) {
}

return Optional.ofNullable(weeklyExperience)
.map(expByDate -> expByDate.get(date.toString()))
.orElse(-1);
.map(expByDate -> expByDate.get(date.toString()))
.orElse(-1);
}

/**
Expand All @@ -429,10 +434,10 @@ public ZonedDateTime getJoined() {
@Override
public String toString() {
return "Member{" +
"uuid=" + uuid +
", rank='" + rank + '\'' +
", joined=" + joinDate +
'}';
"uuid=" + uuid +
", rank='" + rank + '\'' +
", joined=" + joinDate +
'}';
}

@Override
Expand Down Expand Up @@ -518,12 +523,12 @@ public int getPriority() {
@Override
public String toString() {
return "Rank{" +
"name='" + name + '\'' +
", tag='" + tag + '\'' +
", isDefault=" + isDefault +
", creationDate=" + creationDate +
", priority=" + priority +
'}';
"name='" + name + '\'' +
", tag='" + tag + '\'' +
", isDefault=" + isDefault +
", creationDate=" + creationDate +
", priority=" + priority +
'}';
}

@Override
Expand All @@ -536,7 +541,7 @@ public boolean equals(Object o) {
}
Rank rank = (Rank) o;
return Objects.equals(name, rank.name) &&
Objects.equals(creationDate, rank.creationDate);
Objects.equals(creationDate, rank.creationDate);
}

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

import com.google.gson.JsonObject;
import net.hypixel.api.reply.AbstractReply;

public class ResourceReply extends AbstractReply {

Expand Down
Loading