Skip to content

Commit ada3b56

Browse files
committed
Allow set_entity_rotation() on players when possible
Currently only supported on Paper 1.19 or above
1 parent c6a961e commit ada3b56

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/main/java/com/laytonsmith/core/functions/EntityManagement.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5659,10 +5659,6 @@ public Boolean runAsync() {
56595659
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
56605660
MCEntity entity = Static.getEntity(args[0], t);
56615661

5662-
if(entity instanceof MCPlayer) {
5663-
throw new CREUnsupportedOperationException(getName() + " cannot be used on players.", t);
5664-
}
5665-
56665662
float yaw = (float) ArgumentValidation.getDouble(args[1], t);
56675663
float pitch;
56685664
if(args.length == 3) {
@@ -5671,7 +5667,11 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime
56715667
pitch = entity.getLocation().getPitch();
56725668
}
56735669

5674-
entity.setRotation(yaw, pitch);
5670+
try {
5671+
entity.setRotation(yaw, pitch);
5672+
} catch(UnsupportedOperationException ex) {
5673+
throw new CREUnsupportedOperationException(getName() + " cannot be used on players.", t);
5674+
}
56755675
return CVoid.VOID;
56765676
}
56775677

@@ -5687,8 +5687,9 @@ public Integer[] numArgs() {
56875687

56885688
@Override
56895689
public String docs() {
5690-
return "void {entityUUID, yaw, [pitch]} Sets an entity's yaw and pitch without teleporting or ejecting. If used"
5691-
+ " on a player, an UnsupportedOperationException is thrown.";
5690+
return "void {entityUUID, yaw, [pitch]} Sets an entity's yaw and pitch without teleporting or ejecting."
5691+
+ " Can only be used on players when on Paper 1.19 or above, otherwise will throw an"
5692+
+ " UnsupportedOperationException.";
56925693
}
56935694

56945695
@Override

0 commit comments

Comments
 (0)