Tolerate an empty client_servergroups in Client.getServerGroups

Some servers list a client with an empty client_servergroups; parsing it
threw NumberFormatException and aborted iterating the whole client list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 19:30:48 +00:00
co-authored by Claude Opus 5.5
parent 6fe787de30
commit b335c2c511
@@ -28,6 +28,7 @@ package com.github.manevolent.ts3j.api;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
@@ -130,12 +131,12 @@ public class Client extends Wrapper {
public int[] getServerGroups() {
final String str = get(ClientProperty.CLIENT_SERVERGROUPS);
final String[] arr = str.split(",");
final int[] groups = new int[arr.length];
for (int i = 0; i < groups.length; i++) {
groups[i] = Integer.parseInt(arr[i]);
}
return groups;
if (str == null) return new int[0];
return Arrays.stream(str.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.mapToInt(Integer::parseInt)
.toArray();
}
public int getTalkPower() {