-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
LookCommand.java
132 lines (101 loc) · 4.31 KB
/
LookCommand.java
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package net.aufdemrand.denizen.scripts.commands.entity;
import java.util.Arrays;
import java.util.List;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dList;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.utilities.entity.Rotation;
import net.aufdemrand.denizen.objects.aH;
import net.aufdemrand.denizen.utilities.debugging.dB;
/**
* Controls Denizens' heads.
*
* @author Jeremy Schroeder
*
*/
public class LookCommand extends AbstractCommand {
// look (<entity>) [<location>]
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
if (!scriptEntry.hasObject("location")
&& arg.matchesArgumentType(dLocation.class)) {
scriptEntry.addObject("location", arg.asType(dLocation.class));
}
else if (!scriptEntry.hasObject("entities")
&& arg.matchesArgumentList(dEntity.class)) {
// Entity arg
scriptEntry.addObject("entities", ((dList) arg.asType(dList.class)).filter(dEntity.class));
}
}
// Use the NPC or player as the entity if no entities are specified
scriptEntry.defaultObject("entities",
scriptEntry.hasNPC() ? Arrays.asList(scriptEntry.getNPC().getDenizenEntity()) : null,
scriptEntry.hasPlayer() ? Arrays.asList(scriptEntry.getPlayer().getDenizenEntity()) : null);
if (!scriptEntry.hasObject("location") || !scriptEntry.hasObject("entities"))
throw new InvalidArgumentsException("Must specify a location and entity!");
}
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dLocation loc = (dLocation) scriptEntry.getObject("location");
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
dB.report(getName(), loc.debug() +
aH.debugObj("entities", entities.toString()));
for (dEntity entity : entities) {
if (entity.isSpawned() == true) {
Rotation.faceLocation(entity.getBukkitEntity(), loc);
}
}
}
/*
else if (lookWhere.equals("LEFT")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = theDenizen.getLocation().getYaw() - (float) 80;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("RIGHT")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = theDenizen.getLocation().getYaw() + (float) 80;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("UP")) {
theDenizen.lookClose(false);
theDenizen.getHandle().pitch = theDenizen.getHandle().pitch - (float) 60;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("DOWN")) {
theDenizen.lookClose(false);
theDenizen.getHandle().pitch = theDenizen.getHandle().pitch + (float) 40;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("BACK")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = theDenizen.getLocation().getYaw() - 180;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("SOUTH")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = 0;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("WEST")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = 90;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("NORTH")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = 180;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
else if (lookWhere.equals("EAST")) {
theDenizen.lookClose(false);
theDenizen.getHandle().yaw = 270;
theDenizen.getHandle().az = theDenizen.getHandle().yaw;
}
*/
}