Skip to content

Commit e4846ae

Browse files
committed
0.16.0 - Update to 1.21.11
1 parent 79ad0d6 commit e4846ae

File tree

15 files changed

+438
-435
lines changed

15 files changed

+438
-435
lines changed

Cargo.lock

Lines changed: 314 additions & 305 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "shaysbot"
3-
version = "0.15.22"
3+
version = "0.16.0"
44
authors = ["Shayne Hartford <shaybox@shaybox.com>"]
55
edition = "2024"
66
description = "My personal Minecraft bot using Azalea"
@@ -20,7 +20,7 @@ ncr = { git = "https://github.com/Shays-Forks/ncr-rs", rev = "4004292" }
2020

2121
[dependencies]
2222
anyhow = "1"
23-
azalea = { git = "https://github.com/azalea-rs/azalea", default-features = false, features = ["packet-event", "serde"] }
23+
azalea = { git = "https://github.com/azalea-rs/azalea", default-features = false, features = ["packet-event", "serde", "online-mode"] }
2424
azalea-viaversion = { git = "https://github.com/azalea-rs/azalea-viaversion", optional = true }
2525
#azalea-viaversion = { path = "../azalea-viaversion", optional = true }
2626
base64 = "0.22"

src/lib.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ pub mod trackers;
2424

2525
use std::{collections::HashMap, sync::Arc, time::Duration};
2626

27-
use anyhow::{Result, bail};
27+
use anyhow::{bail, Result};
2828
use azalea::{
29-
DefaultPlugins,
30-
app::{AppExit, PluginGroup, PluginGroupBuilder},
29+
app::{PluginGroup, PluginGroupBuilder},
3130
bot::DefaultBotPlugins,
3231
ecs::prelude::*,
3332
pong::PongPlugin,
3433
prelude::*,
35-
swarm::{DefaultSwarmPlugins, prelude::*},
34+
swarm::{prelude::*, DefaultSwarmPlugins},
35+
DefaultPlugins,
3636
};
3737
#[cfg(feature = "via")]
3838
use azalea_viaversion::ViaVersionPlugin;
39-
use bevy_discord::DiscordBotPlugin;
4039
#[cfg(feature = "bot")]
4140
use bevy_discord::config::DiscordBotConfig;
41+
use bevy_discord::DiscordBotPlugin;
4242
use parking_lot::RwLock;
4343
use semver::Version;
4444
#[cfg(feature = "bot")]
@@ -135,10 +135,9 @@ pub async fn start() -> Result<()> {
135135
client = client.add_plugins(ViaVersionPlugin::start(&global_settings.server_version).await);
136136
}
137137

138-
if let AppExit::Error(error) = client.start(global_settings.server_address).await? {
139-
bail!(error)
140-
}
141-
138+
client
139+
.start(global_settings.server_address.to_string())
140+
.await;
142141
Ok(())
143142
}
144143

@@ -178,13 +177,7 @@ pub async fn swarm_handler(swarm: Swarm, event: SwarmEvent, state: SwarmState) -
178177
}
179178

180179
info!("AutoReconnecting on {}", account.username);
181-
if let Err(reason) = swarm.add_with_opts(account, state.clone(), join_opts).await {
182-
warn!("[{bot_name}] Failed to AutoReconnect: {reason}");
183-
info!("[{bot_name}] AutoReconnecting in 30s...");
184-
185-
state.auto_reconnect.write().entry(bot_name).or_default().1 = 30;
186-
continue;
187-
}
180+
swarm.add_with_opts(account, state.clone(), join_opts).await;
188181

189182
break;
190183
},

src/modules/auto_eat.rs

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@ use std::{cmp::Ordering, collections::HashMap, sync::LazyLock};
33
use azalea::{
44
app::{App, Plugin},
55
ecs::prelude::*,
6-
entity::{LocalEntity, LookDirection, metadata::Player},
6+
entity::{inventory::Inventory, metadata::Player, LocalEntity, LookDirection},
77
inventory::{
8+
operations::{ClickOperation, SwapClick},
89
ContainerClickEvent,
9-
Inventory,
1010
InventorySystems,
11-
operations::{ClickOperation, SwapClick},
1211
},
1312
local_player::Hunger,
1413
mining::continue_mining_block,
15-
packet::game::{SendGamePacketEvent, handle_outgoing_packets_observer},
14+
packet::game::{handle_outgoing_packets_observer, SendGamePacketEvent},
1615
physics::PhysicsSystems,
1716
prelude::*,
1817
protocol::packets::game::{
18+
s_interact::InteractionHand,
1919
ServerboundGamePacket,
2020
ServerboundUseItem,
21-
s_interact::InteractionHand,
2221
},
23-
registry::Item,
22+
registry::builtin::ItemKind,
2423
};
2524

2625
use crate::prelude::*;
@@ -119,41 +118,41 @@ impl AutoEatPlugin {
119118
}
120119
}
121120

122-
pub static FOOD_ITEMS: LazyLock<HashMap<Item, (i32, f32)>> = LazyLock::new(|| {
121+
pub static FOOD_ITEMS: LazyLock<HashMap<ItemKind, (i32, f32)>> = LazyLock::new(|| {
123122
HashMap::from([
124-
(Item::Apple, (4, 2.4)),
125-
(Item::BakedPotato, (5, 6.0)),
126-
(Item::Beef, (3, 1.8)),
127-
(Item::Beetroot, (1, 1.2)),
128-
(Item::BeetrootSoup, (6, 7.2)),
129-
(Item::Bread, (5, 6.0)),
130-
(Item::Carrot, (3, 3.6)),
131-
(Item::Chicken, (2, 1.2)),
132-
(Item::Cod, (2, 0.4)),
133-
(Item::CookedBeef, (8, 12.8)),
134-
(Item::CookedChicken, (6, 7.2)),
135-
(Item::CookedCod, (5, 6.0)),
136-
(Item::CookedMutton, (6, 9.6)),
137-
(Item::CookedPorkchop, (8, 12.8)),
138-
(Item::CookedRabbit, (5, 6.0)),
139-
(Item::CookedSalmon, (6, 9.6)),
140-
(Item::Cookie, (2, 0.4)),
141-
(Item::DriedKelp, (1, 0.6)),
142-
(Item::EnchantedGoldenApple, (4, 9.6)),
143-
(Item::GlowBerries, (2, 0.4)),
144-
(Item::GoldenApple, (4, 9.6)),
145-
(Item::GoldenCarrot, (6, 14.4)),
146-
(Item::HoneyBottle, (6, 1.2)),
147-
(Item::MelonSlice, (2, 1.2)),
148-
(Item::MushroomStew, (6, 7.2)),
149-
(Item::Mutton, (2, 1.2)),
150-
(Item::Porkchop, (3, 1.8)),
151-
(Item::Potato, (1, 0.6)),
152-
(Item::PumpkinPie, (8, 4.8)),
153-
(Item::Rabbit, (3, 1.8)),
154-
(Item::RabbitStew, (10, 12.0)),
155-
(Item::Salmon, (2, 0.4)),
156-
(Item::SweetBerries, (2, 0.4)),
157-
(Item::TropicalFish, (1, 0.2)),
123+
(ItemKind::Apple, (4, 2.4)),
124+
(ItemKind::BakedPotato, (5, 6.0)),
125+
(ItemKind::Beef, (3, 1.8)),
126+
(ItemKind::Beetroot, (1, 1.2)),
127+
(ItemKind::BeetrootSoup, (6, 7.2)),
128+
(ItemKind::Bread, (5, 6.0)),
129+
(ItemKind::Carrot, (3, 3.6)),
130+
(ItemKind::Chicken, (2, 1.2)),
131+
(ItemKind::Cod, (2, 0.4)),
132+
(ItemKind::CookedBeef, (8, 12.8)),
133+
(ItemKind::CookedChicken, (6, 7.2)),
134+
(ItemKind::CookedCod, (5, 6.0)),
135+
(ItemKind::CookedMutton, (6, 9.6)),
136+
(ItemKind::CookedPorkchop, (8, 12.8)),
137+
(ItemKind::CookedRabbit, (5, 6.0)),
138+
(ItemKind::CookedSalmon, (6, 9.6)),
139+
(ItemKind::Cookie, (2, 0.4)),
140+
(ItemKind::DriedKelp, (1, 0.6)),
141+
(ItemKind::EnchantedGoldenApple, (4, 9.6)),
142+
(ItemKind::GlowBerries, (2, 0.4)),
143+
(ItemKind::GoldenApple, (4, 9.6)),
144+
(ItemKind::GoldenCarrot, (6, 14.4)),
145+
(ItemKind::HoneyBottle, (6, 1.2)),
146+
(ItemKind::MelonSlice, (2, 1.2)),
147+
(ItemKind::MushroomStew, (6, 7.2)),
148+
(ItemKind::Mutton, (2, 1.2)),
149+
(ItemKind::Porkchop, (3, 1.8)),
150+
(ItemKind::Potato, (1, 0.6)),
151+
(ItemKind::PumpkinPie, (8, 4.8)),
152+
(ItemKind::Rabbit, (3, 1.8)),
153+
(ItemKind::RabbitStew, (10, 12.0)),
154+
(ItemKind::Salmon, (2, 0.4)),
155+
(ItemKind::SweetBerries, (2, 0.4)),
156+
(ItemKind::TropicalFish, (1, 0.2)),
158157
])
159158
});

src/modules/auto_kill.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ use azalea::{
55
attack::AttackEvent,
66
bot::LookAtEvent,
77
ecs::prelude::*,
8-
entity::{Position, dimensions::EntityDimensions, metadata::AbstractMonster},
8+
entity::{
9+
dimensions::EntityDimensions,
10+
inventory::Inventory,
11+
metadata::AbstractMonster,
12+
Position,
13+
},
914
inventory::{
10-
ContainerClickEvent,
11-
Inventory,
1215
operations::{ClickOperation, SwapClick},
16+
ContainerClickEvent,
1317
},
1418
nearest_entity::EntityFinder,
1519
pathfinder::Pathfinder,
1620
physics::PhysicsSystems,
1721
prelude::*,
18-
registry::Item,
22+
registry::builtin::ItemKind,
1923
};
2024

2125
use crate::prelude::*;
@@ -111,19 +115,19 @@ impl AutoKillPlugin {
111115
}
112116
}
113117

114-
pub static WEAPON_ITEMS: LazyLock<HashMap<Item, i32>> = LazyLock::new(|| {
118+
pub static WEAPON_ITEMS: LazyLock<HashMap<ItemKind, i32>> = LazyLock::new(|| {
115119
HashMap::from([
116-
(Item::DiamondAxe, 9),
117-
(Item::DiamondSword, 7),
118-
(Item::GoldenAxe, 7),
119-
(Item::GoldenSword, 4),
120-
(Item::IronAxe, 9),
121-
(Item::IronSword, 6),
122-
(Item::NetheriteAxe, 10),
123-
(Item::NetheriteSword, 8),
124-
(Item::StoneAxe, 9),
125-
(Item::StoneSword, 5),
126-
(Item::WoodenAxe, 7),
127-
(Item::WoodenSword, 4),
120+
(ItemKind::DiamondAxe, 9),
121+
(ItemKind::DiamondSword, 7),
122+
(ItemKind::GoldenAxe, 7),
123+
(ItemKind::GoldenSword, 4),
124+
(ItemKind::IronAxe, 9),
125+
(ItemKind::IronSword, 6),
126+
(ItemKind::NetheriteAxe, 10),
127+
(ItemKind::NetheriteSword, 8),
128+
(ItemKind::StoneAxe, 9),
129+
(ItemKind::StoneSword, 5),
130+
(ItemKind::WoodenAxe, 7),
131+
(ItemKind::WoodenSword, 4),
128132
])
129133
});

src/modules/auto_leave.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use azalea::{
2-
FormattedText,
32
app::{App, Plugin, Update},
43
auto_reconnect::start_rejoin_on_disconnect,
54
connection::RawConnection,
@@ -10,7 +9,8 @@ use azalea::{
109
packet::game::{GamePingEvent, ReceiveGamePacketEvent, SendGamePacketEvent},
1110
player::GameProfileComponent,
1211
protocol::packets::game::{ClientboundGamePacket, ServerboundPong},
13-
registry::EntityKind,
12+
registry::builtin::EntityKind,
13+
FormattedText,
1414
};
1515
use itertools::Itertools;
1616

src/modules/auto_totem.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use azalea::{
22
app::{App, Plugin},
33
ecs::prelude::*,
4+
entity::inventory::Inventory,
45
inventory::{
5-
ContainerClickEvent,
6-
Inventory,
7-
Menu,
86
handle_container_click_event,
97
operations::{ClickOperation, SwapClick},
8+
ContainerClickEvent,
9+
Menu,
1010
},
1111
prelude::*,
12-
registry::Item,
12+
registry::builtin::ItemKind,
1313
};
1414

1515
use crate::prelude::*;
@@ -43,13 +43,13 @@ impl AutoTotemPlugin {
4343
continue;
4444
};
4545

46-
if player.offhand.kind() == Item::TotemOfUndying {
46+
if player.offhand.kind() == ItemKind::TotemOfUndying {
4747
continue;
4848
}
4949

5050
let Some(index) = inventory.menu().slots()[8..]
5151
.iter()
52-
.position(|slot| slot.kind() == Item::TotemOfUndying)
52+
.position(|slot| slot.kind() == ItemKind::TotemOfUndying)
5353
.and_then(|index| u16::try_from(index + 8).ok())
5454
else {
5555
continue;

src/modules/auto_whitelist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use azalea::{
22
app::{App, Plugin, Update},
33
packet::game::ReceiveGamePacketEvent,
44
protocol::packets::game::ClientboundGamePacket,
5-
registry::EntityKind,
5+
registry::builtin::EntityKind,
66
};
77

88
use crate::prelude::*;

src/modules/discord_logger.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use azalea::{
22
app::{App, Plugin, Update},
3-
blocks::BlockTrait,
3+
block::BlockTrait,
44
disconnect::DisconnectEvent,
55
ecs::prelude::*,
66
local_player::TabList,
77
packet::{game::ReceiveGamePacketEvent, login::ReceiveLoginPacketEvent},
88
player::GameProfileComponent,
99
prelude::*,
1010
protocol::packets::game::ClientboundGamePacket,
11-
registry::EntityKind,
11+
registry::builtin::EntityKind,
1212
};
1313
use bevy_discord::res::DiscordHttpResource;
1414
use serenity::{
@@ -371,5 +371,5 @@ pub async fn send_message(content: impl ToString, channel_id: ChannelId, client:
371371

372372
if let Err(error) = client.send_message(channel_id, vec![], &map).await {
373373
error!("{error}");
374-
};
374+
}
375375
}

src/parsers/minecraft.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ use std::{
88
use anyhow::Result;
99
use azalea::{
1010
app::{App, Plugin, Update},
11-
chat::{ChatKind, ChatReceivedEvent, handle_send_chat_event, handler::SendChatKindEvent},
11+
chat::{handle_send_chat_event, handler::SendChatKindEvent, ChatKind, ChatReceivedEvent},
1212
ecs::prelude::*,
1313
local_player::TabList,
1414
};
1515
use ncr::{
16-
AesKey,
17-
NcrError,
1816
encoding::{
1917
Base64Encoding,
2018
Base64rEncoding,
@@ -25,6 +23,8 @@ use ncr::{
2523
},
2624
encryption::{Cfb8Encryption, EcbEncryption, Encryption, GcmEncryption},
2725
utils::{prepend_header, trim_header},
26+
AesKey,
27+
NcrError,
2828
};
2929

3030
use crate::prelude::*;
@@ -152,11 +152,10 @@ impl MinecraftParserPlugin {
152152
};
153153

154154
info!("Command Response: {}", event.content);
155-
if local_settings.anti_spam.enabled {
156-
if let Ok(duration) = SystemTime::now().duration_since(UNIX_EPOCH) {
155+
if local_settings.anti_spam.enabled
156+
&& let Ok(duration) = SystemTime::now().duration_since(UNIX_EPOCH) {
157157
let _ = write!(event.content, " [{}]", duration.as_secs());
158158
}
159-
}
160159

161160
try_encrypt(&mut event.content, &settings.chat, type_encryption);
162161
chat_kind_events.write(SendChatKindEvent {
@@ -252,11 +251,10 @@ pub fn find_encryption(content: &str, key: &AesKey) -> (Option<EncryptionType>,
252251
];
253252

254253
for encryptor in encryptors {
255-
if let Ok(plaintext) = encryptor.decrypt(content, key) {
256-
if let Ok(trimmed) = trim_header(&plaintext) {
254+
if let Ok(plaintext) = encryptor.decrypt(content, key)
255+
&& let Ok(trimmed) = trim_header(&plaintext) {
257256
return (Some(encryptor), String::from(trimmed));
258257
}
259-
}
260258
}
261259
}
262260

@@ -279,9 +277,9 @@ pub fn try_encrypt(
279277
if let Ok(ciphertext) = encryption.encrypt(&plaintext, &key) {
280278
*content = ciphertext;
281279
}
282-
} else if chat_encryption.mode == EncryptionMode::Always {
283-
if let Ok(ciphertext) = Cfb8Encryption(NewBase64rEncoding).encrypt(&plaintext, &key) {
284-
*content = ciphertext;
285-
}
280+
} else if chat_encryption.mode == EncryptionMode::Always
281+
&& let Ok(ciphertext) = Cfb8Encryption(NewBase64rEncoding).encrypt(&plaintext, &key)
282+
{
283+
*content = ciphertext;
286284
}
287285
}

0 commit comments

Comments
 (0)