-
Notifications
You must be signed in to change notification settings - Fork 188
Set Spawn command (continuation of #2374) #2447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
71459fe
Create delete
Vinywar123 3f5f294
Added Changes
Vinywar123 58c00b7
Add files via upload
Vinywar123 9b0cc99
Add files via upload
Vinywar123 601c11c
Delete delete
Vinywar123 08aab5f
Merge branch 'PixelGuys:master' into Set_Spawn_Command
Vinywar123 7210271
change to transfer by kill command
Wunka 112cd53
rename playerSpawnPoint and format
Wunka ebf6063
remove Inventory snyc
Wunka 6abc4e5
send spawnPos on no arguments
Wunka bfc324a
readd removed line
Wunka 446500d
update desc and usage
Wunka dcd2644
format
Wunka ca614bb
Change one oversight while changing command name
Wunka 6d6d88f
remove spawn from client world struct
Wunka 526e052
accept suggestion
Wunka 4a74ec2
Merge branch 'master' into spawnCommand
Wunka 77fa6db
send spawn when x == null and extra if for y == null
Wunka 2f64797
change message
Wunka db7b006
change mseesage v2
Wunka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| const std = @import("std"); | ||
|
|
||
| const main = @import("main"); | ||
| const User = main.server.User; | ||
|
|
||
| pub const description = "Get or set the player spawn point"; | ||
| pub const usage = | ||
| \\/spawn | ||
| \\/spawn <x> <y> | ||
| \\/spawn <x> <y> <z> | ||
| ; | ||
|
|
||
| pub fn execute(args: []const u8, source: *User) void { | ||
| var x: ?f64 = null; | ||
| var y: ?f64 = null; | ||
| var z: ?f64 = null; | ||
| var split = std.mem.splitScalar(u8, args, ' '); | ||
| while(split.next()) |arg| { | ||
| if(arg.len == 0) break; | ||
| const num: f64 = std.fmt.parseFloat(f64, arg) catch { | ||
| source.sendMessage("#ff0000Expected number, found \"{s}\"", .{arg}); | ||
| return; | ||
| }; | ||
| if(x == null) { | ||
| x = num; | ||
| } else if(y == null) { | ||
| y = num; | ||
| } else if(z == null) { | ||
| z = num; | ||
| } else { | ||
| source.sendMessage("#ff0000Too many arguments for command /spawn", .{}); | ||
| return; | ||
| } | ||
| } | ||
| if(x == null) { | ||
| source.sendMessage("#ffff00{}", .{source.spawnPos}); | ||
| return; | ||
| } | ||
| if(y == null) { | ||
| source.sendMessage("#ff0000Invalid number of arguments for /spawn.\nUsage: \n" ++ usage, .{}); | ||
| return; | ||
| } | ||
| if(z == null) { | ||
| z = source.player.pos[2]; | ||
| } | ||
| x = std.math.clamp(x.?, -1e9, 1e9); // TODO: Remove after #310 is implemented | ||
| y = std.math.clamp(y.?, -1e9, 1e9); | ||
| z = std.math.clamp(z.?, -1e9, 1e9); | ||
|
|
||
| source.spawnPos = .{x.?, y.?, z.?}; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.