Skidamek / AutoModpack

Enjoy a seamless modpack installation process and effortless updates with a user-friendly solution that simplifies management, making your gaming experience a breeze.
https://modrinth.com/mod/automodpack
GNU Lesser General Public License v3.0
90 stars 29 forks source link

Custom Message for Non-Automodpack clients #236

Closed wMarciano closed 1 week ago

wMarciano commented 1 month ago

Motivation

Firstly, I love this mod, and thank you for being considerate of un-modded players with the 'requireAutoModpackOnClient' config option!

That said, it would be awesome to be able to let un-modded players know that they are missing out on the full experience.

Description

Ideally, this would be exposed in server config with some simple settings like:

"nagUnmoddedClients" : true | false (default : false)
"nagMessage" : "Hey, you're unmodded lol,\n heres a [&elink&f] to get automodpack."

And presented on either the server join screen (if possible) or in the chat. Untitled-1 Screenshot 2024-05-19 at 9 41 56 AM

Other information

No response

Skidamek commented 1 month ago

Join screen is impossible but chat, tab list or server motd could be But i think only on chat link is clickable, or mojang removed it?

wMarciano commented 1 month ago

Chat probably makes the most sense then, links are clickable with a simple tellraw like this:

tellraw @s ["Hey, you're unmodded! Click this ",{"text":"link","clickEvent":{"action":"open_url","value":"https://github.com/Skidamek/AutoModpack-Installer/releases/download/Latest/automodpack-fabric-installer-0.11.2.jar"}}," to get a the one-click installer."]

So then the "nagMessage" config variable could take in the part in brackets, and the mod simply would run tellraw unmoddedPlayer [nagMessage]

wMarciano commented 2 weeks ago

Hey, I ended up implementing it alongside 1.21 fabric compatibility in a fork... I'd submit a PR but the 1.21 changes break the older versions (probably a way around this, i just didn't quite understand your multi-version setup), so I only targeted 1.21-fabric. There also is probably a better event to tie the chat message to (I'm not very knowledgable in that department)...I just have it sent 10 seconds after the automodpack handshake occurs for my own ease of implementation.

Skidamek commented 2 weeks ago

Thanks I've seen, its helpful, you actually motivated to work on it. I am getting to it, hopefully in next few days you can expect official beta 2 with 1.21, 1.20.6, 1.20.4, fixes and custom message :)

Skidamek commented 1 week ago

Ok, I've implemented it my way see the default text and link are different than proposed, can you check it and leave feedback? Pull request with some better ideas are appreciated as well! And i set it enabled by default because i though its maybe better when its shown only to non automodpack players anyway...

wMarciano commented 1 week ago

Looks great! If you're still at your desk, a good QOL feature would be allowing the user to customize the link (for example, to link directly to the bundled fabric installer, a specific version, etc.)

In Jsons.java:

public String nagLink= "https://modrinth.com/project/automodpack"; // leave blank for no link

and in PlayerManagerMixin.java:

if (serverConfig.nagLink.isEmpty()) {
    Text nagText = VersionedText.literal(serverConfig.nagMessage);
} else {
     Text nagText = VersionedText.literal(serverConfig.nagMessage).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,  serverConfig.nagLink)));
}

If not, I can PR this. Otherwise, great work! Thanks for being receptive.

Skidamek commented 1 week ago

Do you think its intuitive that you can click into this message? Because it just look like normal blank message its something i am concerned about. And you can make PR sure, currently i am not available.

wMarciano commented 1 week ago

Hmm... as long as the message makes it clear, it shouldn't be a big deal. You could switch to tellraw and leave it up to the user to format the link:

server.getCommandManager().executeWithPrefix(server.getCommandSource(), "tellraw " + playerName + " [\"" + serverConfig.nagMessage + "\"]");

which should support any tellraw formatting as long as all internal " are escaped:

nagMessage = "This server provides a dedicated modpack through AutoModpack!\",{\"text\":\"Check it out\",\"underlined\":true,\"color\":\"yellow\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://github.com/Skidamek/AutoModpack\"}},\"!"

But that's not super intuitive. Honestly you can probably just leave it as is, or give the nag message an underline/color.

Skidamek commented 1 week ago

Ok, see https://github.com/Skidamek/AutoModpack/commit/f48df6b4d8706b0e80b0a919f880e11be30c90d1 By default it should look like this image

wMarciano commented 1 week ago

Solid! Well solved!