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:
@@ -28,6 +28,7 @@ package com.github.manevolent.ts3j.api;
|
|||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -130,12 +131,12 @@ public class Client extends Wrapper {
|
|||||||
|
|
||||||
public int[] getServerGroups() {
|
public int[] getServerGroups() {
|
||||||
final String str = get(ClientProperty.CLIENT_SERVERGROUPS);
|
final String str = get(ClientProperty.CLIENT_SERVERGROUPS);
|
||||||
final String[] arr = str.split(",");
|
if (str == null) return new int[0];
|
||||||
final int[] groups = new int[arr.length];
|
return Arrays.stream(str.split(","))
|
||||||
for (int i = 0; i < groups.length; i++) {
|
.map(String::trim)
|
||||||
groups[i] = Integer.parseInt(arr[i]);
|
.filter(s -> !s.isEmpty())
|
||||||
}
|
.mapToInt(Integer::parseInt)
|
||||||
return groups;
|
.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTalkPower() {
|
public int getTalkPower() {
|
||||||
|
|||||||
Reference in New Issue
Block a user