Skip to content

Commit

Permalink
Alternate solution to command api. (valence-rs#446)
Browse files Browse the repository at this point in the history
# Objective

I want to add commands ergonomically, unfortunately @Jenya705 's
implementation did not look to promising for my purposes so I am working
on an alternative command api.

# Solution

lib-users should be able to make commands quickly and easily.

Some objectives in the order I plan to implement them:

- [x] Sync commands to players based on command visibility scope.
- [x] Derive Macro
- [x] Execute and handle commands.
- [x] Parse commands with a lot of lib-user friendly options.
- [ ] ~~Handle server-side suggestions.~~ (this has been defered to the
future)

---------

Co-authored-by: Carson McManus <[email protected]>
Co-authored-by: Ryan Johnson <[email protected]>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent 99f88ae commit f43e60e
Show file tree
Hide file tree
Showing 36 changed files with 4,743 additions and 197 deletions.
21 changes: 16 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ default = [
"player_list",
"scoreboard",
"world_border",
"command",
"weather",
"testing",
]
Expand All @@ -34,6 +35,7 @@ network = ["dep:valence_network"]
player_list = ["dep:valence_player_list"]
scoreboard = ["dep:valence_scoreboard"]
world_border = ["dep:valence_world_border"]
command = ["dep:valence_command", "dep:valence_command_macros"]
weather = ["dep:valence_weather"]
testing = []

Expand All @@ -42,25 +44,28 @@ anyhow.workspace = true
bevy_app.workspace = true
bevy_ecs.workspace = true
bevy_log = { workspace = true, optional = true }
uuid.workspace = true
bytes.workspace = true
rand.workspace = true
uuid.workspace = true
valence_advancement = { workspace = true, optional = true }
valence_anvil = { workspace = true, optional = true, features = [
"bevy_plugin",
] }
valence_boss_bar = { workspace = true, optional = true }
valence_server.workspace = true
valence_command = { workspace = true, optional = true }
valence_command_macros = { workspace = true, optional = true }
valence_ident_macros.workspace = true
valence_ident.workspace = true
valence_inventory = { workspace = true, optional = true }
valence_lang.workspace = true
valence_network = { workspace = true, optional = true }
valence_player_list = { workspace = true, optional = true }
valence_registry.workspace = true
valence_scoreboard = { workspace = true, optional = true }
valence_server.workspace = true
valence_text.workspace = true
valence_weather = { workspace = true, optional = true }
valence_world_border = { workspace = true, optional = true }
valence_lang.workspace = true
valence_text.workspace = true
valence_ident.workspace = true

[dev-dependencies]
anyhow.workspace = true
Expand Down Expand Up @@ -106,6 +111,7 @@ async-trait = "0.1.60"
atty = "0.2.14"
base64 = "0.21.0"
bevy_app = { version = "0.11", default-features = false }
bevy_derive = "0.11.2"
bevy_ecs = { version = "0.11", default-features = false, features = [
"multi-threaded",
] }
Expand Down Expand Up @@ -141,8 +147,10 @@ noise = "0.8.2"
num = "0.4.0"
num-bigint = "0.4.3"
owo-colors = "3.5.0"
ordered-float = "3.7.0"
parking_lot = "0.12.1"
paste = "1.0.11"
petgraph = "0.6.3"
pretty_assertions = "1.3.0"
proc-macro2 = "1.0.56"
quote = "1.0.26"
Expand All @@ -155,6 +163,7 @@ rsa = "0.9.2"
rsa-der = "0.3.0"
rustc-hash = "1.1.0"
serde = "1.0.160"
serde-value = "0.7.0"
serde_json = "1.0.96"
sha1 = "0.10.5"
sha2 = "0.10.6"
Expand All @@ -174,6 +183,8 @@ valence_advancement = { path = "crates/valence_advancement", version = "0.2.0-al
valence_anvil = { path = "crates/valence_anvil", version = "0.1.0" }
valence_boss_bar = { path = "crates/valence_boss_bar", version = "0.2.0-alpha.1" }
valence_build_utils = { path = "crates/valence_build_utils", version = "0.2.0-alpha.1" }
valence_command = { path = "crates/valence_command", version = "0.2.0-alpha.1" }
valence_command_macros = { path = "crates/valence_command_macros", version = "0.2.0-alpha.1" }
valence_entity = { path = "crates/valence_entity", version = "0.2.0-alpha.1" }
valence_generated = { path = "crates/valence_generated", version = "0.2.0-alpha.1" }
valence_ident = { path = "crates/valence_ident", version = "0.2.0-alpha.1" }
Expand Down
352 changes: 185 additions & 167 deletions assets/depgraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions crates/valence_command/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "valence_command"
description = "Command management for Valence"
readme = "README.md"
version.workspace = true
edition.workspace = true
repository.workspace = true
documentation.workspace = true
license.workspace = true

[dependencies]
anyhow.workspace = true
bevy_app.workspace = true
bevy_derive.workspace = true
bevy_ecs.workspace = true
byteorder.workspace = true
ordered-float.workspace = true
petgraph.workspace = true
thiserror.workspace = true
tracing.workspace = true

valence_server.workspace = true
valence_text.workspace = true
13 changes: 13 additions & 0 deletions crates/valence_command/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Valence Command

This plugin manages the command system for a valence server. It is responsible for parsing, storing, managing and
dispatching commands.

#### This plugin manages the following:

- Registering commands to a Command Graph which is used parse commands.
- Receiving commands from the client and turning them into events.
- Parsing commands and dispatching them in the registered executable format.
- Sending the command graph to clients.

See the module level documentation for more information.
Loading

0 comments on commit f43e60e

Please sign in to comment.