Offer move/kick/ban when the server won't tell our powers

Asking for i_client_move_power and the like (permget) needs
b_client_permissionoverview_own, which custom moderator groups often lack
although they hold the powers; servergrouppermlist is refused too. A
refusal counted as 0, so Android hid actions the official client allows.
Now a refusal means unknown and the actions are offered, as the official
client always does, leaving the server to judge; only an answered 0 hides
them. Verified with such a group on a local 3.13.7 server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 00:50:58 +00:00
co-authored by Claude Opus 5.5
parent c41b86f704
commit 7fde4f502a
5 changed files with 36 additions and 3 deletions
@@ -37,6 +37,8 @@ public final class ServerModel {
private final Map<Integer, Integer> selfPermissionValues = new LinkedHashMap<>();
/** The local client's {@link #UNREPORTED_PERMISSIONS}, which the needed permissions leave out; absent until known. */
private final Map<String, Integer> unreportedValues = new HashMap<>();
/** Whether the server answered for the {@link #UNREPORTED_PERMISSIONS} at all. */
private boolean unreportedKnown;
private String serverName = "TeamSpeak Server";
/** The {@code virtualserver_*} properties from {@code initserver}, kept up to date by server edits. */
private final Map<String, String> serverProperties = new HashMap<>();
@@ -55,6 +57,7 @@ public final class ServerModel {
nextPermissionId = FIRST_PERMISSION_ID;
selfPermissionValues.clear();
unreportedValues.clear();
unreportedKnown = false;
serverProperties.clear();
defaultChannelGroupId = 0;
defaultChannelId = 0;
@@ -180,6 +183,24 @@ public final class ServerModel {
public synchronized void setUnreportedPermissions(Map<String, Integer> values) {
unreportedValues.clear();
unreportedValues.putAll(values);
unreportedKnown = true;
}
/**
* The server would not say: asking needs {@code b_client_permissionoverview_own}, which
* moderator groups often lack although they hold the powers.
*/
public synchronized void unreportedPermissionsRefused() {
unreportedValues.clear();
unreportedKnown = false;
}
/**
* Whether we may hold one of {@link #UNREPORTED_PERMISSIONS}: unless the server said we
* do not, the action is offered, as the official client always does, and the server judges.
*/
public synchronized boolean mayHavePower(String name) {
return !unreportedKnown || unreportedValues.getOrDefault(name, 0) != 0;
}
/** One of {@link #UNREPORTED_PERMISSIONS}; 0 until known, or when the server would not tell. */
@@ -890,7 +890,7 @@ public final class TeamspeakConnection implements TS3Listener {
if (name != null && value != null) powers.put(name, Integer.parseInt(value));
}
model.setUnreportedPermissions(powers);
}, e -> model.setUnreportedPermissions(Map.of()));
}, e -> model.unreportedPermissionsRefused());
}
/** Assigns or removes a server group for a client (by database id, as {@code servergroupaddclient} needs). */
@@ -710,7 +710,7 @@ public final class ServerSession {
* server knows, so it is left to refuse.
*/
private boolean hasPower(String power) {
return conn.isConnected() && conn.getModel().selfPower(power) != 0;
return conn.isConnected() && conn.getModel().mayHavePower(power);
}
// ---- connection events ----