Crossfire JXClient, Trunk
src
gui
src
main
java
com
realtime
crossfire
jxclient
commands
ExecCommand.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
.
gui
.
commandlist
.
CommandList
;
26
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
textinput
.
CommandCallback
;
27
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
textinput
.
NoSuchCommandException
;
28
import
com
.
realtime
.
crossfire
.
jxclient
.
server
.
crossfire
.
CrossfireServerConnection
;
29
import
org.jetbrains.annotations.NotNull;
30
35
public
class
ExecCommand
extends
AbstractCommand
{
36
40
@NotNull
41
private
final
CommandCallback
commandCallback
;
42
48
public
ExecCommand
(@NotNull
final
CommandCallback
commandCallback
, @NotNull
final
CrossfireServerConnection
crossfireServerConnection
) {
49
super(
"exec"
,
crossfireServerConnection
);
50
this.commandCallback =
commandCallback
;
51
}
52
53
@Override
54
public
boolean
allArguments
() {
55
return
false
;
56
}
57
58
@Override
59
public
void
execute
(@NotNull
final
String args) {
60
if
(args.isEmpty()) {
61
drawInfoError
(
"Which command do you want to run?"
);
62
return
;
63
}
64
65
final
CommandList
commandList;
66
try
{
67
commandList =
commandCallback
.
getCommandList
(args);
68
}
catch
(
final
NoSuchCommandException
ex) {
69
drawInfoError
(ex.getMessage());
70
return
;
71
}
72
commandList.
execute
();
73
}
74
75
@NotNull
76
@Override
77
public
String
getHelp
() {
78
final
StringBuilder sb =
new
StringBuilder();
79
sb.append(
"Executes a client-sided action\n"
);
80
sb.append(
"\n"
);
81
sb.append(
"Usage: exec <command>\n"
);
82
sb.append(
"\n"
);
83
sb.append(
"Available client sided actions are:\n"
);
84
for
(
final
String command :
commandCallback
.
getCommandListNames
()) {
85
sb.append(
"- "
).append(command).append(
"\n"
);
86
}
87
return
sb.toString();
88
}
89
90
}
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.server
com.realtime.crossfire.jxclient.gui.commandlist.CommandList
Definition:
CommandList.java:34
com.realtime.crossfire.jxclient.gui.textinput
Definition:
ActivateCommandInputCommand.java:23
com.realtime.crossfire.jxclient.commands.ExecCommand.allArguments
boolean allArguments()
Definition:
ExecCommand.java:54
com.realtime.crossfire.jxclient.gui.commandlist
Definition:
CommandList.java:23
com.realtime.crossfire.jxclient.commands.ExecCommand
Definition:
ExecCommand.java:35
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback.getCommandList
CommandList getCommandList(@NotNull String args)
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback
Definition:
CommandCallback.java:33
com.realtime.crossfire.jxclient.commands.AbstractCommand.crossfireServerConnection
final CrossfireServerConnection crossfireServerConnection
Definition:
AbstractCommand.java:45
com.realtime.crossfire.jxclient.commands.ExecCommand.commandCallback
final CommandCallback commandCallback
Definition:
ExecCommand.java:41
com.realtime.crossfire.jxclient.commands.AbstractCommand.drawInfoError
void drawInfoError(@NotNull final String message)
Definition:
AbstractCommand.java:69
com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection
Definition:
CrossfireServerConnection.java:37
com.realtime.crossfire.jxclient.commands.ExecCommand.execute
void execute(@NotNull final String args)
Definition:
ExecCommand.java:59
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback.getCommandListNames
Collection< String > getCommandListNames()
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.gui.textinput.NoSuchCommandException
Definition:
NoSuchCommandException.java:31
com.realtime.crossfire.jxclient.gui.commandlist.CommandList.execute
void execute()
Definition:
CommandList.java:99
com.realtime.crossfire.jxclient.commands.ExecCommand.ExecCommand
ExecCommand(@NotNull final CommandCallback commandCallback, @NotNull final CrossfireServerConnection crossfireServerConnection)
Definition:
ExecCommand.java:48
com.realtime.crossfire.jxclient.server.crossfire
Definition:
AbstractCrossfireServerConnection.java:23
com.realtime.crossfire
com.realtime.crossfire.jxclient.commands.ExecCommand.getHelp
String getHelp()
Definition:
ExecCommand.java:77
com.realtime
com
com.realtime.crossfire.jxclient.commands.AbstractCommand
Definition:
AbstractCommand.java:33
Generated by
1.8.17