File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ pub const Target = struct {
102102 source .sendMessage ("#ff0000Too few arguments for command" , .{});
103103 return error .TooFewArguments ;
104104 };
105- if (userIndex [0 ] == '@' ) {
105+ if (userIndex . len > 0 and userIndex [0 ] == '@' ) {
106106 const user = parsePlayerIndexAndIncreaseRefCount (userIndex , source ) catch return error .InvalidArgs ;
107107 increasedRefCount = true ;
108108 _ = split .next ();
Original file line number Diff line number Diff line change @@ -5,17 +5,21 @@ const User = main.server.User;
55
66const command = @import ("_command.zig" );
77
8- pub const description = "Get or set the player / world spawn point" ;
8+ pub const description = "Get or set a player's / the world spawn point" ;
99pub const usage =
1010 \\/spawn
1111 \\/spawn <x> <y> <z>
12+ \\/spawn @<playerIndex>
13+ \\/spawn @<playerIndex> <x> <y> <z>
1214 \\/spawn world
1315 \\/spawn world <x> <y> <z>
1416;
1517
1618pub fn execute (args : []const u8 , source : * User ) void {
1719 var split = std .mem .splitScalar (u8 , args , ' ' );
18- if (split .peek ().? .len > 0 ) {
20+ const target = command .Target .init (& split , source ) catch return ;
21+ defer target .deinit ();
22+ if (split .peek () != null and split .peek ().? .len > 0 ) {
1923 if (std .mem .eql (u8 , split .peek ().? , "world" )) {
2024 _ = split .next ();
2125 if (split .peek () == null or split .peek ().? .len == 0 ) {
@@ -38,8 +42,8 @@ pub fn execute(args: []const u8, source: *User) void {
3842 source .sendMessage ("#ff0000Too many arguments for command /spawn" , .{});
3943 return ;
4044 }
41- source .spawnPos = pos ;
45+ target . user .spawnPos = pos ;
4246 } else {
43- source .sendMessage ("#ffff00{}" , .{source .getSpawnPos ()});
47+ source .sendMessage ("#ffff00{}" , .{target . user .getSpawnPos ()});
4448 }
4549}
You can’t perform that action at this time.
0 commit comments