EnderKill98 / stasis-bot

A stupidly simple, but yet very impressive minecraft stasis-bot thanks to azalea!
MIT License
5 stars 1 forks source link

azelea viaversion #2

Open kittenvr opened 2 months ago

kittenvr commented 2 months ago

can you try to add azelea viaversion again the commit said it is fixed

EnderKill98 commented 1 month ago

If you mean this commit: https://github.com/azalea-rs/azalea-viaversion/commit/c74b5e02b9d29875c79c746bdfb70d1116bda49a

This is already the one, I use as basis on here: https://github.com/EnderKill98/azalea-viaversion/commits/feature/no-default-features-and-update-via-proxy/

Via is still broken, when I update azalea to the current version:

grafik

So same issue as in https://github.com/azalea-rs/azalea-viaversion/issues/7. I once tried to fix this, but failed after trying a few hours.


I also tried to update the bot to 1.21: https://github.com/EnderKill98/stasis-bot/commit/698dbebd6ba98d8a6cbf17fc09beaaec6857acb1

It "works". But there is a funny new bug:

grafik

Expected messages:

grafik

So it seems that some messages get duplicated. I'm honestly getting tired of fixing all these issues. At least commands can now be sent without getting kicked...

The order is also wrong. Maybe my issue of how I log though.

One of the chat messages, printed as json Code: ```rust async fn handle(mut bot: Client, event: Event, mut bot_state: BotState) -> anyhow::Result<()> { match event { // Event::Chat(packet) => { let message_json: serde_json::Value = serde_json::to_value(packet.message())?; let message_json_str = serde_json::to_string_pretty(&message_json)?; info!("Chat JSON: {message_json_str}"); info!( "CHAT: {}", if OPTS.no_color { packet.message().to_string() } else { packet.message().to_ansi() } ); let message = packet.message().to_string(); } // } ``` Outputted JSON: ```json 2024-09-30T15:58:53.346350Z INFO stasis_bot: Chat JSON: { "extra": [ { "color": "dark_green", "extra": [ { "color": "green", "text": "Show Redstone Block Updates" }, { "color": "green", "text": ": " }, { "bold": false, "color": "aqua", "text": "[On]" }, { "text": " " }, { "bold": true, "color": "aqua", "text": "[Off]" } ], "siblings": [ { "color": "green", "text": "Show Redstone Block Updates" }, { "color": "green", "text": ": " }, { "bold": false, "color": "aqua", "text": "[On]" }, { "text": " " }, { "bold": true, "color": "aqua", "text": "[Off]" } ], "text": " - " }, { "color": "green", "text": "Show Redstone Block Updates" }, { "color": "green", "text": ": " }, { "bold": false, "color": "aqua", "text": "[On]" }, { "text": " " }, { "bold": true, "color": "aqua", "text": "[Off]" } ], "siblings": [ { "color": "dark_green", "extra": [ { "color": "green", "text": "Show Redstone Block Updates" }, { "color": "green", "text": ": " }, { "bold": false, "color": "aqua", "text": "[On]" }, { "text": " " }, { "bold": true, "color": "aqua", "text": "[Off]" } ], "siblings": [ { "color": "green", "text": "Show Redstone Block Updates" }, { "color": "green", "text": ": " }, { "bold": false, "color": "aqua", "text": "[On]" }, { "text": " " }, { "bold": true, "color": "aqua", "text": "[Off]" } ], "text": " - " }, { "color": "green", "text": "Show Redstone Block Updates" }, { "color": "green", "text": ": " }, { "bold": false, "color": "aqua", "text": "[On]" }, { "text": " " }, { "bold": true, "color": "aqua", "text": "[Off]" } ], "text": "" } ``` JSON from Minecraft 1.20.6: (Most likely first processed by ViaVersion from 1.21 to 1.20.6, deserialized and then serialized to JSON again, but looks pretty much, like how coded it in the plugin). ```json { "text": "", "extra": [ { "text": " - ", "color": "dark_green" }, { "text": "Show Redstone Block Updates", "hoverEvent": { "contents": "Visualizes when a block gets a RedstoneEvent", "action": "show_text" }, "color": "green" }, { "text": ": ", "color": "green" }, { "text": "[On]", "hoverEvent": { "contents": "§7Click to turn this setting on.", "action": "show_text" }, "clickEvent": { "action": "run_command", "value": "/settings showRedstoneUpdates:on" }, "color": "aqua", "bold": false }, " ", { "text": "[Off]", "hoverEvent": { "contents": "§7Click to turn this setting off.", "action": "show_text" }, "clickEvent": { "action": "run_command", "value": "/settings showRedstoneUpdates:off" }, "color": "aqua", "bold": true } ] } ```

My guess would be, that these changes are somehow responsible: https://github.com/azalea-rs/azalea/commit/ea64fba7f655b9afa03d57e8590c16e024f396f3#diff-6787cba3ef53a6e5c2cd7fd98e0f9b8bf92d9cfd336929bb83aded5a230d716e

But I have no clue what happened there. It seems to have copied itself into a few children. Maybe borrowing broken?

Only seems to affect some of my messages though. So some rare exception.

Can also be tested by joining an example that logs chat onto testpaper.cosmos-ink.net (server is in offline mode).

Any Ideas @mat-1 ?


For now I'll not update it. ViaVersion is still broken, which keeps my releases in beta-hell, due to a feature not working and the new version seems to have regressions again. I would need to create yet another fork of azela to fix these issues there.

Workaround for now is to just use ViaProxy in front of the bot (the flag --openauthmod exists, so no need for account setup that is only supported in the GUI).

ShayBox commented 1 month ago

Use ZenithProxy instead of ViaProxy, it has a bunch of additional modules you might want (auto eat, visual range, auto disconnect, etc), integrated ViaProxy for multi-version support, it can auth for you instead of OpenAuthMod, and you can whitelist an offline username for the bot to join with.

kittenvr commented 1 month ago

Instead of ViaProxy, use ZenithProxy. It has all the additional modules you might need, integrated ViaProxy, it can auth for you instead of OAM, and you can whitelist an offline username for the bot to join with.

is this hard or how long would it take?

ShayBox commented 1 month ago

You would set it up yourself, just download the jar or linux binary, run it, optionally setup a discord bot

ShayBox commented 1 month ago

Changing v.extend(sibling); to v.push(sibling); or v.extend(siblings); in component.rs impl IntoIterator fixes the duplicate issue, but some messages with a lot of nested siblings fail to format properly and just disappear past the first few nests, but it's better than the current azalea bug.

EnderKill98 commented 1 month ago

I think I'll just end up yeeting the via-version support for the time being.

I'm already running some of these bots with a separate ViaProxy as a Systemd-Service which works well. Mainly for that I added the native OpenAuthMod support (just stolen from the azalea ViaVersion code). Because that way many bots can use the same ViaProxy to the same server with their own accounts. You can only manage Accounts on the ViaProxy side when running the gui for some reason.

ZenithProxy would also be a suitable replacement ig, but the point of me adding the integrated azalea-viaproxy stuff was mainly the convenience factor. So it probably makes sense to just yeet the feature for now. People just need to stick their own proxy of choice behind it if needed ig.