Enchanted Book Sorting

Discussion in 'Bukkit Discussion' started by Deity.-, Aug 20, 2019.

  1. Offline

    Deity.-

    I am making a plugin for Bukkit and am creating an advanced sorting mechanic for players to use. I have it all set up except for one thing: Enchanted books. I have no issues writing any code (which is why I put this in this channel instead of the development one), however I have no idea what criteria to use for sorting them. So far I've come up with a few ideas:
    • Sort by name of highest-level enchantment
    • Sort by total level of enchantment
    • Sort by applicable tool (However my plugin also allows enchantments on items that normally can't get it, so an enchanted book would be able to hold both Sharpness and Protection)
    • Sort by 'power' rating (This is currently the method that I'll stick with, although I find this is too subjective and may be difficult to locate items through this method)
    • Sort by number of enchantments
    • Sort by name of first enchantment
    None of these ideas seem like they're very good so if anybody has any ideas on how I can sort these enchanted books, any help or ideas would be appreciated.

    Edit:
    I'm not sorting the enchantments on the book, rather I'm sorting the book with other ones.
     
    Last edited: Aug 21, 2019
  2. Online

    CraftCreeper6

    @Deity.-
    Just sort them alphabetically and by the level.

    I.E:

    If your list is:

    Sharp I, Sharp V, Sharp II, Sharp IV, Prot II, Prot I, Sharp X

    Then you would sort it first alphabetically:
    Prot II, Prot I, Sharp I, Sharp V, Sharp II, Sharp IV, Sharp X

    Then sort by level:
    Prot I, Prot II, Sharp I, Sharp II, Sharp IV, Sharp V, Sharp X
     
  3. Offline

    Deity.-

    Sorry I don't think I said this very well, but I'm not sorting the enchantments on a book, I'm sorting the book itself with other books.
     
  4. Online

    CraftCreeper6

    @Deity.-
    And by sorting the books what do you mean? What else can you sort on a book other than its enchantments?
     
  5. Offline

    Deity.-

    I'm not trying to sort the enchantments on the book like as you said,
    I'm instead trying to sort a chest filled with enchanted books by some criteria to put the books in order, not the enchantments.
     
  6. Online

    CraftCreeper6

    @Deity.-
    But enchantments could be a criteria, correct?

    I'm confused what you're asking for. You can sort the chest based on the enchantments that each book has.

    Another idea is alphabetical, by overall magnitude of enchantment (add up all enchantment levels on the book), ascending and descending for each option. etc...
     

Share This Page