-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add prototype for /give command * fix /give namespace * fix accidentally replaced text * remove dbg! statements * replace block_registry with item_registry * sync added items with client * warn!(..) => log::warn!(..) --------- Co-authored-by: user622628252416 <[email protected]>
- Loading branch information
1 parent
41e71a8
commit 16dabf1
Showing
16 changed files
with
470 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,60 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::{command::dispatcher::InvalidTreeError, server::Server}; | ||
|
||
use super::{ | ||
super::{ | ||
args::{ArgumentConsumer, RawArgs}, | ||
CommandSender, | ||
}, | ||
Arg, DefaultNameArgConsumer, FindArg, | ||
}; | ||
|
||
pub(crate) struct ItemArgumentConsumer; | ||
|
||
#[async_trait] | ||
impl ArgumentConsumer for ItemArgumentConsumer { | ||
async fn consume<'a>( | ||
&self, | ||
_sender: &CommandSender<'a>, | ||
_server: &'a Server, | ||
args: &mut RawArgs<'a>, | ||
) -> Option<Arg<'a>> { | ||
let s = args.pop()?; | ||
|
||
let name = if s.contains(':') { | ||
s.to_string() | ||
} else { | ||
format!("minecraft:{s}") | ||
}; | ||
|
||
// todo: get an actual item | ||
Some(Arg::Item(name)) | ||
} | ||
} | ||
|
||
impl DefaultNameArgConsumer for ItemArgumentConsumer { | ||
fn default_name(&self) -> &'static str { | ||
"item" | ||
} | ||
|
||
fn get_argument_consumer(&self) -> &dyn ArgumentConsumer { | ||
self | ||
} | ||
} | ||
|
||
impl<'a> FindArg<'a> for ItemArgumentConsumer { | ||
type Data = &'a str; | ||
|
||
fn find_arg( | ||
args: &'a super::ConsumedArgs, | ||
name: &'a str, | ||
) -> Result<Self::Data, InvalidTreeError> { | ||
match args.get(name) { | ||
Some(Arg::Item(name)) => Ok(name), | ||
_ => Err(InvalidTreeError::InvalidConsumptionError(Some( | ||
name.to_string(), | ||
))), | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains 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 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
Oops, something went wrong.