WolfyScript / CustomCrafting

Spigot based plugin to create your own custom Recipes & Items. Designed to be easy to use with in-game GUI and tons of configuration possibilities.
https://modrinth.com/plugin/customcrafting
GNU General Public License v3.0
114 stars 36 forks source link

Recipe Book Category & Filter Recipe Sorting #262

Closed WolfyScript closed 1 year ago

WolfyScript commented 1 year ago

This PR adds the possibility to sort recipes inside categories and/or filters, and updates the recipe_book.conf to the new Creative Menu Categories.

New Recipe Book Config

You can view the recipe_book.conf here. To use it on your server you may need delete your current recipe_book.conf and recipe_book.json to generate it.

Additionally, now the old recipe_book.json gets renamed to recipe_book.conf if it doesn't exist yet, instead of keeping both versions.

Separate Category Title Property

Each category can now have both a name and title property. The name is the name of the item in the main menu of the recipe book, while the title is the inventory title when the category is open. If title is unspecified, it uses the name instead.

Sorting

There is no GUI editor for this, so it must be configured via the recipe_book.conf. Each category and filter can have a sort property, that contains the sort behaviour settings.

defaultSort : Specifies the default algorithm used to sort the recipes/groups

order : Specifies the order of the sort algo.

Then there are custom values for specific group/recipe sorting. When in 'ascending' order, higher values come last. All undefined recipes/groups have a value of 0. recipes : Map of recipe ids to values for custom sorting. groups : Map of group names to values for custom sorting.

For example:

(This example is from the new recipe_book.conf. )

A category with the following settings sorts the recipes and groups simultaneously in acending order.

sort {
  defaultSort = ID
  order = ACENDING
}

Then a filter inside that category can resort the already sorted recipes and therefore reorder recipes/groups.

sort {
  # This defines the algo used to sort the recipes/groups.
  defaultSort = NONE # NONE              = keeps the recipe/group order of the category
                     # ID                = sorts both groups & recipes simultaneosly, groups and recipes may intersect
                     # ID_GROUPS_FIRST   = sorts groups and recipes seperately, groups are put before the recipes
                     # ID_RECIPES_FIRST  = sorts groups and recipes seperately, recipes are put before the groups
  order = ASCENDING # ASCENDING   = from smallest to biggest value
                    # DESCENDING  = from biggest to smallest value
  # Custom values for specific group/recipe sorting
  # When in 'ascending' order, higher values come last. All undefined recipes/groups have a value of 0
  recipes {
    "customcrafting:customcrafting/recipe_book": -100 # this recipe is put infront of all recipes/groups
    "customcrafting:customcrafting/advanced_crafting_table": 1 # and this recipe is put at the end of the category!
  }
  groups {
     any_group_name: -101 # so this group would be put before the customcrafting recipe book recipe defined above.
   }
}