@@ -67,6 +67,7 @@ public static String docs() {
6767 }
6868
6969 @ api (environments = {CommandHelperEnvironment .class })
70+ @ seealso ({get_mob_owner_uuid .class , set_mob_owner .class })
7071 public static class get_mob_owner extends AbstractFunction {
7172
7273 @ Override
@@ -82,13 +83,14 @@ public Integer[] numArgs() {
8283 @ Override
8384 public String docs () {
8485 return "string {entityUUID} Returns the owner's name, or null if the mob is unowned."
85- + "An UntameableMobException is thrown if mob isn't tameable to begin with." ;
86+ + " Use {{function|get_mob_owner_uuid}} to get the owner's unique id."
87+ + " An UntameableMobException is thrown if mob isn't tameable to begin with." ;
8688 }
8789
8890 @ Override
8991 public Class <? extends CREThrowable >[] thrown () {
9092 return new Class []{CREUntameableMobException .class , CRELengthException .class ,
91- CREBadEntityException .class , CREIllegalArgumentException .class };
93+ CREBadEntityException .class , CREFormatException .class };
9294 }
9395
9496 @ Override
@@ -122,6 +124,63 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
122124 }
123125
124126 @ api (environments = {CommandHelperEnvironment .class })
127+ @ seealso ({get_mob_owner .class , set_mob_owner .class })
128+ public static class get_mob_owner_uuid extends AbstractFunction {
129+
130+ @ Override
131+ public String getName () {
132+ return "get_mob_owner_uuid" ;
133+ }
134+
135+ @ Override
136+ public Integer [] numArgs () {
137+ return new Integer []{1 };
138+ }
139+
140+ @ Override
141+ public String docs () {
142+ return "string {entityUUID} Returns the owner's UUID, or null if the mob is unowned."
143+ + "An UntameableMobException is thrown if mob isn't tameable to begin with." ;
144+ }
145+
146+ @ Override
147+ public Class <? extends CREThrowable >[] thrown () {
148+ return new Class []{CREUntameableMobException .class , CRELengthException .class ,
149+ CREBadEntityException .class , CREFormatException .class };
150+ }
151+
152+ @ Override
153+ public boolean isRestricted () {
154+ return true ;
155+ }
156+
157+ @ Override
158+ public MSVersion since () {
159+ return MSVersion .V3_3_5 ;
160+ }
161+
162+ @ Override
163+ public Boolean runAsync () {
164+ return false ;
165+ }
166+
167+ @ Override
168+ public Mixed exec (Target t , Environment environment , Mixed ... args ) throws ConfigRuntimeException {
169+ MCLivingEntity mob = Static .getLivingEntity (args [0 ], t );
170+ if (!mob .isTameable ()) {
171+ throw new CREUntameableMobException ("The specified entity is not tameable" , t );
172+ }
173+ MCAnimalTamer owner = ((MCTameable ) mob ).getOwner ();
174+ if (owner == null ) {
175+ return CNull .NULL ;
176+ } else {
177+ return new CString (owner .getUniqueID ().toString (), t );
178+ }
179+ }
180+ }
181+
182+ @ api (environments = {CommandHelperEnvironment .class })
183+ @ seealso ({get_mob_owner .class , get_mob_owner_uuid .class })
125184 public static class set_mob_owner extends AbstractFunction {
126185
127186 @ Override
@@ -136,15 +195,15 @@ public Integer[] numArgs() {
136195
137196 @ Override
138197 public String docs () {
139- return "void {entityUUID, player} Sets the tameable mob to the specified player. Offline players are "
140- + " supported, but this means that partial matches are NOT supported. You must type the player's "
141- + " name exactly. Setting the player to null will untame the mob." ;
198+ return "void {entityUUID, player} Sets the tameable mob to the specified player."
199+ + " The player argument supports offline players, so it should be a UUID or an exact player name. "
200+ + " Setting the player to null will untame the mob." ;
142201 }
143202
144203 @ Override
145204 public Class <? extends CREThrowable >[] thrown () {
146205 return new Class []{CREUntameableMobException .class , CRELengthException .class ,
147- CREBadEntityException .class , CREIllegalArgumentException .class };
206+ CREBadEntityException .class , CREFormatException .class };
148207 }
149208
150209 @ Override
@@ -173,7 +232,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
173232 if (player instanceof CNull ) {
174233 mct .setOwner (null );
175234 } else {
176- mct .setOwner (Static .getServer (). getOfflinePlayer ( player . val () ));
235+ mct .setOwner (Static .GetUser ( player , t ));
177236 }
178237 return CVoid .VOID ;
179238 }
0 commit comments