Skip to content

Categories

tom2208 edited this page Mar 5, 2021 · 2 revisions

Description

Categories replace the old Evaluator. They define how the items get sorted. In other words, which item comes before another item. Categories can be configured and added by the user to make a custom sorting system. There is a default Category Order for the server and the each player can also override the order for themself, if they have the correct permission.

Categories work internally by sequentially subdividing the inventory into smaller parts. The resulting parts of the first category are fed into the second category, those parts into the third, and so on. The new part is always put infront of the part it was separated from.

A Category must not necessarily create a new part. If no item matches, nothing will happen. Additionally some Built-In Categories (eg. all Alpha* Categories) and all MasterCategories do not create new parts, but only rearrange the items within existing parts.

See the examples for a visual explanation.

Explanation Video for the Sorting Alorithm Configuration: https://youtu.be/zBcVTeyODVQ

Existing Categories you can add

If you search for existing patterns by use use this article: Useful Categories If you created useful own categories you want to share contact us and we will add them to the article so other user can benefit form your work.

Types

There are different Types of Categories. We differentiate between Built-in Categories and Configurable Categories. The Built-in Categories can not be changed, only used in the category order definition. The Configurable Categories are stored in the config.yml and may be configured (added/edited/removed) by the player.

  • Built-in Categories
  • Configurable Categories
    • WordCategory
    • ListCategory
    • MasterCategory

Built-in Categories

doesn't create new parts:

Name Description
AlphaAsc Sorts the Items alphabetically in ascending order (a-z)
AlphaDesc Sorts the Items alphabetically in descending order (z-a)
AlphaBackAsc Sorts the items alphabetically in ascending order, comparing from the last character (a-z)
AlphaBackDesc Sorts the items alphabetically in descending order, comparing from the last character (z-a)

create new parts if applicable:

Name Description
IsBlock Creates new part with placable block items
IsItem Creates new part with non-placable items
IsEdible Creates new part with edible items
IsFuel Creates new part with items that can be used as Fuel in Furnace
IsFlammable Creates new part with items that are flammable

WordCategory

A WordCategory is defined by a word/text. Items which contain that word in their name will be separated into a new part.

ListCategory

A ListCategory is defined by an ordered list of exact Item names. Items present in the list will be separated into a new part, sorted by their respective position defined in the list.

MasterCategory

A MasterCategory is defined by an ordererd list of other category names. The Items will be fed through all subcategories defined by the MasterCategory, however the resulting parts will all be merged back to one part. MasterCategories may contain other MasterCategories. See Example 2 for a visual explanation.

Example 1

Images/tutorial_lists.png

  • Notes
    • AlphaAsc - notice that the Built-In AlphaAsc Category doesnt create any new parts. It simply orders the items in the existing part(s). Creating a category for each letter would be counterproductive.
    • StoneWord - notice that the stone gets separated from the StoneList part. Granite and Diorite don't, as they don't contain "stone" in their name. In the end it doesn't make a difference in this case, but it shows how all three previous parts get subdivided and we end up with six new parts, which all get fed individually into the RedstoneList Category.
    • StairWord - notice that there are two stair parts, not one. That is because the StoneWord Category already separated a couple of stairs into their own part, along with the other "stone" blocks, that were not on the StoneList. In Example 2 we see how to prevent that using a MasterCategory.

Example 2

example MasterCategory

  • Notes
    • StoneMaster - MasterCategories don't subdivide the existing categories. However they still sort the items inside them, according to their defined subcategories. So it's as if we took the Result from the StoneWord Category, from Example 1, and merged it back to the two parts we got from the IsBlock Category.

Books

There is the possibility to add WordCategories, ListCategories and MasterCategories by defining them In-Game inside Minceraft Books, using a Book and Quill. Signed Books that are correctly formatted can also be read.

To add a book, simply hold the book in your hand and type /sortingadmin categories addFromBook

To receive an existing Category as a Book and Quill Item, simply type /sortingadmin categories getAsBook <categoryName> replacing with the Category name you want. There should be autocompletion to help you. Note that only configurable Categories (WordCategories, ListCategories, MasterCategories) can be gotten as Book. The Builtin Categories do not work like this.

Commands

  • /sortingconfig categories
    • get the category order for the player
  • /sortingconfig categories list
    • get all available categories. This command supports paging. Simply add a space and number at the end, and it will show that page.
  • /sortingconfig categories set <name,name,name,..> *
    • set the category order for the player. The Categories must be a single String without spaces. Each category is separated by a comma (","). eg: /sortingconfig categories set AlphaAsc,IsBlock,StoneMaster
  • /sortingadmin categories
    • get the default category order
  • /sortingadmin categories set <name,name,..>
    • set the default category order. Same syntax as /sortingconfig categories set
  • /sortingadmin categories addFromBook
    • add a category from the book in hand. see Books
  • /sortingadmin categories getAsBook <name>
    • get a category as a book. see Books
  • /sortingadmin categories remove <name>
    • removes a category that is removable.

Permissions

  • chestcleaner.cmd.sortingconfig.categories

    • allow player to override the category order for themself using the /sortingconfig categories command. The player can use the default Categories defined in config.yml. The players category order will be saved in playerdata.yml
  • chestcleaner.cmd.admin.config

    • allow player to set the default server category order and add new categories, defined in config.yml. This will apply to all players who haven't set their own category order.

Config

  • configurable categories and the default category order are saved/configured in config.yml
default:
  categories:
    - AlphaBackAsc
    - IsBlock
categories:
  words:
    - ==: WordCategory
      name: StoneWord
      word: stone
    - ==: WordCategory
      name: StairWord
      word: stair
  lists:
    - ==: ListCategory
      name: StoneList
      list:
        - stone
        - stone_bricks
        - mossy_stone_bricks
    - ==: ListCategory
      name: DirtList
      list:
        - dirt
        - grass_block
  master:
    - ==: MasterCategory
      name: StoneMaster
      list:
        - StoneList
        - StoneWord
  • the player patterns are saved/configured in playerdata.yml
<player id>:
    categories:
      - AlphaBackAsc
      - IsBlock