-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAttachCommand.java
More file actions
40 lines (34 loc) · 1.29 KB
/
AttachCommand.java
File metadata and controls
40 lines (34 loc) · 1.29 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
package com.denizenscript.clientizen.scripts.commands;
import com.denizenscript.clientizen.tags.EntityTag;
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.scripts.commands.AbstractCommand;
import com.denizenscript.denizencore.scripts.commands.generator.ArgLinear;
import com.denizenscript.denizencore.scripts.commands.generator.ArgName;
import com.denizenscript.denizencore.scripts.commands.generator.ArgPrefixed;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class AttachCommand extends AbstractCommand {
public static Map<UUID, EntityTag> attachedEntities = new HashMap<>();
public AttachCommand() {
setName("attach");
setSyntax("attach [<entity>|...] [to:<entity>] (cancel)");
setRequiredArguments(2, 2);
isProcedural = false;
autoCompile();
}
public static void autoExecute(ScriptEntry scriptEntry,
@ArgLinear @ArgName("entities") List<EntityTag> attachingEntities,
@ArgPrefixed @ArgName("to") EntityTag entity,
@ArgName("cancel") boolean cancel) {
for (EntityTag attachingEntity : attachingEntities) {
if (cancel) {
attachedEntities.remove(attachingEntity.uuid);
}
else {
attachedEntities.put(attachingEntity.uuid, entity);
}
}
}
}