Skip to content

Commit 54a10c4

Browse files
committed
Add reason parameter to the serverstop and serverprocessstop commands
1 parent 69334fa commit 54a10c4

4 files changed

Lines changed: 116 additions & 7 deletions

File tree

src/main/java/com/github/theholywaffle/teamspeak3/TS3Api.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,6 +4084,22 @@ public void stopServer(int serverId) {
40844084
asyncApi.stopServer(serverId).getUninterruptibly();
40854085
}
40864086

4087+
/**
4088+
* Stops the virtual server with the specified ID.
4089+
*
4090+
* @param serverId
4091+
* the ID of the virtual server
4092+
* @param reason
4093+
* the reason message to display to clients when they are disconnected
4094+
*
4095+
* @throws TS3CommandFailedException
4096+
* if the execution of a command fails
4097+
* @querycommands 1
4098+
*/
4099+
public void stopServer(int serverId, String reason) {
4100+
asyncApi.stopServer(serverId, reason).getUninterruptibly();
4101+
}
4102+
40874103
/**
40884104
* Stops the specified virtual server.
40894105
*
@@ -4098,6 +4114,22 @@ public void stopServer(VirtualServer virtualServer) {
40984114
asyncApi.stopServer(virtualServer).getUninterruptibly();
40994115
}
41004116

4117+
/**
4118+
* Stops the specified virtual server.
4119+
*
4120+
* @param virtualServer
4121+
* the virtual server to stop
4122+
* @param reason
4123+
* the reason message to display to clients when they are disconnected
4124+
*
4125+
* @throws TS3CommandFailedException
4126+
* if the execution of a command fails
4127+
* @querycommands 1
4128+
*/
4129+
public void stopServer(VirtualServer virtualServer, String reason) {
4130+
asyncApi.stopServer(virtualServer, reason).getUninterruptibly();
4131+
}
4132+
41014133
/**
41024134
* Stops the entire TeamSpeak 3 Server instance by shutting down the process.
41034135
* <p>
@@ -4112,6 +4144,23 @@ public void stopServerProcess() {
41124144
asyncApi.stopServerProcess().getUninterruptibly();
41134145
}
41144146

4147+
/**
4148+
* Stops the entire TeamSpeak 3 Server instance by shutting down the process.
4149+
* <p>
4150+
* To have permission to use this command, you need to use the server query admin login.
4151+
* </p>
4152+
*
4153+
* @param reason
4154+
* the reason message to display to clients when they are disconnected
4155+
*
4156+
* @throws TS3CommandFailedException
4157+
* if the execution of a command fails
4158+
* @querycommands 1
4159+
*/
4160+
public void stopServerProcess(String reason) {
4161+
asyncApi.stopServerProcess(reason).getUninterruptibly();
4162+
}
4163+
41154164
/**
41164165
* Unregisters the server query from receiving any event notifications.
41174166
*

src/main/java/com/github/theholywaffle/teamspeak3/TS3ApiAsync.java

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,7 +4708,25 @@ public CommandFuture<Void> startServer(VirtualServer virtualServer) {
47084708
* @querycommands 1
47094709
*/
47104710
public CommandFuture<Void> stopServer(int serverId) {
4711-
Command cmd = VirtualServerCommands.serverStop(serverId);
4711+
return stopServer(serverId, null);
4712+
}
4713+
4714+
/**
4715+
* Stops the virtual server with the specified ID.
4716+
*
4717+
* @param serverId
4718+
* the ID of the virtual server
4719+
* @param reason
4720+
* the reason message to display to clients when they are disconnected
4721+
*
4722+
* @return a future to track the progress of this command
4723+
*
4724+
* @throws TS3CommandFailedException
4725+
* if the execution of a command fails
4726+
* @querycommands 1
4727+
*/
4728+
public CommandFuture<Void> stopServer(int serverId, String reason) {
4729+
Command cmd = VirtualServerCommands.serverStop(serverId, reason);
47124730
return executeAndReturnError(cmd);
47134731
}
47144732

@@ -4725,7 +4743,25 @@ public CommandFuture<Void> stopServer(int serverId) {
47254743
* @querycommands 1
47264744
*/
47274745
public CommandFuture<Void> stopServer(VirtualServer virtualServer) {
4728-
return stopServer(virtualServer.getId());
4746+
return stopServer(virtualServer.getId(), null);
4747+
}
4748+
4749+
/**
4750+
* Stops the specified virtual server.
4751+
*
4752+
* @param virtualServer
4753+
* the virtual server to stop
4754+
* @param reason
4755+
* the reason message to display to clients when they are disconnected
4756+
*
4757+
* @return a future to track the progress of this command
4758+
*
4759+
* @throws TS3CommandFailedException
4760+
* if the execution of a command fails
4761+
* @querycommands 1
4762+
*/
4763+
public CommandFuture<Void> stopServer(VirtualServer virtualServer, String reason) {
4764+
return stopServer(virtualServer.getId(), reason);
47294765
}
47304766

47314767
/**
@@ -4741,7 +4777,26 @@ public CommandFuture<Void> stopServer(VirtualServer virtualServer) {
47414777
* @querycommands 1
47424778
*/
47434779
public CommandFuture<Void> stopServerProcess() {
4744-
Command cmd = ServerCommands.serverProcessStop();
4780+
return stopServerProcess(null);
4781+
}
4782+
4783+
/**
4784+
* Stops the entire TeamSpeak 3 Server instance by shutting down the process.
4785+
* <p>
4786+
* To have permission to use this command, you need to use the server query admin login.
4787+
* </p>
4788+
*
4789+
* @param reason
4790+
* the reason message to display to clients when they are disconnected
4791+
*
4792+
* @return a future to track the progress of this command
4793+
*
4794+
* @throws TS3CommandFailedException
4795+
* if the execution of a command fails
4796+
* @querycommands 1
4797+
*/
4798+
public CommandFuture<Void> stopServerProcess(String reason) {
4799+
Command cmd = ServerCommands.serverProcessStop(reason);
47454800
return executeAndReturnError(cmd);
47464801
}
47474802

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ public static Command logView(int lines, boolean instance) {
7070
return builder.build();
7171
}
7272

73-
public static Command serverProcessStop() {
74-
return new CommandBuilder("serverprocessstop").build();
73+
public static Command serverProcessStop(String reason) {
74+
CommandBuilder builder = new CommandBuilder("serverprocessstop", 1);
75+
builder.addIf(reason != null, new KeyValueParam("reasonmsg", reason));
76+
return builder.build();
7577
}
7678

7779
public static Command version() {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ public static Command serverStart(int id) {
9393
return new CommandBuilder("serverstart", 1).add(new KeyValueParam("sid", id)).build();
9494
}
9595

96-
public static Command serverStop(int id) {
97-
return new CommandBuilder("serverstop", 1).add(new KeyValueParam("sid", id)).build();
96+
public static Command serverStop(int id, String reason) {
97+
CommandBuilder builder = new CommandBuilder("serverstop", 2);
98+
builder.add(new KeyValueParam("sid", id));
99+
builder.addIf(reason != null, new KeyValueParam("reasonmsg", reason));
100+
return builder.build();
98101
}
99102
}

0 commit comments

Comments
 (0)