Skip to content

Commit

Permalink
Merge pull request #255 from AzureAaron/address-override
Browse files Browse the repository at this point in the history
Add alternate hypixel address argument
  • Loading branch information
kevinthegreat1 committed Aug 24, 2023
2 parents 886153a + 78ec3b0 commit 121f5a5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/me/xmrvizzy/skyblocker/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Utility variables and methods for retrieving Skyblock related information.
*/
public class Utils {
private static final String ALTERNATE_HYPIXEL_ADDRESS = System.getProperty("skyblocker.alternateHypixelAddress", "");
private static final String PROFILE_PREFIX = "Profile: ";
private static boolean isOnHypixel = false;
private static boolean isOnSkyblock = false;
Expand Down Expand Up @@ -129,10 +130,9 @@ public static void updateFromScoreboard(MinecraftClient client) {
return;
}
String string = sidebar.toString();
String serverAddress = (client.getCurrentServerEntry() != null) ? client.getCurrentServerEntry().address.toLowerCase() : "";

if (sidebar.isEmpty()) return;
if (serverAddress.contains("hypixel.net") || serverAddress.contains("hypixel.io")) {
if (isConnectedToHypixel(client)) {
if (!isOnHypixel) {
isOnHypixel = true;
}
Expand All @@ -154,6 +154,14 @@ public static void updateFromScoreboard(MinecraftClient client) {
leaveSkyblock();
}
}

private static boolean isConnectedToHypixel(MinecraftClient client) {
String serverAddress = (client.getCurrentServerEntry() != null) ? client.getCurrentServerEntry().address.toLowerCase() : "";
String serverBrand = (client.player != null && client.player.getServerBrand() != null) ? client.player.getServerBrand() : "";
boolean isOnHypixel = (serverAddress.equalsIgnoreCase(ALTERNATE_HYPIXEL_ADDRESS) || serverAddress.contains("hypixel.net") || serverAddress.contains("hypixel.io") || serverBrand.contains("Hypixel BungeeCord"));

return isOnHypixel;
}

private static void leaveSkyblock() {
if (isOnSkyblock) {
Expand Down

0 comments on commit 121f5a5

Please sign in to comment.