blob: 8a5972ae5f1535bd32193b3ba85d3c8c678092c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package org.bukkit.event.server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
/**
* This event is called when a command is run from the server console. It is
* called early in the command handling process, and modifications in this
* event (via {@link #setCommand(String)}) will be shown in the behavior.
* <p>
* Many plugins will have <b>no use for this event</b>, and you should
* attempt to avoid using it if it is not necessary.
* <p>
* Some examples of valid uses for this event are:
* <ul>
* <li>Logging executed commands to a separate file
* <li>Variable substitution. For example, replacing <code>${ip:Steve}</code>
* with the connection IP of the player named Steve, or simulating the
* <code>@a</code> and <code>@p</code> decorators used by Command Blocks
* for plugins that do not handle it.
* <li>Conditionally blocking commands belonging to other plugins.
* <li>Per-sender command aliases. For example, after the console runs the
* command <code>/calias cr gamemode creative</code>, the next time they
* run <code>/cr</code>, it gets replaced into
* <code>/gamemode creative</code>. (Global command aliases should be
* done by registering the alias.)
* </ul>
* <p>
* Examples of incorrect uses are:
* <ul>
* <li>Using this event to run command logic
* </ul>
* <p>
* If the event is cancelled, processing of the command will halt.
* <p>
* The state of whether or not there is a slash (<code>/</code>) at the
* beginning of the message should be preserved. If a slash is added or
* removed, unexpected behavior may result.
*/
public class ServerCommandEvent extends ServerEvent {
private static final HandlerList handlers = new HandlerList();
private String command;
private final CommandSender sender;
public ServerCommandEvent(final CommandSender sender, final String command) {
this.command = command;
this.sender = sender;
}
/**
* Gets the command that the user is attempting to execute from the
* console
*
* @return Command the user is attempting to execute
*/
public String getCommand() {
return command;
}
/**
* Sets the command that the server will execute
*
* @param message New message that the server will execute
*/
public void setCommand(String message) {
this.command = message;
}
/**
* Get the command sender.
*
* @return The sender
*/
public CommandSender getSender() {
return sender;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
|