-
-
Notifications
You must be signed in to change notification settings - Fork 449
Expand file tree
/
Copy pathScriptCommandEvent.java
More file actions
88 lines (75 loc) · 2.3 KB
/
Copy pathScriptCommandEvent.java
File metadata and controls
88 lines (75 loc) · 2.3 KB
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
87
88
package ch.njol.skript.command;
import ch.njol.skript.effects.Delay;
import ch.njol.skript.util.Date;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* @deprecated There is no direct replacement for this class.
* The closest alternative is {@link org.skriptlang.skript.bukkit.command.custom.ScriptCommandEvent}.
*/
@Deprecated(since = "INSERT VERSION", forRemoval = true)
public class ScriptCommandEvent extends CommandEvent {
private final ScriptCommand scriptCommand;
private final String commandLabel;
private final String rest;
private final Date executionDate = new Date();
private boolean cooldownCancelled;
/**
* @param scriptCommand The script command executed.
* @param sender The executor of this script command.
* @param commandLabel The command name (may be the used alias)
* @param rest The rest of the command string (the arguments)
*/
public ScriptCommandEvent(ScriptCommand scriptCommand, CommandSender sender, String commandLabel, String rest) {
super(sender, scriptCommand.getLabel(), rest.split(" "));
this.scriptCommand = scriptCommand;
this.commandLabel = commandLabel;
this.rest = rest;
}
/**
* @return The script command executed.
*/
public ScriptCommand getScriptCommand() {
return scriptCommand;
}
/**
* @return The used command label. This may be a command alias.
*/
public String getCommandLabel() {
return commandLabel;
}
/**
* @return The arguments combined into one string.
* @see CommandEvent#getArgs()
*/
public String getArgsString() {
return rest;
}
/**
* Only accurate when this event is not delayed (yet)
*/
public boolean isCooldownCancelled() {
return cooldownCancelled;
}
public void setCooldownCancelled(boolean cooldownCancelled) {
if (Delay.isDelayed(this)) {
CommandSender sender = getSender();
if (sender instanceof Player) {
Date date = cooldownCancelled ? null : executionDate;
scriptCommand.setLastUsage(((Player) sender).getUniqueId(), this, date);
}
} else {
this.cooldownCancelled = cooldownCancelled;
}
}
// Bukkit stuff
private final static HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}