33import com .laytonsmith .PureUtilities .Common .StringUtils ;
44import com .laytonsmith .PureUtilities .Version ;
55import com .laytonsmith .abstraction .MCAttributeModifier ;
6+ import com .laytonsmith .abstraction .MCLeashable ;
67import com .laytonsmith .abstraction .MCNamespacedKey ;
78import com .laytonsmith .abstraction .blocks .MCMaterial ;
89import com .laytonsmith .abstraction .MCAnimalTamer ;
@@ -1062,11 +1063,14 @@ public static class get_leashholder extends EntityManagement.EntityGetterFunctio
10621063
10631064 @ Override
10641065 public Mixed exec (Target t , Environment environment , Mixed ... args ) throws ConfigRuntimeException {
1065- MCLivingEntity le = Static .getLivingEntity (args [0 ], t );
1066- if (!le .isLeashed ()) {
1066+ MCEntity e = Static .getEntity (args [0 ], t );
1067+ if (!(e instanceof MCLeashable )) {
1068+ throw new CREBadEntityException ("Entity type is not leashable." , t );
1069+ }
1070+ if (!((MCLeashable ) e ).isLeashed ()) {
10671071 return CNull .NULL ;
10681072 }
1069- return new CString (le .getLeashHolder ().getUniqueId ().toString (), t );
1073+ return new CString ((( MCLeashable ) e ) .getLeashHolder ().getUniqueId ().toString (), t );
10701074 }
10711075
10721076 @ Override
@@ -1076,8 +1080,9 @@ public String getName() {
10761080
10771081 @ Override
10781082 public String docs () {
1079- return "string {entityUUID} Returns the UUID of the entity that is holding the given living entity's leash,"
1080- + " or null if it isn't being held." ;
1083+ return "string {entityUUID} Returns the UUID of the entity that is holding the given entity's leash,"
1084+ + " or null if it isn't being held. Only mobs and boats can be leashed, otherwise a"
1085+ + " BadEntityException is thrown. Boats are only supported on Paper 1.21.3+ and Spigot 1.21.10+." ;
10811086 }
10821087
10831088 @ Override
@@ -1091,14 +1096,17 @@ public static class set_leashholder extends EntityManagement.EntitySetterFunctio
10911096
10921097 @ Override
10931098 public Mixed exec (Target t , Environment environment , Mixed ... args ) throws ConfigRuntimeException {
1094- MCLivingEntity le = Static .getLivingEntity (args [0 ], t );
1099+ MCEntity e = Static .getEntity (args [0 ], t );
10951100 MCEntity holder ;
10961101 if (args [1 ] instanceof CNull ) {
10971102 holder = null ;
10981103 } else {
10991104 holder = Static .getEntity (args [1 ], t );
11001105 }
1101- le .setLeashHolder (holder );
1106+ if (!(e instanceof MCLeashable )) {
1107+ throw new CREBadEntityException ("Entity type is not leashable." , t );
1108+ }
1109+ ((MCLeashable ) e ).setLeashHolder (holder );
11021110 return CVoid .VOID ;
11031111 }
11041112
@@ -1109,11 +1117,10 @@ public String getName() {
11091117
11101118 @ Override
11111119 public String docs () {
1112- return "void {entityUUID, entityUUID} The first argument is the entity to be held on a leash,"
1113- + " and must be living. The second is the holder of the leash. This does not have to be living,"
1114- + " but the only non-living entity that will persist as a holder across restarts is the leash hitch."
1115- + " Players, bats, enderdragons, withers and certain other entities can not be held by leashes due"
1116- + " to minecraft limitations." ;
1120+ return "void {entityUUID, holderUUID} The first argument is the entity to be held on a leash, and must be a"
1121+ + " mob or a boat. The second is the holder of the leash and can be many types of entities,"
1122+ + " notably a leash hitch. Certain entity types may be excluded from being leashed depending on the"
1123+ + " Minecraft version. Boats are only supported on Paper 1.21.3+ and Spigot 1.21.10+." ;
11171124 }
11181125
11191126 @ Override
0 commit comments