Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dungeon score not working when fancy tab hud is disabled #1145

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,63 @@
public class PlayerListManager {

public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Regex");
private static final Pattern PLAYERS_COLUMN_PATTERN = Pattern.compile("(^|\\s*)(Players \\(\\d+\\)|Island|Coop \\(\\d+\\))(\\s*|$)");
private static final Pattern INFO_COLUMN_PATTERN = Pattern.compile("(^|\\s*)Info(\\s*|$)");
private static final Pattern PLAYERS_COLUMN_PATTERN = Pattern.compile("\\s*(Players \\(\\d+\\)|Island|Coop \\(\\d+\\))\\s*");
private static final Pattern INFO_COLUMN_PATTERN = Pattern.compile("\\s*Info\\s*");

/**
* The player list in tab.
*/
private static List<PlayerListEntry> playerList = new ArrayList<>(); // Initialize to prevent npe.

/**
* The player list in tab, but a list of strings instead of {@link PlayerListEntry}s.
*
* @implNote All leading and trailing whitespace is removed from the strings.
*/
private static List<String> playerStringList = new ArrayList<>();
@Nullable
private static String footer;
public static final Map<String, TabHudWidget> tabWidgetInstances = new Object2ObjectOpenHashMap<>();
public static final List<TabHudWidget> tabWidgetsToShow = new ObjectArrayList<>(5);

public static void updateList() {
private static void reset() {
if (!tabWidgetsToShow.isEmpty()) {
tabWidgetsToShow.clear();
ScreenBuilder.positionsNeedsUpdating = true;
}
}

if (!Utils.isOnSkyblock() || !SkyblockerConfigManager.get().uiAndVisuals.tabHud.tabHudEnabled) {
if (!tabWidgetsToShow.isEmpty()) {
tabWidgetsToShow.clear();
ScreenBuilder.positionsNeedsUpdating = true;
}
public static void updateList() {
if (!Utils.isOnSkyblock()) {
reset();
return;
}

ClientPlayNetworkHandler cpnwh = MinecraftClient.getInstance().getNetworkHandler();
ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();

// check is needed, else game crashes on server leave
if (cpnwh != null) {
playerList = cpnwh.getPlayerList().stream().sorted(PlayerListHudAccessor.getOrdering()).toList();
playerStringList = playerList.stream().map(PlayerListEntry::getDisplayName).filter(Objects::nonNull).map(Text::getString).map(String::strip).toList();
if (networkHandler != null) {
playerList = networkHandler.getPlayerList()
.stream()
.sorted(PlayerListHudAccessor.getOrdering())
.toList();
playerStringList = playerList.stream()
.map(PlayerListEntry::getDisplayName)
.filter(Objects::nonNull)
.map(Text::getString)
.map(String::strip)
.toList();
}

if (!SkyblockerConfigManager.get().uiAndVisuals.tabHud.tabHudEnabled) {
reset();
return;
}

if (MinecraftClient.getInstance().currentScreen instanceof WidgetsConfigurationScreen widgetsConfigurationScreen && widgetsConfigurationScreen.isPreviewVisible()) return;

if (Utils.isInDungeons()) {
updateDungeons(null);
} else {
updateWidgetsFrom(playerList);
}
if (Utils.isInDungeons()) updateDungeons(null);
else updateWidgetsFrom(playerList);
}

/**
Expand Down
Loading