Skip to content

Commit

Permalink
Backend: Command Register Event (#2642)
Browse files Browse the repository at this point in the history
Co-authored-by: CalMWolfs <[email protected]>
Co-authored-by: Cal <[email protected]>
Co-authored-by: hannibal2 <[email protected]>
  • Loading branch information
4 people authored Oct 13, 2024
1 parent d8bb537 commit 113389a
Show file tree
Hide file tree
Showing 20 changed files with 886 additions and 655 deletions.
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigFileType
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.config.Features
import at.hannibal2.skyhanni.config.SackData
import at.hannibal2.skyhanni.config.commands.Commands
import at.hannibal2.skyhanni.config.commands.RegisterCommandsEvent
import at.hannibal2.skyhanni.data.OtherInventoryData
import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson
import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson
Expand Down Expand Up @@ -59,7 +59,7 @@ class SkyHanniMod {

SkyHanniEvents.init(modules)

Commands.init()
RegisterCommandsEvent.post()

PreInitFinishedEvent().post()
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.config

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.GuiEditManager
import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper
import io.github.notenoughupdates.moulconfig.gui.MoulConfigEditor

Expand All @@ -18,4 +19,16 @@ object ConfigGuiManager {
}
SkyHanniMod.screenToOpen = GuiScreenElementWrapper(editor)
}

fun onCommand(args: Array<String>) {
if (args.isNotEmpty()) {
if (args[0].lowercase() == "gui") {
GuiEditManager.openGuiPositionEditor(hotkeyReminder = true)
} else {
openConfigGui(args.joinToString(" "))
}
} else {
openConfigGui()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package at.hannibal2.skyhanni.config.commands

class CommandBuilder(val name: String) {
var description: String = ""
var category: CommandCategory = CommandCategory.MAIN
var aliases: List<String> = emptyList()
private var autoComplete: ((Array<String>) -> List<String>) = { listOf() }
private var callback: (Array<String>) -> Unit = {}

fun callback(callback: (Array<String>) -> Unit) {
this.callback = callback
}

fun autoComplete(autoComplete: (Array<String>) -> List<String>) {
this.autoComplete = autoComplete
}

fun toSimpleCommand() = SimpleCommand(name.lowercase(), aliases, callback, autoComplete)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package at.hannibal2.skyhanni.config.commands

enum class CommandCategory(val color: String, val categoryName: String, val description: String) {
MAIN(
"§6",
"Main Command",
"Most useful commands of SkyHanni",
),
USERS_ACTIVE(
"§e",
"Normal Command",
"Normal Command for everyone to use",
),
USERS_RESET(
"§e",
"Normal Reset Command",
"Normal Command that resents some data",
),
USERS_BUG_FIX(
"§f",
"User Bug Fix",
"A Command to fix small bugs",
),
DEVELOPER_TEST(
"§5",
"Developer Test Commands",
"A Command to edit/test/change some features. §cIntended for developers only!",
),
DEVELOPER_DEBUG(
"§9",
"Developer Debug Commands",
"A Command to debug/read/copy/monitor features. §cIntended for developers only!",
),
INTERNAL(
"§8",
"Internal Command",
"A Command that should §cnever §7be called manually!",
),
SHORTENED_COMMANDS(
"§b",
"Shortened Commands",
"Commands that shorten or improve existing Hypixel commands!",
)
}
Loading

0 comments on commit 113389a

Please sign in to comment.