-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
411 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/game/leaderboard/GameLeaderboard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.game.leaderboard; | ||
|
||
import org.json.simple.JSONObject; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.LazyObject; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class GameLeaderboard { | ||
|
||
private LazyObject source; | ||
|
||
public GameLeaderboard(LazyObject source) { | ||
this.source = source; | ||
} | ||
|
||
public long getStart() { | ||
return source.getLong("start"); | ||
} | ||
|
||
public long getEnd() { | ||
return source.getLong("end"); | ||
} | ||
|
||
public List<LeaderboardPlace> getPlayers() { | ||
return (List<LeaderboardPlace>) source.getJSONArray("leaderboard") | ||
.stream().map((place) -> new LeaderboardPlace((JSONObject) place)).collect(Collectors.toList()); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/game/leaderboard/LeaderboardPlace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.game.leaderboard; | ||
|
||
import org.json.simple.JSONObject; | ||
|
||
public class LeaderboardPlace extends JSONObject { | ||
|
||
public LeaderboardPlace(JSONObject in) { | ||
putAll(in); | ||
} | ||
|
||
public long getPlace() { | ||
return (long) get("index"); | ||
} | ||
|
||
public long getHumanPlace() { | ||
return getPlace() + 1; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/player/games/arcade/PmkStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.player.games.arcade; | ||
|
||
import pw.roccodev.beezig.hiveapi.wrapper.player.PvPStats; | ||
import pw.roccodev.beezig.hiveapi.wrapper.player.Titleable; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.LazyObject; | ||
|
||
public class PmkStats extends PvPStats implements Titleable { | ||
|
||
private LazyObject source; | ||
|
||
public PmkStats(String usernameOrUUID) { | ||
this(usernameOrUUID, false); | ||
} | ||
|
||
public PmkStats(String username, boolean convertToUUID) { | ||
super(username, "PMK", convertToUUID); | ||
source = getSource(); | ||
} | ||
|
||
|
||
public long getInfections() { | ||
return source.getLong("infections"); | ||
} | ||
|
||
@Override | ||
public long getDeaths() { | ||
return getInfections(); | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return source.getString("title"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/player/games/arcade/RrStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.player.games.arcade; | ||
|
||
import pw.roccodev.beezig.hiveapi.wrapper.player.GameStats; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.LazyObject; | ||
|
||
import java.util.Date; | ||
|
||
public class RrStats extends GameStats { | ||
|
||
private LazyObject source; | ||
|
||
public RrStats(String usernameOrUUID) { | ||
this(usernameOrUUID, false); | ||
} | ||
|
||
public RrStats(String username, boolean convertToUUID) { | ||
super(username, "RR", convertToUUID); | ||
source = getSource(); | ||
} | ||
|
||
|
||
public long getTablesCleared() { | ||
return source.getLong("tablescleared"); | ||
} | ||
|
||
public long getHighestScore() { | ||
return source.getLong("highscore"); | ||
} | ||
|
||
@Override | ||
public long getGamesPlayed() { | ||
return source.getLong("gamesplayed"); | ||
} | ||
|
||
@Override | ||
public long getPoints() { | ||
return source.getLong("points"); | ||
} | ||
|
||
@Override | ||
public Date getFirstLogin() { | ||
return new Date(source.getLong("firstlogin") * 1000); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/player/games/arcade/SlapStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.player.games.arcade; | ||
|
||
import pw.roccodev.beezig.hiveapi.wrapper.player.PvPStats; | ||
import pw.roccodev.beezig.hiveapi.wrapper.player.Titleable; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.LazyObject; | ||
|
||
import java.util.Date; | ||
|
||
public class SlapStats extends PvPStats implements Titleable { | ||
|
||
private LazyObject source; | ||
|
||
public SlapStats(String usernameOrUUID) { | ||
this(usernameOrUUID, false); | ||
} | ||
|
||
public SlapStats(String username, boolean convertToUUID) { | ||
super(username, "SLAP", convertToUUID); | ||
source = getSource(); | ||
} | ||
|
||
|
||
@Override | ||
public long getGamesPlayed() { | ||
return source.getLong("gamesplayed"); | ||
} | ||
|
||
@Override | ||
public long getPoints() { | ||
return source.getLong("points"); | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return source.getString("title"); | ||
} | ||
|
||
@Override | ||
public Date getFirstLogin() { | ||
return new Date(source.getLong("firstlogin") * 1000); | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/player/games/arcade/SpStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.player.games.arcade; | ||
|
||
import pw.roccodev.beezig.hiveapi.wrapper.player.PvPStats; | ||
import pw.roccodev.beezig.hiveapi.wrapper.player.Titleable; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.LazyObject; | ||
|
||
import java.util.Date; | ||
|
||
public class SpStats extends PvPStats implements Titleable { | ||
|
||
private LazyObject source; | ||
|
||
public SpStats(String usernameOrUUID) { | ||
this(usernameOrUUID, false); | ||
} | ||
|
||
public SpStats(String username, boolean convertToUUID) { | ||
super(username, "SP", convertToUUID); | ||
source = getSource(); | ||
} | ||
|
||
public long getBlocksDestroyed() { | ||
return source.getLong("blocksdestroyed"); | ||
} | ||
|
||
public long getEggsFired() { | ||
return source.getLong("eggsfired"); | ||
} | ||
|
||
public long getTimeAlive() { | ||
return source.getLong("timealive"); | ||
} | ||
|
||
public boolean hasRainbowEggs() { | ||
return source.getBoolean("rainboweggs"); | ||
} | ||
|
||
public boolean isSheepUnlocked() { | ||
return source.getBoolean("sheepunlock"); | ||
} | ||
|
||
public boolean hasShovelUpgrade() { | ||
return source.getBoolean("shovelupgrade"); | ||
} | ||
|
||
@Override | ||
public long getKills() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public long getGamesPlayed() { | ||
return source.getLong("gamesplayed"); | ||
} | ||
|
||
@Override | ||
public long getPoints() { | ||
return source.getLong("points"); | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return source.getString("title"); | ||
} | ||
|
||
@Override | ||
public Date getFirstLogin() { | ||
return new Date(source.getLong("firstlogin") * 1000); | ||
} | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
src/main/java/pw/roccodev/beezig/hiveapi/wrapper/player/games/arcade/SplStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package pw.roccodev.beezig.hiveapi.wrapper.player.games.arcade; | ||
|
||
import org.json.simple.JSONObject; | ||
import pw.roccodev.beezig.hiveapi.wrapper.player.PvPStats; | ||
import pw.roccodev.beezig.hiveapi.wrapper.player.Titleable; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.JObject; | ||
import pw.roccodev.beezig.hiveapi.wrapper.utils.json.LazyObject; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class SplStats extends PvPStats implements Titleable { | ||
|
||
private LazyObject source; | ||
|
||
public SplStats(String usernameOrUUID) { | ||
this(usernameOrUUID, false); | ||
} | ||
|
||
public SplStats(String username, boolean convertToUUID) { | ||
super(username, "SPL", convertToUUID); | ||
source = getSource(); | ||
} | ||
|
||
public long getBlocksPainted() { | ||
return source.getLong("blockspainted"); | ||
} | ||
|
||
public long getUltimatesEarned() { | ||
return source.getLong("ultimates_earned"); | ||
} | ||
|
||
public HashMap<String, SploopCharacterStats> getCharacterStats() { | ||
|
||
HashMap<String, SploopCharacterStats> stats = new HashMap<>(); | ||
|
||
JSONObject rawStats = source.getJSONObject("character_stats"); | ||
for(Object o : rawStats.entrySet()) { | ||
if(!(o instanceof Map.Entry)) continue; | ||
Map.Entry<String, JSONObject> entry = (Map.Entry<String, JSONObject>) o; | ||
stats.put(entry.getKey(), new SploopCharacterStats(new JObject(entry.getValue()))); | ||
} | ||
|
||
return stats; | ||
} | ||
|
||
public SploopCharacterStats getStatsByCharacter(String raw) { | ||
return getCharacterStats().get(raw); | ||
} | ||
|
||
public SploopCharacterStats getStatsByCharacter(Character character) { | ||
return getStatsByCharacter(character.getApiKey()); | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return source.getString("title"); | ||
} | ||
|
||
|
||
public class SploopCharacterStats { | ||
|
||
private JObject source; | ||
|
||
SploopCharacterStats(JObject source) { | ||
this.source = source; | ||
} | ||
|
||
public long getBlocksPainted() { | ||
return source.getLong("blocks_painted"); | ||
} | ||
|
||
public long getKills() { | ||
return source.getLong("kills"); | ||
} | ||
|
||
public long getDeaths() { | ||
return source.getLong("deaths"); | ||
} | ||
|
||
public long getGamesPlayed() { | ||
return source.getLong("games_played"); | ||
} | ||
|
||
public long getUltimateKills() { | ||
return source.getLong("ultimate_kills"); | ||
} | ||
|
||
|
||
} | ||
|
||
public enum Character { | ||
|
||
TORSTEIN("TorsteinCharacter"), | ||
RAVEN("RavenCharacter"), | ||
BOOSTER("BoosterCharacter"), | ||
OINKY("OinkyCharacter"); | ||
|
||
private String apiKey; | ||
|
||
Character(String apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
|
||
public String getApiKey() { | ||
return apiKey; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.