From 21a3f8f1ed7230655cfe2f1e93b8edb14a2a21d0 Mon Sep 17 00:00:00 2001 From: Appability Date: Sat, 12 Nov 2022 16:45:51 -0800 Subject: add welcome message --- src/main/kotlin/com/ambientaddons/AmbientAddons.kt | 3 +- .../com/ambientaddons/commands/AmbientCommand.kt | 14 ++++++++- .../com/ambientaddons/config/PersistentData.kt | 1 + .../com/ambientaddons/features/misc/Welcome.kt | 33 ++++++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/com/ambientaddons/features/misc/Welcome.kt diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt index 5de2222..3a3db3e 100644 --- a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt +++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt @@ -81,7 +81,8 @@ class AmbientAddons { Salvage, Farming, ThunderWarning, - CustomEndInfo + CustomEndInfo, + Welcome ).forEach(MinecraftForge.EVENT_BUS::register) keyBinds.values.forEach(ClientRegistry::registerKeyBinding) guiElements = listOf( diff --git a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt index ff86228..3d62954 100644 --- a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt +++ b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt @@ -1,6 +1,7 @@ package com.ambientaddons.commands import AmbientAddons +import AmbientAddons.Companion.mc import com.ambientaddons.config.Config import com.ambientaddons.utils.Extensions.withModPrefix import com.ambientaddons.utils.SBLocation @@ -23,7 +24,18 @@ class AmbientCommand : CommandBase() { "location" -> UChat.chat(SBLocation.toString().withModPrefix()) "buy" -> AutoBuyCommand.processCommand(args.drop(1)) "salvage" -> SalvageCommand.processCommand(args.drop(1)) - else -> UChat.chat("§cUnknown argument!") + else -> { + val chatWidth = mc.ingameGUI?.chatGUI?.chatWidth ?: return + val chatBreak = "§9§m" + "-".repeat(chatWidth / mc.fontRendererObj.getStringWidth("-")) + UChat.chat(""" + $chatBreak + §b§lUsage: + §a/ambient §eto access GUI settings. + §a/ambient buy §eto edit autobuy list. + §a/ambient salvage §eto configure salvage features. + $chatBreak + """.trimIndent()) + } } } } \ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt index f46bcd9..2c63e76 100644 --- a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt +++ b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt @@ -10,6 +10,7 @@ import kotlinx.serialization.decodeFromString @Serializable data class PersistentData( + var isFirstLoad: Boolean = true, var autoBuyItems: MutableMap = mutableMapOf( "RECOMBOBULATOR_3000" to 5000000, "FIRST_MASTER_STAR" to null, diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Welcome.kt b/src/main/kotlin/com/ambientaddons/features/misc/Welcome.kt new file mode 100644 index 0000000..ac99025 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/misc/Welcome.kt @@ -0,0 +1,33 @@ +package com.ambientaddons.features.misc + +import AmbientAddons.Companion.mc +import AmbientAddons.Companion.persistentData +import com.ambientaddons.utils.SBLocation +import gg.essential.universal.UChat +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent + +object Welcome { + + @SubscribeEvent + fun onTick(event: ClientTickEvent) { + if (!persistentData.isFirstLoad || event.phase != TickEvent.Phase.START || !SBLocation.inSkyblock) return + val chatWidth = mc.ingameGUI?.chatGUI?.chatWidth ?: return + persistentData.isFirstLoad = false + persistentData.save() + val chatBreak = "§9§m" + "-".repeat(chatWidth / mc.fontRendererObj.getStringWidth("-")) + UChat.chat(""" + $chatBreak + §b§lThanks for installing AmbientAddons Forge! + + §eUse §a§l/ambient §r§eto access GUI settings. + §eAliases: §a/aa §eor §a/ambientaddons + + §eTo configure auto-buy, use §a/ambient buy§e. + §eTo configure salvage features, use §a/ambient salvage§e. + $chatBreak + """.trimIndent()) + } +} \ No newline at end of file -- cgit