ClassProvider
Implement it to make your plugin's classes available via Classes. Register it in onLoad via Mimic.registerClassProvider. To read or change classes of players, use Classes instead.
A slot holds at most one of the player's classes: a class group, a primary or secondary class, a race. Races are classes too, held in a race slot. Your plugin may have one slot or many.
It replaces the deprecated ClassSystem API, which supports only a flat list of class names.
What to implement
Required: allSlots, allClasses, getClasses and getPrimarySlot.
Optional: setClass. Skip it if your plugin can't change classes, it returns
falseby default.
IDs
Mimic adds your provider id as the namespace, so return slot and class IDs without it: warrior becomes myplugin:warrior. Don't change id later, it breaks consumers' configs. Class IDs are unique within your provider, regardless of the slot.
If your plugin has its own namespaced IDs, convert them to paths:
Drop your plugin's own namespace:
origins:human->human.Keep other namespaces as the first path part:
myaddon:elf->myaddon/elf.
Other rules:
Allowed characters:
a-z,0-9,.,_,-and/. Slots and classes with other characters are ignored.To convert other IDs, lowercase them and replace other characters with
_. Keep a map back to the original IDs.If two IDs become the same (
Warriorandwarrior), log a warning and keep one of them.
Rules
Only online players are passed to the provider.
Never throw. If the player's data isn't loaded yet, return
nullor empty from reads andfalsefrom writes.Don't change data until the player's data is loaded, even if your plugin's API allows it.
Report only active classes. Unlocked but inactive classes, classes the player has left, jobs and professions aren't classes here.
Report a placeholder meaning "no class yet", like a starting class, as an empty slot, so consumers can tell whether the player has picked a class. A default that is a real choice, like a starting race, is a class.
Reads may be called from any thread. If your plugin can't read data there, return
nullor empty instead of throwing.Writes are expected on the main thread (on Folia - on the player's thread), but Mimic doesn't enforce it.
Mimic does the rest: selects the provider by the ID namespace, finds subclasses using ClassDefinition.parents, and catches errors thrown by the provider.
Since
0.10.0
Types
Class of a ClassProvider. Classes are immutable, so they can be cached and reused.
Slot of a ClassProvider. Slots are immutable, so they can be cached and reused.
Properties
Inherited properties
Functions
Returns classes the player has, where key is a slot ID. Empty slots are omitted. Return the same ClassDefinition.parents and ClassDefinition.levelTrack as in allClasses.
Returns the slot holding the class that best represents the player's class, or null if there is no such slot.