-
Notifications
You must be signed in to change notification settings - Fork 17
DIVINIA RATIO COQUINARIA™ #835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JustAHuman-xD
wants to merge
36
commits into
master
Choose a base branch
from
idra/recipe-rewrite
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 23 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
366418e
RECIPES VOLUME 1: THE PROPHECY
LordIdra f092edd
RECIPES VOLUME 2: EMERGENCE
LordIdra faf3c02
RECIPES VOLUME 3: CONVERSION
JustAHuman-xD 5f31ff0
RECIPES VOLUME 4: TRANSMUTATION
LordIdra 0b7a207
RECIPES VOLUME 5: DOPPELGANGERS
JustAHuman-xD 9c9de3b
RECIPES VOLUME 6: EVOLUTION
LordIdra a7b8887
Merge branch 'idra/recipe-rewrite' of github.com:pylonmc/rebar into i…
LordIdra b0faf54
RECIPES VOLUME 7: REPAIR
JustAHuman-xD 58c46a2
RECIPES VOLUME 8: NEW PERSPECTIVES
LordIdra d955a8a
Merge branch 'idra/recipe-rewrite' of github.com:pylonmc/rebar into i…
LordIdra 506ded6
RECIPES VOLUME 8: REVELATIONS
JustAHuman-xD 9cc2807
RECIPES VOLUME 8.5: COALESCENCE
LordIdra dc77f67
Merge remote-tracking branch 'origin/idra/recipe-rewrite' into idra/r…
LordIdra 9cdaa9f
RECIPES VOLUME 9: ACCEPTANCE
JustAHuman-xD c9dadc0
RECIPES VOLUME 9.1: FLEXIBILITY
JustAHuman-xD 197427c
RECIPES VOLUME 10: DEVASTATION
LordIdra d425f91
RECIPES VOLUME 10.1: THE SHEDDING
JustAHuman-xD 93d9792
RECIPES VOLUME 10.5: WASTELANDS
JustAHuman-xD a82fb80
Revert "RECIPES VOLUME 10: DEVASTATION"
LordIdra f332838
RECIPES VOLUME 10.01: INTEMRISSION
LordIdra 5c98bcb
RECIPES VOLUME 11: SERENITY
LordIdra ab2def0
RECIPES VOLUME 12: ENLIGHTENMENT
JustAHuman-xD ead6d94
RECIPES VOLUME 13: SERENITY
JustAHuman-xD 6a0744b
docs improvements and stuff
LordIdra 7ad25db
Merge branch 'idra/recipe-rewrite' into idra/docs-improvements-and-stuff
LordIdra 7f6be6c
config adapter improvements
LordIdra b563fef
PR comments
LordIdra aea04d3
oh that's why I didn't do it
LordIdra fea84ce
apistatus internal
LordIdra 414e98d
.of
LordIdra fbea0e1
fix rebar item javadoc
JustAHuman-xD 9afff70
Merge pull request #841 from pylonmc/idra/docs-improvements-and-stuff
LordIdra 999537b
Merge branch 'master' into idra/recipe-rewrite
JustAHuman-xD c37a5c0
RECIPES VOLUME 14.01: WAKING
JustAHuman-xD 57c9751
RECIPES VOLUME 14.02: PARALYSIS
JustAHuman-xD f1a41d2
RECIPES VOLUME 14.03: CURE
JustAHuman-xD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
rebar/src/main/kotlin/io/github/pylonmc/rebar/config/adapter/FluidChoiceConfigAdapter.kt
This file contains hidden or 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,36 @@ | ||
| package io.github.pylonmc.rebar.config.adapter | ||
|
|
||
| import io.github.pylonmc.rebar.recipe.ingredient.FluidChoice | ||
| import org.bukkit.configuration.ConfigurationSection | ||
|
|
||
| object FluidChoiceConfigAdapter : ConfigAdapter<FluidChoice> { | ||
|
|
||
| override val type = FluidChoice::class.java | ||
|
|
||
| override fun convert(value: Any): FluidChoice = when (value) { | ||
| is Pair<*, *> -> FluidChoice.of( | ||
| // e.g. 'pylon:water: 100' | ||
| ConfigAdapter.REBAR_FLUID.convert(value.first!!), | ||
| ConfigAdapter.DOUBLE.convert(value.second!!) | ||
| ) | ||
| is ConfigurationSection, is Map<*, *> -> { | ||
| val map = MapConfigAdapter.STRING_TO_ANY.convert(value) | ||
| if (map.size == 1) { | ||
| // e.g. | ||
| // input: | ||
| // pylon:water: 500 | ||
| return convert(map.entries.first().toPair()) | ||
| } | ||
|
|
||
| // e.g. | ||
| // input: | ||
| // fluids: [pylon:water, pylon:lava] | ||
| // amount: 300 | ||
| val fluids = ConfigAdapter.SET.from(ConfigAdapter.REBAR_FLUID) | ||
| .convert(map["fluids"] ?: error("A list of fluids must be provided e.g. 'fluids: [pylon:water]'")) | ||
| val amount = ConfigAdapter.DOUBLE.convert(map["amount"] ?: error("A fluid amount must be specified e.g. 'amount: 500'")) | ||
| FluidChoice.of(fluids, amount) | ||
| } | ||
| else -> throw IllegalArgumentException("Cannot convert $value to FluidChoice") | ||
| } | ||
| } |
19 changes: 4 additions & 15 deletions
19
rebar/src/main/kotlin/io/github/pylonmc/rebar/config/adapter/FluidOrItemConfigAdapter.kt
This file contains hidden or 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,25 +1,14 @@ | ||
| package io.github.pylonmc.rebar.config.adapter | ||
|
|
||
| import io.github.pylonmc.rebar.recipe.FluidOrItem | ||
| import org.bukkit.configuration.ConfigurationSection | ||
| import io.github.pylonmc.rebar.recipe.ingredient.FluidOrItem | ||
|
|
||
| object FluidOrItemConfigAdapter : ConfigAdapter<FluidOrItem> { | ||
|
|
||
| override val type = FluidOrItem::class.java | ||
|
|
||
| override fun convert(value: Any): FluidOrItem { | ||
| val item = runCatching { ConfigAdapter.ITEM_STACK.convert(value) }.getOrNull() | ||
| return if (item != null) { | ||
| FluidOrItem.of(item) | ||
| } else when (value) { | ||
| is Pair<*, *> -> { | ||
| val fluid = ConfigAdapter.REBAR_FLUID.convert(value.first!!) | ||
| val amount = ConfigAdapter.DOUBLE.convert(value.second!!) | ||
| FluidOrItem.of(fluid, amount) | ||
| } | ||
|
|
||
| is ConfigurationSection, is Map<*, *> -> convert(MapConfigAdapter.STRING_TO_ANY.convert(value).toList().single()) | ||
| else -> throw IllegalArgumentException("Cannot convert $value to FluidOrItem") | ||
| } | ||
| runCatching { ConfigAdapter.ITEM_STACK.convert(value) }.onSuccess { return FluidOrItem.of(it) } | ||
| runCatching { FluidWithAmountConfigAdapter.convert(value) }.onSuccess { return it } | ||
| throw IllegalArgumentException("Cannot convert $value to FluidOrItem") | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
rebar/src/main/kotlin/io/github/pylonmc/rebar/config/adapter/FluidWithAmountConfigAdapter.kt
This file contains hidden or 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,22 @@ | ||
| package io.github.pylonmc.rebar.config.adapter | ||
|
|
||
| import io.github.pylonmc.rebar.recipe.ingredient.FluidWithAmount | ||
| import org.bukkit.configuration.ConfigurationSection | ||
|
|
||
| object FluidWithAmountConfigAdapter : ConfigAdapter<FluidWithAmount> { | ||
|
|
||
| override val type = FluidWithAmount::class.java | ||
|
|
||
| override fun convert(value: Any): FluidWithAmount = when (value) { | ||
| is Pair<*, *> -> FluidWithAmount( | ||
| ConfigAdapter.REBAR_FLUID.convert(value.first!!), | ||
| ConfigAdapter.DOUBLE.convert(value.second!!) | ||
| ) | ||
| is ConfigurationSection, is Map<*, *> -> { | ||
| val map = MapConfigAdapter.STRING_TO_ANY.convert(value) | ||
| check(map.size == 1) { "The input section had more than one key. Ensure the config is in the format e.g. `pylon:water: 500`" } | ||
| convert(map.entries.first().toPair()) | ||
| } | ||
| else -> throw IllegalArgumentException("Cannot convert $value to FluidOrItem.Fluid") | ||
| } | ||
| } |
98 changes: 98 additions & 0 deletions
98
rebar/src/main/kotlin/io/github/pylonmc/rebar/config/adapter/ItemChoiceConfigAdapter.kt
This file contains hidden or 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,98 @@ | ||
| package io.github.pylonmc.rebar.config.adapter | ||
|
|
||
| import io.github.pylonmc.rebar.recipe.ingredient.ItemChoice | ||
| import org.bukkit.Registry | ||
| import org.bukkit.configuration.ConfigurationSection | ||
|
|
||
| object ItemChoiceConfigAdapter : ConfigAdapter<ItemChoice> { | ||
|
|
||
| override val type = ItemChoice::class.java | ||
|
|
||
| private fun fromString(string: String): ItemChoice.Builder { | ||
| val builder = ItemChoice.Builder() | ||
| if (string.startsWith("#")) { | ||
| // e.g. '#minecraft:acacia_logs' | ||
| val tag = ConfigAdapter.ITEM_TAG.convert(string) | ||
| for (value in tag.values) { | ||
| builder.addFuzzy(value) | ||
| } | ||
| } else if (string.contains("[")) { | ||
| // e.g. 'minecraft:potion[potion_contents={potion:"healing"}]' | ||
| val stack = ConfigAdapter.ITEM_STACK.convert(string) | ||
| builder.addFuzzy(stack) | ||
| } else { | ||
| // e.g. 'minecraft:apple' | ||
| // e.g. 'pylon:fluid_pipe_copper' | ||
| val type = ConfigAdapter.ITEM_TYPE_WRAPPER.convert(string) | ||
| builder.addFuzzy(type) | ||
| } | ||
| return builder | ||
| } | ||
|
|
||
| private fun fromConfigSection(map: Map<String, Any?>): ItemChoice.Builder { | ||
| val item = ConfigAdapter.ITEM_TYPE_WRAPPER.convert(map["item"] ?: error("You must specify an item for recipe inputs")) | ||
| val exact = map["exact"]?.let { ConfigAdapter.BOOLEAN.convert(it) } ?: false | ||
| val ignore = map["ignore"]?.let { | ||
| ConfigAdapter.SET.from(ConfigAdapter.KEYED.fromRegistry(Registry.DATA_COMPONENT_TYPE)).convert(it) | ||
| } ?: emptySet() | ||
|
|
||
| check(ignore.isEmpty() || exact) { | ||
| "You cannot have ignored components unless 'exact' is true" | ||
| } | ||
|
|
||
| val builder = ItemChoice.Builder() | ||
| if (!exact) { | ||
| builder.addFuzzy(item) | ||
| } else { | ||
| builder.addExact(item, ignore) | ||
| } | ||
|
|
||
| return builder | ||
| } | ||
|
|
||
| override fun convert(value: Any): ItemChoice = when (value) { | ||
| is String -> fromString(value).amount(1).build() | ||
|
|
||
| is Pair<*, *> -> { | ||
| // e.g. 'pylon:fluid_pipe_bronze: 5' | ||
| fromString(value.first!! as String) | ||
| .amount(ConfigAdapter.INTEGER.convert(value.second!!)) | ||
| .build() | ||
| } | ||
|
|
||
| is ConfigurationSection, is Map<*, *> -> { | ||
| // e.g. | ||
| // input: | ||
| // amount: 5 | ||
| // choices: | ||
| // - item: pylon:bronze_pickaxe | ||
| // exact: true | ||
| // ignore: | ||
| // - max_damage | ||
| // - item: pylon:bronze_ingot | ||
| // - item: minecraft:stone-pickaxe | ||
| // OR | ||
| // pylon:bronze_ingot: 5 | ||
|
|
||
| val map = MapConfigAdapter.STRING_TO_ANY.convert(value) | ||
| if (map.size == 1) { | ||
| return convert(map.entries.first().toPair()) | ||
| } | ||
|
|
||
| val amount = ConfigAdapter.INTEGER.convert(map["amount"] ?: error("You must specify a recipe amount e.g. 'amount: 5'")) | ||
| val choices = ListConfigAdapter.from(ConfigAdapter.ANY).convert(map["choices"] ?: error("You must specify recipe choices e.g. 'choices: [pylon:fluid_pipe_copper, minecraft:apple]'")) | ||
|
|
||
| val internalChoices = mutableListOf<ItemChoice.InternalItemChoice>() | ||
| for (choice in choices) { | ||
| val choiceBuilder = when (choice) { | ||
| is String -> fromString(choice) | ||
| else -> fromConfigSection(MapConfigAdapter.STRING_TO_ANY.convert(choice)) | ||
| } | ||
| internalChoices.addAll(choiceBuilder.internalChoices) | ||
| } | ||
| ItemChoice(internalChoices, amount) | ||
| } | ||
|
|
||
| else -> throw IllegalArgumentException("Cannot convert $value to ItemChoice") | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.