-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- fix enchantment not tradeable in >=1.20.6 | ||
- fix enchantment not tradeable in >=1.20.6 | ||
- use yacl 3.5.x for config creation |
111 changes: 40 additions & 71 deletions
111
src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.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 |
---|---|---|
@@ -1,77 +1,46 @@ | ||
package dev.nyon.telekinesis.config | ||
|
||
import dev.isxander.yacl3.api.ConfigCategory | ||
import dev.isxander.yacl3.api.Option | ||
import dev.isxander.yacl3.api.OptionDescription | ||
import dev.isxander.yacl3.api.YetAnotherConfigLib | ||
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder | ||
import dev.isxander.yacl3.dsl.YetAnotherConfigLib | ||
import dev.isxander.yacl3.dsl.controller | ||
import dev.isxander.yacl3.dsl.descriptionBuilder | ||
import dev.isxander.yacl3.dsl.tickBox | ||
import dev.nyon.konfig.config.saveConfig | ||
import net.minecraft.client.gui.screens.Screen | ||
import net.minecraft.network.chat.Component | ||
|
||
fun generateConfigScreen(parent: Screen? = null): Screen { | ||
val configScreenBuilder = YetAnotherConfigLib.createBuilder() | ||
configScreenBuilder.title(Component.translatable("menu.telekinesis.name")) | ||
configScreenBuilder.appendOptionCategory() | ||
configScreenBuilder.save { saveConfig(config) } | ||
val configScreen = configScreenBuilder.build() | ||
return configScreen.generateScreen(parent) | ||
} | ||
fun generateConfigScreen(parent: Screen? = null): Screen = YetAnotherConfigLib("telekinesis") { | ||
val general by categories.registering { | ||
val needEnchantment by rootOptions.registering { | ||
binding(true, { config.needEnchantment }, { config.needEnchantment = it }) | ||
controller = tickBox() | ||
descriptionBuilder { | ||
addDefaultText(1) | ||
} | ||
} | ||
|
||
fun YetAnotherConfigLib.Builder.appendOptionCategory() { | ||
this.category( | ||
ConfigCategory.createBuilder() | ||
.name(Component.translatable("menu.telekinesis.config.general")) | ||
.option( | ||
Option.createBuilder<Boolean>() | ||
.name(Component.translatable("menu.telekinesis.config.general.needEnchantment")) | ||
.description( | ||
OptionDescription | ||
.of(Component.translatable("menu.telekinesis.config.general.needEnchantment.description")) | ||
) | ||
.binding(config.needEnchantment, { config.needEnchantment }, { config.needEnchantment = it }) | ||
.controller { | ||
TickBoxControllerBuilder.create(it) | ||
}.build() | ||
) | ||
.option( | ||
Option.createBuilder<Boolean>() | ||
.name(Component.translatable("menu.telekinesis.config.general.needSneak")) | ||
.description( | ||
OptionDescription | ||
.of( | ||
Component.translatable("menu.telekinesis.config.general.needSneak.description") | ||
) | ||
) | ||
.binding(config.needSneak, { config.needSneak }, { config.needSneak = it }) | ||
.controller { | ||
TickBoxControllerBuilder.create(it) | ||
}.build() | ||
) | ||
.option( | ||
Option.createBuilder<Boolean>() | ||
.name(Component.translatable("menu.telekinesis.config.general.expAllowed")) | ||
.description( | ||
OptionDescription | ||
.of(Component.translatable("menu.telekinesis.config.general.expAllowed.description")) | ||
) | ||
.binding(config.expAllowed, { config.expAllowed }, { config.expAllowed = it }) | ||
.controller { | ||
TickBoxControllerBuilder.create(it) | ||
}.build() | ||
) | ||
.option( | ||
Option.createBuilder<Boolean>() | ||
.name(Component.translatable("menu.telekinesis.config.general.itemsAllowed")) | ||
.description( | ||
OptionDescription | ||
.of(Component.translatable("menu.telekinesis.config.general.itemsAllowed.description")) | ||
) | ||
.binding(config.itemsAllowed, { config.itemsAllowed }, { config.itemsAllowed = it }) | ||
.controller { | ||
TickBoxControllerBuilder.create(it) | ||
}.build() | ||
) | ||
.build() | ||
) | ||
} | ||
val needSneak by rootOptions.registering { | ||
binding(false, { config.needSneak }, { config.needSneak = it }) | ||
controller = tickBox() | ||
descriptionBuilder { | ||
addDefaultText(1) | ||
} | ||
} | ||
|
||
val expAllowed by rootOptions.registering { | ||
binding(false, { config.expAllowed }, { config.expAllowed = it }) | ||
controller = tickBox() | ||
descriptionBuilder { | ||
addDefaultText(1) | ||
} | ||
} | ||
|
||
val itemsAllowed by rootOptions.registering { | ||
binding(false, { config.itemsAllowed }, { config.itemsAllowed = it }) | ||
controller = tickBox() | ||
descriptionBuilder { | ||
addDefaultText(1) | ||
} | ||
} | ||
} | ||
|
||
save { saveConfig(config) } | ||
}.generateScreen(parent) |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"menu.telekinesis.name": "telekinesis", | ||
"menu.telekinesis.config.general": "General", | ||
"menu.telekinesis.config.general.needEnchantment": "Need enchantment", | ||
"menu.telekinesis.config.general.needEnchantment.description": "Decides whether telekinesis should only work with the enchantment.", | ||
"menu.telekinesis.config.general.needSneak": "Only while sneaking", | ||
"menu.telekinesis.config.general.needSneak.description": "Decides whether players should have to sneak to use telekinesis.", | ||
"menu.telekinesis.config.general.expAllowed": "Exp drops", | ||
"menu.telekinesis.config.general.expAllowed.description": "Decides whether telekinesis should also work for exp drops.", | ||
"menu.telekinesis.config.general.itemsAllowed": "Items", | ||
"menu.telekinesis.config.general.itemsAllowed.description": "Decides whether telekinesis should also work for item drops.", | ||
"yacl3.config.telekinesis.title": "telekinesis", | ||
"yacl3.config.telekinesis.category.general": "General", | ||
"yacl3.config.telekinesis.category.general.root.option.needEnchantment": "Need enchantment", | ||
"yacl3.config.telekinesis.category.general.root.option.needEnchantment.description": "Decides whether telekinesis should only work with the enchantment.", | ||
"yacl3.config.telekinesis.category.general.root.option.needSneak": "Only while sneaking", | ||
"yacl3.config.telekinesis.category.general.root.option.needSneak.description": "Decides whether players should have to sneak to use telekinesis.", | ||
"yacl3.config.telekinesis.category.general.root.option.expAllowed": "Exp drops", | ||
"yacl3.config.telekinesis.category.general.root.option.expAllowed.description": "Decides whether telekinesis should also work for exp drops.", | ||
"yacl3.config.telekinesis.category.general.root.option.itemsAllowed": "Items", | ||
"yacl3.config.telekinesis.category.general.root.option.itemsAllowed.description": "Decides whether telekinesis should also work for item drops.", | ||
"enchantment.telekinesis.telekinesis.name": "Telekinesis" | ||
} |