Crossfire JXClient, Trunk
src
gui
src
main
java
com
realtime
crossfire
jxclient
commands
ScriptkillallCommand.java
Go to the documentation of this file.
1
/*
2
* This file is part of JXClient, the Fullscreen Java Crossfire Client.
3
*
4
* JXClient is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* JXClient is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with JXClient; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*
18
* Copyright (C) 2005-2008 Yann Chachkoff
19
* Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20
* Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21
*/
22
23
package
com.realtime.crossfire.jxclient.commands;
24
25
import
com
.
realtime
.
crossfire
.
jxclient
.
scripts
.
ScriptManager
;
26
import
com
.
realtime
.
crossfire
.
jxclient
.
scripts
.
ScriptProcess
;
27
import
com
.
realtime
.
crossfire
.
jxclient
.
server
.
crossfire
.
CrossfireServerConnection
;
28
import
java.util.Collection;
29
import
org.jetbrains.annotations.NotNull;
30
35
public
class
ScriptkillallCommand
extends
AbstractCommand
{
36
40
@NotNull
41
private
final
ScriptManager
scriptManager
;
42
48
public
ScriptkillallCommand
(@NotNull
final
ScriptManager
scriptManager
, @NotNull
final
CrossfireServerConnection
crossfireServerConnection
) {
49
super(
"scriptkillall"
,
crossfireServerConnection
);
50
this.scriptManager =
scriptManager
;
51
}
52
53
@Override
54
public
boolean
allArguments
() {
55
return
false
;
56
}
57
58
@Override
59
public
void
execute
(@NotNull
final
String args) {
60
final
Collection<ScriptProcess> scriptProcesses =
scriptManager
.
getScripts
(args);
61
if
(scriptProcesses.isEmpty()) {
62
drawInfoError
(
scriptManager
.
hasScripts
() ?
"No matching scripts."
:
"No scripts running."
);
63
return
;
64
}
65
scriptProcesses.forEach(
ScriptProcess::killScript
);
66
}
67
68
@NotNull
69
@Override
70
public
String
getHelp
() {
71
//noinspection StringBufferReplaceableByString
72
final
StringBuilder sb =
new
StringBuilder();
73
sb.append(
"Stops a running client-sided scripts\n"
);
74
sb.append(
"\n"
);
75
sb.append(
"Usage: scriptkillall\n"
);
76
sb.append(
"Usage: scriptkillall <script>\n"
);
77
sb.append(
"\n"
);
78
sb.append(
"Stops the running client-sided scripts <script>. "
);
79
sb.append(
"<script> is the ID of a running client-sided script or the partial name of a running client-sided script. "
);
80
sb.append(
"If <script> is omitted, all running client-sided-scripts are killed. Otherwise all matching client-sided scripts are killed.\n"
);
81
sb.append(
"Note: Kill only one client-sided script: scriptkill\n"
);
82
return
sb.toString();
83
}
84
85
}
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.commands.ScriptkillallCommand.getHelp
String getHelp()
Definition:
ScriptkillallCommand.java:70
com.realtime.crossfire.jxclient.commands.ScriptkillallCommand.allArguments
boolean allArguments()
Definition:
ScriptkillallCommand.java:54
com.realtime.crossfire.jxclient.server
com.realtime.crossfire.jxclient.commands.ScriptkillallCommand.execute
void execute(@NotNull final String args)
Definition:
ScriptkillallCommand.java:59
com.realtime.crossfire.jxclient.scripts.ScriptManager.getScripts
Set< ScriptProcess > getScripts(@NotNull final String partialScriptName)
Definition:
ScriptManager.java:163
com.realtime.crossfire.jxclient.commands.ScriptkillallCommand.ScriptkillallCommand
ScriptkillallCommand(@NotNull final ScriptManager scriptManager, @NotNull final CrossfireServerConnection crossfireServerConnection)
Definition:
ScriptkillallCommand.java:48
com.realtime.crossfire.jxclient.commands.ScriptkillallCommand.scriptManager
final ScriptManager scriptManager
Definition:
ScriptkillallCommand.java:41
com.realtime.crossfire.jxclient.commands.AbstractCommand.crossfireServerConnection
final CrossfireServerConnection crossfireServerConnection
Definition:
AbstractCommand.java:45
com.realtime.crossfire.jxclient.scripts.ScriptManager
Definition:
ScriptManager.java:46
com.realtime.crossfire.jxclient.commands.AbstractCommand.drawInfoError
void drawInfoError(@NotNull final String message)
Definition:
AbstractCommand.java:69
com.realtime.crossfire.jxclient.scripts
Definition:
AbstractScriptProcess.java:23
com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection
Definition:
CrossfireServerConnection.java:37
com.realtime.crossfire.jxclient.scripts.ScriptProcess.killScript
void killScript()
com.realtime.crossfire.jxclient.scripts.ScriptManager.hasScripts
boolean hasScripts()
Definition:
ScriptManager.java:203
com.realtime.crossfire.jxclient.server.crossfire
Definition:
AbstractCrossfireServerConnection.java:23
com.realtime.crossfire
com.realtime.crossfire.jxclient.scripts.ScriptProcess
Definition:
ScriptProcess.java:31
com.realtime
com.realtime.crossfire.jxclient.commands.ScriptkillallCommand
Definition:
ScriptkillallCommand.java:35
com
com.realtime.crossfire.jxclient.commands.AbstractCommand
Definition:
AbstractCommand.java:33
Generated by
1.8.17