@@ -2,12 +2,15 @@ package mynameisjeff.simpletogglesprint.core
22
33import cc.polyfrost.oneconfig.config.Config
44import cc.polyfrost.oneconfig.config.annotations.HUD
5+ import cc.polyfrost.oneconfig.config.annotations.KeyBind
56import cc.polyfrost.oneconfig.config.annotations.Switch
67import cc.polyfrost.oneconfig.config.annotations.Text
8+ import cc.polyfrost.oneconfig.config.core.OneKeyBind
79import cc.polyfrost.oneconfig.config.data.Mod
810import cc.polyfrost.oneconfig.config.data.ModType
911import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator
1012import cc.polyfrost.oneconfig.hud.TextHud
13+ import cc.polyfrost.oneconfig.libs.universal.UKeyboard
1114import mynameisjeff.simpletogglesprint.SimpleToggleSprint
1215import mynameisjeff.simpletogglesprint.core.SimpleToggleSprintConfig.ToggleSprintHud.DisplayState.Companion.activeDisplay
1316import mynameisjeff.simpletogglesprint.mixins.accessors.AccessorEntityPlayer
@@ -40,23 +43,61 @@ object SimpleToggleSprintConfig : Config(Mod("SimpleToggleSprint", ModType.PVP,
4043 @Switch(
4144 name = " Seperate Keybind for Toggle Sprint" ,
4245 subcategory = " Toggle Sprint" ,
43- description = " Use a seperate keybind for Toggle Sprint.\n Configure it in the In-Game Controls menu. "
46+ description = " Use a seperate keybind for Toggle Sprint."
4447 )
4548 var keybindToggleSprint = false
4649
50+ @KeyBind(
51+ name = " Toggle Sprint Keybind" ,
52+ subcategory = " Toggle Sprint"
53+ )
54+ var keybindToggleSprintKey = OneKeyBind (UKeyboard .KEY_NONE )
55+
4756 @Switch(
4857 name = " Seperate Keybind for Toggle Sneak" ,
4958 subcategory = " Toggle Sneak" ,
50- description = " Use a seperate keybind for Toggle Sneak.\n Configure it in the In-Game Controls menu. "
59+ description = " Use a seperate keybind for Toggle Sneak."
5160 )
5261 var keybindToggleSneak = false
5362
63+ @KeyBind(
64+ name = " Toggle Sneak Keybind" ,
65+ subcategory = " Toggle Sneak"
66+ )
67+ var keybindToggleSneakKey = OneKeyBind (UKeyboard .KEY_NONE )
68+
5469 @HUD(
5570 name = " HUD" ,
5671 subcategory = " HUD"
5772 )
5873 var hud = ToggleSprintHud ()
5974
75+ init {
76+ initialize()
77+ addDependency(" keybindToggleSprint" , " toggleSprint" )
78+ addDependency(" keybindToggleSneak" , " toggleSneak" )
79+ addDependency(" keybindToggleSprintKey" , " keybindToggleSprint" )
80+ addDependency(" keybindToggleSneakKey" , " keybindToggleSneak" )
81+ registerKeyBind(keybindToggleSprintKey) {
82+ if (keybindToggleSprint) {
83+ if (enabled && toggleSprint && ! SimpleToggleSprint .sprintHeld) {
84+ toggleSprintState = ! toggleSprintState
85+ SimpleToggleSprintConfig .save()
86+ }
87+ SimpleToggleSprint .sprintHeld = ! SimpleToggleSprint .sprintHeld
88+ }
89+ }
90+ registerKeyBind(keybindToggleSneakKey) {
91+ if (keybindToggleSneak) {
92+ if (enabled && toggleSneak && ! SimpleToggleSprint .sneakHeld) {
93+ toggleSneakState = ! toggleSneakState
94+ SimpleToggleSprintConfig .save()
95+ }
96+ SimpleToggleSprint .sneakHeld = ! SimpleToggleSprint .sneakHeld
97+ }
98+ }
99+ }
100+
60101 class ToggleSprintHud : TextHud (true , 0 , 1080 - 19 ) {
61102 @Switch(name = " Brackets" )
62103 private var brackets = true
0 commit comments