Skip to main content

create_profile_action

Creates a new profile for the player — action entry.

Entry Information

PropertyValue
Entry IDcreate_profile_action
TypeAction
ColorRed
Iconmdi:account-plus

Description

Action to open the profile selection menu. / @Entry( "open_profile_menu_action", "Opens the profile selection menu for the player", Colors.RED, "mdi:account-multiple" ) @Tags("profiles", "action", "menu") class OpenProfileMenuActionEntry( override val id: String = "", override val name: String = "", override val triggers: List<Ref<TriggerableEntry>> = emptyList(), override val criteria: List<Criteria> = emptyList(), override val modifiers: List<Modifier> = emptyList(), @Help("Reference to the menu configuration. If empty, uses the first available.") val menuConfig: Ref<ProfileMenuConfigEntry> = emptyRef(), ) : ActionEntry { override fun ActionTrigger.execute() { val configId = menuConfig.get()?.id val menuService = org.koin.core.context.GlobalContext.get().get<ProfileMenuService>() menuService.open(player, configId) } } /** Action to switch to a specific profile by ID. / @Entry( "switch_profile_action", "Switches the player to a specific profile", Colors.RED, "mdi:account-switch" ) @Tags("profiles", "action") class SwitchProfileActionEntry( override val id: String = "", override val name: String = "", override val triggers: List<Ref<TriggerableEntry>> = emptyList(), override val criteria: List<Criteria> = emptyList(), override val modifiers: List<Modifier> = emptyList(), @Help("The profile ID to switch to. Supports placeholders.") @Placeholder val profileId: String = "", @Help("Message to send on success. Leave empty for no message.") @Placeholder val successMessage: String = "", @Help("Message to send on failure. Leave empty for no message.") @Placeholder val failureMessage: String = "<red>Impossible de changer de profil.", ) : ActionEntry { override fun ActionTrigger.execute() { val resolvedId = profileId.parsePlaceholders(player) // Async: messages and events fire from the callback, once the switch really landed. ProfilesAPI.switchProfile(player, resolvedId) { switched -> if (!switched) { if (failureMessage.isNotBlank()) player.sendMini(failureMessage) return@switchProfile } val profile = ProfilesAPI.getProfile(player, resolvedId) if (successMessage.isNotBlank()) { player.sendMini(successMessage.replace("{profile_name}", profile?.name ?: resolvedId)) } // Trigger events if (profile != null) { Query.find<ProfileSwitchedEventEntry>() .triggerAllFor(player) { ProfileContextKeys.PROFILE_ID += profile.id ProfileContextKeys.PROFILE_NAME += profile.name } } } } } /** Action to create a new profile for the player.

Fields

FieldTypeDescription
profileNameStringName for the new profile. Supports placeholders.
successMessageStringMessage to send on success. Supports {profile_name} and {profile_id}.
maxReachedMessageStringMessage to send if max profiles reached.
switchToNewBooleanWhether to switch to the new profile after creation.

Usage Example

- entry: create_profile_action
name: "Creates a new profile for the player"
profileName: ""
successMessage: ""
maxReachedMessage: ""
switchToNew: false