@@ -118,20 +118,20 @@ public Boolean runAsync() {
118118
119119 @ Override
120120 public Mixed exec (Target t , Environment environment , Mixed ... args ) throws ConfigRuntimeException {
121- String world ;
121+ MCWorld w ;
122122 if (args .length == 1 ) {
123- world = args [0 ].val ();
123+ w = Static . getServer (). getWorld ( args [0 ].val () );
124124 } else {
125- if (environment .getEnv (CommandHelperEnvironment .class ).GetPlayer () == null ) {
125+ MCPlayer p = environment .getEnv (CommandHelperEnvironment .class ).GetPlayer ();
126+ if (p == null ) {
126127 throw new CREInvalidWorldException ("A world must be specified in a context with no player." , t );
127128 }
128- world = environment . getEnv ( CommandHelperEnvironment . class ). GetPlayer (). getWorld (). getName ();
129+ w = p . getWorld ();
129130 }
130- MCWorld w = Static .getServer ().getWorld (world );
131131 if (w == null ) {
132- throw new CREInvalidWorldException ("The specified world \" " + world + "\" is not a valid world." , t );
132+ throw new CREInvalidWorldException ("The specified world \" " + args [ 0 ]. val () + "\" is not a valid world." , t );
133133 }
134- return ObjectGenerator .GetGenerator ().location (w .getSpawnLocation (), false );
134+ return ObjectGenerator .GetGenerator ().location (w .getSpawnLocation ());
135135 }
136136 }
137137
@@ -155,21 +155,30 @@ public Boolean runAsync() {
155155
156156 @ Override
157157 public Mixed exec (Target t , Environment environment , Mixed ... args ) throws ConfigRuntimeException {
158- MCPlayer p = environment .getEnv (CommandHelperEnvironment .class ).GetPlayer ();
159158 MCWorld w = null ;
160- if (p != null ) {
161- w = p .getWorld ();
159+ if (args .length == 1 ) {
160+ MCPlayer p = environment .getEnv (CommandHelperEnvironment .class ).GetPlayer ();
161+ if (p != null ) {
162+ w = p .getWorld ();
163+ }
164+ MCLocation l = ObjectGenerator .GetGenerator ().location (args [0 ], w , t );
165+ l .getWorld ().setSpawnLocation (l );
166+ return CVoid .VOID ;
167+ } else if (args .length == 2 ) {
168+ w = Static .getServer ().getWorld (args [0 ].val ());
169+ MCLocation l = ObjectGenerator .GetGenerator ().location (args [1 ], w , t );
170+ w .setSpawnLocation (l );
171+ return CVoid .VOID ;
162172 }
173+
163174 int x = 0 ;
164175 int y = 0 ;
165176 int z = 0 ;
166- if (args .length == 1 ) {
167- MCLocation l = ObjectGenerator .GetGenerator ().location (args [0 ], w , t );
168- w = l .getWorld ();
169- x = l .getBlockX ();
170- y = l .getBlockY ();
171- z = l .getBlockZ ();
172- } else if (args .length == 3 ) {
177+ if (args .length == 3 ) {
178+ MCPlayer p = environment .getEnv (CommandHelperEnvironment .class ).GetPlayer ();
179+ if (p != null ) {
180+ w = p .getWorld ();
181+ }
173182 x = ArgumentValidation .getInt32 (args [0 ], t );
174183 y = ArgumentValidation .getInt32 (args [1 ], t );
175184 z = ArgumentValidation .getInt32 (args [2 ], t );
@@ -193,14 +202,13 @@ public String getName() {
193202
194203 @ Override
195204 public Integer [] numArgs () {
196- return new Integer []{1 , 3 , 4 };
205+ return new Integer []{1 , 2 , 3 , 4 };
197206 }
198207
199208 @ Override
200209 public String docs () {
201- return "void {locationArray | [world], x, y, z} Sets the spawn of the world. Note that in some cases"
202- + " a plugin may override the spawn, and this method will do nothing. In that case,"
203- + " you should use the plugin's commands to set the spawn." ;
210+ return "void {[world], locationArray | [world], x, y, z} Sets the spawn of the world."
211+ + " Note that in some cases a plugin may override the spawn." ;
204212 }
205213
206214 @ Override
0 commit comments