blob: 3e13e1cc4b725f08fc70539e83be140b01c9de71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
package de.cowtipper.cowlection.data;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
import java.util.Map;
@SuppressWarnings("unused")
public class HyPlayerData {
private String playername;
private String displayname;
private String rank;
private String prefix;
private String newPackageRank;
private String rankPlusColor;
private String monthlyPackageRank;
private String monthlyRankColor;
private long lastLogin;
private long lastLogout;
private String mostRecentGameType;
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private Map<String, Integer> achievements;
/**
* No-args constructor for GSON
*/
public HyPlayerData() {
}
public String getPlayerName() {
return displayname;
}
public String getPlayerNameFormatted() {
return getRankFormatted() + displayname;
}
public long getLastLogin() {
return lastLogin;
}
public long getLastLogout() {
return lastLogout;
}
public String getLastGame() {
return DataHelper.GameType.getFancyName(mostRecentGameType);
}
public int getAchievement(String achievementName) {
if (achievements != null) {
return achievements.getOrDefault(achievementName, 0);
}
return 0;
}
public boolean hasNeverJoinedHypixel() {
// example player that has never joined Hypixel (as of April 2020): Joe
return rank == null && lastLogin == 0 && StringUtils.isNullOrEmpty(playername);
}
public boolean hasNeverLoggedOut() {
// example player that has no logout value (as of October 2022): Creeper (in general accounts that haven't logged in for a few years)
return lastLogin != 0 && lastLogout == 0;
}
public boolean isHidingOnlineStatus() {
// example players: any higher ranked player (mods, admins, ...)
return lastLogin == 0 && lastLogout == 0;
}
/**
* Player's Rank prefix: <a href="https://github.com/HypixelDev/PublicAPI/wiki/Common-Questions#how-do-i-get-a-players-rank-prefix">API Docs: How do I get a player's rank prefix?</a>
*
* @return formatted rank
*/
private String getRankFormatted() {
if (prefix != null) {
return prefix;
}
if (rank != null) {
switch (rank) {
case "HELPER":
return EnumChatFormatting.BLUE + "[HELPER] ";
case "MODERATOR":
return EnumChatFormatting.DARK_GREEN + "[MOD] ";
case "GAME_MASTER":
return EnumChatFormatting.DARK_GREEN + "[GM] ";
case "ADMIN":
return EnumChatFormatting.RED + "[ADMIN] ";
case "YOUTUBER":
return EnumChatFormatting.RED + "[" + EnumChatFormatting.WHITE + "YOUTUBE" + EnumChatFormatting.RED + "] ";
default:
// unknown rank, fall-through
break;
}
}
if (rankPlusColor == null) {
rankPlusColor = "RED";
}
if (monthlyPackageRank != null && monthlyPackageRank.equals("SUPERSTAR")) {
// MVP++
EnumChatFormatting rankPlusPlusColor = monthlyRankColor != null ? EnumChatFormatting.getValueByName(monthlyRankColor) : EnumChatFormatting.GOLD;
return rankPlusPlusColor + "[MVP" + EnumChatFormatting.getValueByName(rankPlusColor) + "++" + rankPlusPlusColor + "] ";
}
if (newPackageRank != null) {
switch (newPackageRank) {
case "VIP":
return EnumChatFormatting.GREEN + "[VIP] ";
case "VIP_PLUS":
return EnumChatFormatting.GREEN + "[VIP" + EnumChatFormatting.GOLD + "+" + EnumChatFormatting.GREEN + "] ";
case "MVP":
return EnumChatFormatting.AQUA + "[MVP] ";
case "MVP_PLUS":
return EnumChatFormatting.AQUA + "[MVP" + EnumChatFormatting.getValueByName(rankPlusColor) + "+" + EnumChatFormatting.AQUA + "] ";
default:
return EnumChatFormatting.GRAY.toString();
}
}
return EnumChatFormatting.GRAY.toString();
}
}
|