mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
better docs for disabling plugins
This commit is contained in:
parent
5d799be9db
commit
1493c06de5
3 changed files with 25 additions and 13 deletions
|
@ -84,6 +84,8 @@ Azalea lets you create "swarms", which are a group of bots in the same world tha
|
|||
|
||||
Azalea uses [Bevy ECS](https://docs.rs/bevy_ecs) internally to store information about the world and clients. Bevy plugins are more powerful than async handler functions, but more difficult to use. See [pathfinder](https://github.com/azalea-rs/azalea/blob/main/azalea/src/pathfinder/mod.rs) as an example of how to make a plugin. You can then enable a plugin by adding `.add_plugin(ExamplePlugin)` in your client/swarm builder.
|
||||
|
||||
Everything in Azalea is implemented as a Bevy plugin, which means you can disable default behaviors (like, physics or chat signing) by disabling built-in plugins. See [`SwarmBuilder::new_without_plugins`] to learn how to do that.
|
||||
|
||||
Also note that just because something is an entity in the ECS doesn't mean that it's a Minecraft entity. You can filter for that by having `With<MinecraftEntityId>` as a filter.
|
||||
|
||||
See the [Bevy Cheatbook](https://bevy-cheatbook.github.io/programming/ecs-intro.html) to learn more about Bevy ECS (and the ECS paradigm in general).
|
||||
|
|
|
@ -94,8 +94,10 @@ impl ClientBuilder<NoState, ()> {
|
|||
.add_plugins(DefaultBotPlugins)
|
||||
}
|
||||
|
||||
/// [`Self::new`] but without adding the plugins by default. This is useful
|
||||
/// if you want to disable a default plugin.
|
||||
/// [`Self::new`] but without adding the plugins by default.
|
||||
///
|
||||
/// This is useful if you want to disable a default plugin. This also exists
|
||||
/// for swarms, see [`SwarmBuilder::new_without_plugins`].
|
||||
///
|
||||
/// Note that you can also disable `LogPlugin` by disabling the `log`
|
||||
/// feature.
|
||||
|
@ -104,12 +106,11 @@ impl ClientBuilder<NoState, ()> {
|
|||
///
|
||||
/// ```
|
||||
/// # use azalea::prelude::*;
|
||||
/// use azalea::{app::PluginGroup, DefaultBotPlugins, DefaultPlugins};
|
||||
/// use bevy_log::LogPlugin;
|
||||
/// use azalea::app::PluginGroup;
|
||||
///
|
||||
/// let client_builder = ClientBuilder::new_without_plugins()
|
||||
/// .add_plugins(DefaultPlugins.build().disable::<LogPlugin>())
|
||||
/// .add_plugins(DefaultBotPlugins);
|
||||
/// .add_plugins(azalea::DefaultPlugins.build().disable::<azalea::chat_signing::ChatSigningPlugin>())
|
||||
/// .add_plugins(azalea::DefaultBotPlugins);
|
||||
/// # client_builder.set_handler(handle);
|
||||
/// # #[derive(Component, Clone, Default)]
|
||||
/// # pub struct State;
|
||||
|
@ -171,6 +172,9 @@ where
|
|||
self
|
||||
}
|
||||
/// Add a group of plugins to the client.
|
||||
///
|
||||
/// See [`Self::new_without_plugins`] to learn how to disable default
|
||||
/// plugins.
|
||||
#[must_use]
|
||||
pub fn add_plugins<M>(mut self, plugins: impl Plugins<M>) -> Self {
|
||||
self.swarm = self.swarm.add_plugins(plugins);
|
||||
|
|
|
@ -112,21 +112,22 @@ impl SwarmBuilder<NoState, NoSwarmState, (), ()> {
|
|||
.add_plugins(DefaultSwarmPlugins)
|
||||
}
|
||||
|
||||
/// [`Self::new`] but without adding the plugins by default. This is useful
|
||||
/// if you want to disable a default plugin.
|
||||
/// [`Self::new`] but without adding the plugins by default.
|
||||
///
|
||||
/// This is useful if you want to disable a default plugin. This also exists
|
||||
/// for `ClientBuilder`, see [`ClientBuilder::new_without_plugins`].
|
||||
///
|
||||
/// You **must** add [`DefaultPlugins`], [`DefaultBotPlugins`], and
|
||||
/// [`DefaultSwarmPlugins`] to this.
|
||||
///
|
||||
/// ```
|
||||
/// # use azalea::{prelude::*, swarm::prelude::*};
|
||||
/// use azalea::{app::PluginGroup, DefaultBotPlugins, DefaultPlugins, swarm::{DefaultSwarmPlugins}};
|
||||
/// use bevy_log::LogPlugin;
|
||||
/// use azalea::app::PluginGroup;
|
||||
///
|
||||
/// let swarm_builder = SwarmBuilder::new_without_plugins()
|
||||
/// .add_plugins(DefaultPlugins.build().disable::<LogPlugin>())
|
||||
/// .add_plugins(DefaultBotPlugins)
|
||||
/// .add_plugins(DefaultSwarmPlugins);
|
||||
/// .add_plugins(azalea::DefaultPlugins.build().disable::<azalea::chat_signing::ChatSigningPlugin>())
|
||||
/// .add_plugins(azalea::DefaultBotPlugins)
|
||||
/// .add_plugins(azalea::swarm::DefaultSwarmPlugins);
|
||||
/// # swarm_builder.set_handler(handle).set_swarm_handler(swarm_handle);
|
||||
/// # #[derive(Component, Resource, Clone, Default)]
|
||||
/// # pub struct State;
|
||||
|
@ -137,6 +138,8 @@ impl SwarmBuilder<NoState, NoSwarmState, (), ()> {
|
|||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// [`ClientBuilder::new_without_plugins`]: crate::ClientBuilder::new_without_plugins
|
||||
#[must_use]
|
||||
pub fn new_without_plugins() -> Self {
|
||||
SwarmBuilder {
|
||||
|
@ -355,6 +358,9 @@ where
|
|||
}
|
||||
|
||||
/// Add one or more plugins to this swarm.
|
||||
///
|
||||
/// See [`Self::new_without_plugins`] to learn how to disable default
|
||||
/// plugins.
|
||||
#[must_use]
|
||||
pub fn add_plugins<M>(mut self, plugins: impl Plugins<M>) -> Self {
|
||||
self.app.add_plugins(plugins);
|
||||
|
|
Loading…
Add table
Reference in a new issue