Skip to content

Commit 424f7ef

Browse files
committed
Add array lookup to CPermIdGetByName, add permId to permName lookup to CPermGet
1 parent 427c723 commit 424f7ef

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/main/java/com/github/theholywaffle/teamspeak3/commands/CPermGet.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,35 @@
2828

2929
import com.github.theholywaffle.teamspeak3.commands.parameter.KeyValueParam;
3030

31+
/**
32+
* Command to look up the value of a permission for the server query.
33+
* <p>
34+
* As this command returns both the numerical ID and the name of a permission,
35+
* it is also useful for looking up a permission's ID based on its name
36+
* and vice versa.
37+
* </p>
38+
*/
3139
public class CPermGet extends Command {
3240

41+
/**
42+
* Looks up a permission value based on the permission's name.
43+
*
44+
* @param permName
45+
* the name of the permission
46+
*/
3347
public CPermGet(String permName) {
3448
super("permget");
3549
add(new KeyValueParam("permsid", permName));
3650
}
3751

52+
/**
53+
* Looks up a permission value based on the permission's numerical ID.
54+
*
55+
* @param permId
56+
* the ID of the permission
57+
*/
58+
public CPermGet(int permId) {
59+
super("permget");
60+
add(new KeyValueParam("permid", permId));
61+
}
3862
}

src/main/java/com/github/theholywaffle/teamspeak3/commands/CPermIdGetByName.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* #L%
2727
*/
2828

29+
import com.github.theholywaffle.teamspeak3.commands.parameter.ArrayParameter;
2930
import com.github.theholywaffle.teamspeak3.commands.parameter.KeyValueParam;
3031

3132
public class CPermIdGetByName extends Command {
@@ -35,4 +36,13 @@ public CPermIdGetByName(String permName) {
3536
add(new KeyValueParam("permsid", permName));
3637
}
3738

39+
public CPermIdGetByName(String[] permNames) {
40+
super("permidgetbyname");
41+
final ArrayParameter permissions = new ArrayParameter();
42+
for (String p : permNames) {
43+
permissions.add(new KeyValueParam("permsid", p));
44+
}
45+
add(permissions);
46+
}
47+
3848
}

0 commit comments

Comments
 (0)