LuckPerms

LuckPerms

41.4k Downloads

Add option to deduplicate prefix/suffix stacks

BrainStone opened this issue · 4 comments

commented

So the idea is simple in principle.
Sometimes the same prefix can be retrieved trough multiple elements in the prefix stack. This could for example happen with a stack like that:

meta-formatting:
  prefix:
    format:
      - highest
      - highest_on_track_donator

If the player has just a donator rank, both would return the same prefix resulting in something like this: [Donator] [Donator]. In this case it could be worked around differently, though here it would be just convient to make sure the same prefix doesn't show up twice.

Another example from Discord would be the following:

Three ranks: default, donator & staff
Two tracks: donator & staff
Four scenarios:

  1. User is no donator, no staff = [Player]
  2. User is donator = [Donator]
  3. User is staff = [Staff]
  4. User is donator and staff = [Donator][Staff]

If deduplication was allowed it could be solved with this stacking setup:

meta-formatting:
  prefix:
    format:
      - highest_on_track_donator
      - highest_on_track_staff
      - highest

Without deduplication it's impossible without having to revert to some crazy lower prefix magic and overrides etc.

So the idea is to add an option to prefix (and suffix) stacking, that prevents the same prefix appearing twice in the stack.
Some implementation details that would make sense (at least to me):

  • Only the first appearance counts
  • Can be toggled individually for prefixes and suffixes (so you can have it on for prefixes but off for suffixes. Not for the individual prefixes/suffixes themselves)
  • It should be on by default in the default config (for conviniece. I belive most people don't want duplicate prefixes)
  • A missing option defaults to false. This is so that the behavior doesn't change when updating (while keeping the old config)

A complete example could look like this:

meta-formatting:
  prefix:
    format:
      - highest_on_track_donator
      - highest_on_track_staff
      - highest
    start-spacer: ""
    middle-spacer: " "
    end-spacer: ""
    deduplicate: true
  suffix:
    format:
      - highest_on_track_prison
      - highest_on_track_donor
      - highest_on_track_staff
    start-spacer: ""
    middle-spacer: " "
    end-spacer: ""
    deduplicate: false

Looking forward to what you think about this!

commented

Instead of true/false, how about:

deduplicate-mode: first-only
deduplicate-mode: last-only
deduplicate-mode: all
commented

I think that’s even better.

commented

Are there even moments, where you want a prefix/suffix to show twice?

commented

I don’t think so. But someone might. That’s why I suggested an option that is set to true (or first-only) in the default config.