blob: 1b35fa658feb951aa70d5491a59a93a25eeaea74 (
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
|
package de.hype.bbsentials.client;
import com.google.common.collect.Lists;
import de.hype.bbsentials.chat.Chat;
import de.hype.bbsentials.constants.enviromentShared.Islands;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.PlayerListEntry;
import java.util.Iterator;
import java.util.List;
public class BBUtils {
public static Islands getCurrentIsland() {
try {
String string = MinecraftClient.getInstance().player.networkHandler.getPlayerListEntry("!C-b").getDisplayName().getString();
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 int getPlayerCount() {
return Integer.parseInt(MinecraftClient.getInstance().player.networkHandler.getPlayerListEntry("!B-a").getDisplayName().getString().trim().replaceAll("[^0-9]", ""));
}
public static String getServer() {
return MinecraftClient.getInstance().player.networkHandler.getPlayerListEntry("!C-c").getDisplayName().getString().replace("Server:", "").trim();
}
public static boolean isOnMegaServer() {
return getServer().toLowerCase().startsWith("mega");
}
public static boolean isOnMiniServer() {
return getServer().toLowerCase().startsWith("mini");
}
public static 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 = MinecraftClient.getInstance().getNetworkHandler().getPlayerList().iterator();
while (var2.hasNext()) {
PlayerListEntry playerListEntry = (PlayerListEntry) var2.next();
String playerName = playerListEntry.getProfile().getName();
if (!playerName.startsWith("!")) {
list.add(playerName);
}
}
return list;
}
}
|