aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/eu/olli/cowmoonication/data
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-05-04 13:25:39 +0200
committerCow <cow@volloeko.de>2020-05-04 13:25:39 +0200
commit4d45e0bc9afacc8408295aef50b8fd6530f97104 (patch)
treec06e0f2ffbf8c1fc697ee468b4a1e2bf85ee1a45 /src/main/java/eu/olli/cowmoonication/data
parent6f33fc424111ce46dcabd85f214db68f4ddc8b9d (diff)
downloadCowlection-4d45e0bc9afacc8408295aef50b8fd6530f97104.tar.gz
Cowlection-4d45e0bc9afacc8408295aef50b8fd6530f97104.tar.bz2
Cowlection-4d45e0bc9afacc8408295aef50b8fd6530f97104.zip
Re-organized packages and files
Diffstat (limited to 'src/main/java/eu/olli/cowmoonication/data')
-rw-r--r--src/main/java/eu/olli/cowmoonication/data/Friend.java65
-rw-r--r--src/main/java/eu/olli/cowmoonication/data/HyStalkingData.java168
-rw-r--r--src/main/java/eu/olli/cowmoonication/data/SlothStalkingData.java48
3 files changed, 281 insertions, 0 deletions
diff --git a/src/main/java/eu/olli/cowmoonication/data/Friend.java b/src/main/java/eu/olli/cowmoonication/data/Friend.java
new file mode 100644
index 0000000..69741e2
--- /dev/null
+++ b/src/main/java/eu/olli/cowmoonication/data/Friend.java
@@ -0,0 +1,65 @@
+package eu.olli.cowmoonication.data;
+
+import java.util.Objects;
+import java.util.UUID;
+
+public class Friend {
+ public static final Friend FRIEND_NOT_FOUND = new Friend();
+ private UUID id;
+ private String name;
+ private long lastChecked;
+
+ static {
+ // uuid & name are null
+ FRIEND_NOT_FOUND.setLastChecked(0);
+ }
+
+ /**
+ * No-args constructor for GSON
+ */
+ private Friend() {
+ this.lastChecked = System.currentTimeMillis();
+ }
+
+ public UUID getUuid() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getLastChecked() {
+ return lastChecked;
+ }
+
+ public void setLastChecked(long lastChecked) {
+ this.lastChecked = lastChecked;
+ }
+
+ @Override
+ public String toString() {
+ return "Friend{" +
+ "uuid=" + id +
+ ", name='" + name + '\'' +
+ ", lastChecked=" + lastChecked +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Friend friend = (Friend) o;
+ return Objects.equals(id, friend.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
diff --git a/src/main/java/eu/olli/cowmoonication/data/HyStalkingData.java b/src/main/java/eu/olli/cowmoonication/data/HyStalkingData.java
new file mode 100644
index 0000000..fdb5543
--- /dev/null
+++ b/src/main/java/eu/olli/cowmoonication/data/HyStalkingData.java
@@ -0,0 +1,168 @@
+package eu.olli.cowmoonication.data;
+
+import eu.olli.cowmoonication.util.Utils;
+import org.apache.commons.lang3.StringUtils;
+
+public class HyStalkingData {
+ private boolean success;
+ private String cause;
+ private HySession session;
+
+ /**
+ * No-args constructor for GSON
+ */
+ private HyStalkingData() {
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public String getCause() {
+ return cause;
+ }
+
+ public HySession getSession() {
+ return session;
+ }
+
+ public static class HySession {
+ private boolean online;
+ private String gameType;
+ private String mode;
+ private String map;
+
+ /**
+ * No-args constructor for GSON
+ */
+ private HySession() {
+ }
+
+ public boolean isOnline() {
+ return online;
+ }
+
+ public String getGameType() {
+ String cleanGameType;
+ try {
+ cleanGameType = GameType.valueOf(gameType).getCleanName();
+ } catch (IllegalArgumentException e) {
+ // no matching game type found
+ cleanGameType = Utils.fancyCase(gameType);
+ }
+ return cleanGameType;
+ }
+
+ public String getMode() {
+ // modes partially taken from https://api.hypixel.net/gameCounts?key=MOO
+ if (mode == null) {
+ return null;
+ }
+ String gameType = getGameType();
+ if (GameType.BEDWARS.cleanName.equals(gameType)) {
+ // BedWars related
+ String playerMode;
+ String specialMode;
+ int specialModeStart = StringUtils.ordinalIndexOf(mode, "_", 2);
+ if (specialModeStart > -1) {
+ playerMode = mode.substring(0, specialModeStart);
+ specialMode = mode.substring(specialModeStart + 1) + " ";
+ } else {
+ playerMode = mode;
+ specialMode = "";
+ }
+ String playerModeClean;
+ switch (playerMode) {
+ case "EIGHT_ONE":
+ playerModeClean = "Solo";
+ break;
+ case "EIGHT_TWO":
+ playerModeClean = "Doubles";
+ break;
+ case "FOUR_THREE":
+ playerModeClean = "3v3v3v3";
+ break;
+ case "FOUR_FOUR":
+ playerModeClean = "4v4v4v4";
+ break;
+ case "TWO_FOUR":
+ playerModeClean = "4v4";
+ break;
+ default:
+ playerModeClean = playerMode;
+ }
+ return Utils.fancyCase(specialMode + playerModeClean);
+ } else if (GameType.SKYBLOCK.cleanName.equals(gameType)) {
+ // SkyBlock related
+ switch (mode) {
+ case "dynamic":
+ return "Private Island";
+ case "hub":
+ return "Hub";
+ case "combat_1":
+ return "Spider's Den";
+ case "combat_2":
+ return "Blazing Fortress";
+ case "combat_3":
+ return "The End";
+ case "farming_1":
+ return "The Barn";
+ case "farming_2":
+ return "Mushroom Desert";
+ case "foraging_1":
+ return "The Park";
+ case "mining_1":
+ return "Gold Mine";
+ case "mining_2":
+ return "Deep Caverns";
+ }
+ }
+ return Utils.fancyCase(mode);
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ // TODO replace with api request: https://github.com/HypixelDev/PublicAPI/blob/master/Documentation/misc/GameType.md
+ public enum GameType {
+ QUAKECRAFT("Quakecraft"),
+ WALLS("Walls"),
+ PAINTBALL("Paintball"),
+ SURVIVAL_GAMES("Blitz Survival Games"),
+ TNTGAMES("The TNT Games"),
+ VAMPIREZ("VampireZ"),
+ WALLS3("Mega Walls"),
+ ARCADE("Arcade"),
+ ARENA("Arena Brawl"),
+ UHC("UHC Champions"),
+ MCGO("Cops and Crims"),
+ BATTLEGROUND("Warlords"),
+ SUPER_SMASH("Smash Heroes"),
+ GINGERBREAD("Turbo Kart Racers"),
+ HOUSING("Housing"),
+ SKYWARS("SkyWars"),
+ TRUE_COMBAT("Crazy Walls"),
+ SPEED_UHC("Speed UHC"),
+ SKYCLASH("SkyClash"),
+ LEGACY("Classic Games"),
+ PROTOTYPE("Prototype"),
+ BEDWARS("Bed Wars"),
+ MURDER_MYSTERY("Murder Mystery"),
+ BUILD_BATTLE("Build Battle"),
+ DUELS("Duels"),
+ SKYBLOCK("SkyBlock"),
+ PIT("Pit");
+
+ private final String cleanName;
+
+ GameType(String cleanName) {
+ this.cleanName = cleanName;
+ }
+
+ public String getCleanName() {
+ return cleanName;
+ }
+ }
+ }
+}
diff --git a/src/main/java/eu/olli/cowmoonication/data/SlothStalkingData.java b/src/main/java/eu/olli/cowmoonication/data/SlothStalkingData.java
new file mode 100644
index 0000000..1072634
--- /dev/null
+++ b/src/main/java/eu/olli/cowmoonication/data/SlothStalkingData.java
@@ -0,0 +1,48 @@
+package eu.olli.cowmoonication.data;
+
+public class SlothStalkingData {
+ private String username;
+ private String rank;
+ private String rank_formatted;
+ // private boolean online;
+ private long last_login;
+ private long last_logout;
+ private String last_game;
+
+ /**
+ * No-args constructor for GSON
+ */
+ public SlothStalkingData() {
+ }
+
+ public String getPlayerNameFormatted() {
+ return rank_formatted.replace('&', 'ยง') + " " + username;
+ }
+
+ public long getLastLogin() {
+ return last_login;
+ }
+
+ public long getLastLogout() {
+ return last_logout;
+ }
+
+ public String getLastGame() {
+ return last_game;
+ }
+
+ public boolean hasNeverJoinedHypixel() {
+ // example player that has never joined Hypixel (as of April 2020): Joe
+ return rank == null && last_login == 0;
+ }
+
+ public boolean hasNeverLoggedOut() {
+ // example player that has no logout value (as of April 2020): Pig (in general accounts that haven't logged in for a few years)
+ return last_login != 0 && last_logout == 0;
+ }
+
+ public boolean isHidingOnlineStatus() {
+ // example players: any higher ranked player (mods, admins, ...)
+ return last_login == 0 && last_logout == 0;
+ }
+}