-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added BindCommand, added getSettingByName function to SettingContainer
- Loading branch information
Showing
7 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
progreso-client/src/main/kotlin/org/progreso/client/commands/BindCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.progreso.client.commands | ||
|
||
import com.mojang.brigadier.arguments.StringArgumentType | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder | ||
import org.progreso.api.command.AbstractCommand | ||
import org.progreso.api.command.arguments.ModuleArgumentType | ||
import org.progreso.api.setting.settings.BindSetting | ||
import org.progreso.client.util.client.KeyboardUtil | ||
|
||
@AbstractCommand.Register("bind") | ||
object BindCommand : AbstractCommand() { | ||
override fun build(builder: LiteralArgumentBuilder<Any>) { | ||
builder.then( | ||
argument("module", ModuleArgumentType()) | ||
.then( | ||
argument("key", StringArgumentType.string()).executesSuccess { context -> | ||
val module = ModuleArgumentType[context] | ||
val key = StringArgumentType.getString(context, "key") | ||
|
||
module.bind = try { | ||
KeyboardUtil.getKeyCode(key) | ||
} catch (ex: Exception) { | ||
errorLocalized("command.bind.key_error", key) | ||
return@executesSuccess | ||
} | ||
|
||
infoLocalized("command.bind.key", module.name, key) | ||
} | ||
) | ||
.then( | ||
literal("reset").executesSuccess { context -> | ||
val module = ModuleArgumentType[context] | ||
module.bind = module.getSettingByName("Bind", BindSetting::class).initialValue | ||
|
||
infoLocalized("command.bind.reset", module.name) | ||
} | ||
) | ||
.executesSuccess { context -> | ||
val module = ModuleArgumentType[context] | ||
|
||
infoLocalized("command.bind.current", module.name, KeyboardUtil.getKeyName(module.bind)) | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
progreso-client/src/main/resources/assets/progreso/lang/en_us.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
progreso-client/src/main/resources/assets/progreso/lang/ru_ru.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters