blob: e50ef3bfd468c3b8f4be35439cfb1be414bce680 (
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
|
package de.hype.bbsentials.forge;
import com.google.common.collect.Lists;
import com.mojang.realmsclient.dto.PlayerInfo;
import de.hype.bbsentials.common.chat.Chat;
import de.hype.bbsentials.common.constants.enviromentShared.Islands;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.server.gui.PlayerListComponent;
import java.util.Iterator;
import java.util.List;
public class BBUtils implements de.hype.bbsentials.common.mclibraries.BBUtils {
public Islands getCurrentIsland() {
try {
String string = getTabListPlayerName("!C-b");
if (!string.startsWith("Area: ")) {
Chat.sendPrivateMessageToSelfError("Could not get Area data. Are you in Skyblock?");
}
else {
return Islands.getByDisplayName(string.replace("Area: ", "").trim());
}
} catch (Exception e) {
}
return null;
}
public static String getTabListPlayerName(String id) {
return Minecraft.getMinecraft().getNetHandler().getPlayerInfo(id).getDisplayName().getUnformattedText();
}
public int getPlayerCount() {
return Integer.parseInt(getTabListPlayerName("!B-a").trim().replaceAll("[^0-9]", ""));
}
public String getServer() {
return getTabListPlayerName("!C-c").replace("Server:", "").trim();
}
public boolean isOnMegaServer() {
return getServer().toLowerCase().startsWith("mega");
}
public boolean isOnMiniServer() {
return getServer().toLowerCase().startsWith("mini");
}
public int getMaximumPlayerCount() {
boolean mega = isOnMegaServer();
Islands island = getCurrentIsland();
if (island == null) return 100;
if (island.equals(Islands.HUB)) {
if (mega) return 80;
else return 24;
}
return 24;
}
public List<String> getPlayers() {
List<String> list = Lists.newArrayList();
Iterator var2 = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().iterator();
while (var2.hasNext()) {
NetworkPlayerInfo playerListEntry = (NetworkPlayerInfo) var2.next();
String playerName = playerListEntry.getDisplayName().getUnformattedText();
if (!playerName.startsWith("!")) {
list.add(playerName);
}
}
return list;
}
}
|