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

Feature/client permissions enum #416

Merged
merged 5 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
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
95 changes: 93 additions & 2 deletions src/main/java/com/github/theholywaffle/teamspeak3/TS3Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -251,6 +251,12 @@ public void addChannelPermission(int channelId, String permName, int permValue)

/**
* Adds a specified permission to a channel.
* @deprecated
* This method is no longer preferred for adding permissions to the client
* <p>
* Use {@link TS3Api#addClientPermission(int, IPermissionType, int, boolean)}
* or {@link TS3Api#addClientPermission(int, BPermissionType, boolean, boolean)} instead.
* </p>
*
* @param clientDBId
* the database ID of the client to grant the permission
Expand All @@ -267,10 +273,57 @@ public void addChannelPermission(int channelId, String permName, int permValue)
* @see Client#getDatabaseId()
* @see Permission
*/
@Deprecated
public void addClientPermission(int clientDBId, String permName, int value, boolean skipped) {
asyncApi.addClientPermission(clientDBId, permName, value, skipped).getUninterruptibly();
}

/**
* Adds a specified permission to a client.
*
* @param clientDBId
* the database ID of the client to grant the permission
* @param permName
* the enum of the permission to grant
* @see IPermissionType
* @param value
* the numeric value of the permission
* @param skipped
* if set to {@code true}, the permission will not be overridden by channel group permissions
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission
*/
public void addClientPermission(int clientDBId, IPermissionType permName, int value, boolean skipped) {
asyncApi.addClientPermission(clientDBId, permName, value, skipped).getUninterruptibly();
}

/**
* Adds a specified permission to a client.
*
* @param clientDBId
* the database ID of the client to grant the permission
* @param permName
* the enum of the permission to grant
* @see BPermissionType
* @param value
* the boolean value of the permission
* @param skipped
* if set to {@code true}, the permission will not be overridden by channel group permissions
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission
*/
public void addClientPermission(int clientDBId, BPermissionType permName, boolean value, boolean skipped) {
asyncApi.addClientPermission(clientDBId, permName, value, skipped).getUninterruptibly();
}

/**
* Adds a client to the specified server group.
* <p>
Expand Down Expand Up @@ -1042,6 +1095,44 @@ public void deleteClientPermission(int clientDBId, String permName) {
asyncApi.deleteClientPermission(clientDBId, permName).getUninterruptibly();
}

/**
* Removes a permission from a client.
*
* @param clientDBId
* the database ID of the client
* @param permName
* the enum of the permission to revoke
* @see IPermissionType
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission#getName()
*/
public void deleteClientPermission(int clientDBId, IPermissionType permName) {
asyncApi.deleteClientPermission(clientDBId, permName).getUninterruptibly();
}

/**
* Removes a permission from a client.
*
* @param clientDBId
* the database ID of the client
* @param permName
* the enum of the permission to revoke
* @see BPermissionType
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission#getName()
*/
public void deleteClientPermission(int clientDBId, BPermissionType permName) {
asyncApi.deleteClientPermission(clientDBId, permName).getUninterruptibly();
}

/**
* Deletes the complaint about the client with database ID {@code targetClientDBId} submitted by
* the client with database ID {@code fromClientDBId} from the server.
Expand Down
95 changes: 95 additions & 0 deletions src/main/java/com/github/theholywaffle/teamspeak3/TS3ApiAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ public CommandFuture<Void> addChannelPermission(int channelId, String permName,

/**
* Adds a specified permission to a channel.
* @deprecated
* This method is no longer preferred for adding permissions to the client
* <p>
* Use {@link TS3ApiAsync#addClientPermission(int, IPermissionType, int, boolean)}
* or {@link TS3ApiAsync#addClientPermission(int, BPermissionType, boolean, boolean)} instead.
* </p>
*
* @param clientDBId
* the database ID of the client to grant the permission
Expand All @@ -301,11 +307,60 @@ public CommandFuture<Void> addChannelPermission(int channelId, String permName,
* @see Client#getDatabaseId()
* @see Permission
*/
@Deprecated
public CommandFuture<Void> addClientPermission(int clientDBId, String permName, int value, boolean skipped) {
Command cmd = PermissionCommands.clientAddPerm(clientDBId, permName, value, skipped);
return executeAndReturnError(cmd);
}

/**
* Adds a specified permission to a client.
*
* @param clientDBId
* the database ID of the client to grant the permission
* @param permName
* the enum of the permission to grant
* @see IPermissionType
* @param value
* the numeric value of the permission
* @param skipped
* if set to {@code true}, the permission will not be overridden by channel group permissions
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission
*/
public CommandFuture<Void> addClientPermission(int clientDBId, IPermissionType permName, int value, boolean skipped) {
Command cmd = PermissionCommands.clientAddPerm(clientDBId, permName.getName(), value, skipped);
return executeAndReturnError(cmd);
}

/**
* Adds a specified permission to a client.
*
* @param clientDBId
* the database ID of the client to grant the permission
* @param permName
* the enum of the permission to grant
* @see BPermissionType
* @param value
* the boolean value of the permission
* @param skipped
* if set to {@code true}, the permission will not be overridden by channel group permissions
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission
*/
public CommandFuture<Void> addClientPermission(int clientDBId, BPermissionType permName, boolean value, boolean skipped) {
Command cmd = PermissionCommands.clientAddPerm(clientDBId, permName.getName(), value, skipped);
return executeAndReturnError(cmd);
}

/**
* Adds a client to the specified server group.
* <p>
Expand Down Expand Up @@ -1157,6 +1212,46 @@ public CommandFuture<Void> deleteClientPermission(int clientDBId, String permNam
return executeAndReturnError(cmd);
}

/**
* Removes a permission from a client.
*
* @param clientDBId
* the database ID of the client
* @param permName
* the enum of the permission to revoke
* @see IPermissionType
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission#getName()
*/
public CommandFuture<Void> deleteClientPermission(int clientDBId, IPermissionType permName) {
Command cmd = PermissionCommands.clientDelPerm(clientDBId, permName.getName());
return executeAndReturnError(cmd);
}

/**
* Removes a permission from a client.
*
* @param clientDBId
* the database ID of the client
* @param permName
* the enum of the permission to revoke
* @see BPermissionType
*
* @throws TS3CommandFailedException
* if the execution of a command fails
* @querycommands 1
* @see Client#getDatabaseId()
* @see Permission#getName()
*/
public CommandFuture<Void> deleteClientPermission(int clientDBId, BPermissionType permName) {
Command cmd = PermissionCommands.clientDelPerm(clientDBId, permName.getName());
return executeAndReturnError(cmd);
}

/**
* Deletes the complaint about the client with database ID {@code targetClientDBId} submitted by
* the client with database ID {@code fromClientDBId} from the server.
Expand Down
Loading