Class StoreTagService
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Turns a store item into the app's own tags.
Modrinth's categories are a good start but they are coarse — nearly half of the top server mods
are filed under "utility" — and they don't say the one thing a server owner cares most about:
whether players have to install the mod as well. So the categories are combined with keyword
rules and with the client/server side, all of which live in Resources/store-tags.json.
Every rule adds to a score and a tag applies from McServerLauncher.Services.StoreTagService.Threshold. That is what replaced "any rule matching is enough", which tagged a password manager as combat (the keyword "sword" inside "password") and a backpack mod as combat too (Modrinth files armour, tools and backpacks under "equipment"). Keywords are whole words, and a project whose author ticked most of the topics gets little from them: those authors tick everything, so the ticks say little. When nothing reaches the threshold the project has no tags, and the card says so by showing none rather than a guess.
Where the downloaded StoreCatalogService has an answer for a project, that answer is used instead: it comes from reading the whole description with a model, which is what these rules can only approximate. The rules remain what runs for every project the catalogue has never seen, and what runs offline on a first launch.
The catalogue is read from the embedded copy, unless
%APPDATA%\McServerLauncher\store-tags.json exists, in which case that file is used
instead. Tags can therefore be added, translated, recoloured or re-mapped without a new build.
public sealed class StoreTagService
- Inheritance
-
StoreTagService
- Inherited Members
Constructors
StoreTagService(string?, StoreCatalogService?)
public StoreTagService(string? overridePath = null, StoreCatalogService? catalog = null)
Parameters
overridePathstringcatalogStoreCatalogService
Fields
TopicKind
The tags offered as filter chips for a given project type ("mod" or "plugin"), so a Paper server is not offered "Magic" and a Fabric server is not offered "Permissions & ranks".
public const string TopicKind = "topic"
Field Value
Properties
All
Every tag in the catalogue, ordered by priority.
public IReadOnlyList<StoreTagDefinition> All { get; }
Property Value
Shared
Shared instance; the catalogue is read once per run. Declared after the static fields it uses: static initialisers run in the order they are written, and the constructor needs them.
public static StoreTagService Shared { get; }
Property Value
Methods
BrowseTags(string)
public IReadOnlyList<StoreTagDefinition> BrowseTags(string projectType)
Parameters
projectTypestring
Returns
Classify(StoreItem, int, string?)
The tags that apply to item, best first: the higher the score the earlier,
then the catalogue's priority. A project that scores nothing has no tags, which the UI shows
by leaving the row out.
public IReadOnlyList<StoreTagDefinition> Classify(StoreItem item, int max = 2147483647, string? onlyKind = null)
Parameters
Returns
Find(string)
Finds a tag by id; null when the catalogue doesn't define it.
public StoreTagDefinition? Find(string id)
Parameters
idstring
Returns
LabelFor(StoreTagDefinition)
The tag's name in the interface language, falling back to English and finally to the raw id — a catalogue that forgot a translation still shows something usable.
public static string LabelFor(StoreTagDefinition tag)