Zum Hauptinhalt springen

delete_profile_action

Deletes a specific profile — action entry.

Entry Information

PropertyValue
Entry IDdelete_profile_action
TypeAction
ColorRed
Iconmdi:account-remove

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. / @Entry( "create_profile_action", "Creates a new profile for the player", Colors.RED, "mdi:account-plus" ) @Tags("profiles", "action") class CreateProfileActionEntry( 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("Name for the new profile. Supports placeholders.") @Placeholder val profileName: String = "Nouveau profil", @Help("Message to send on success. Supports {profile_name} and {profile_id}.") @Placeholder val successMessage: String = "<green>Profil <gold>{profile_name}</gold> créé !", @Help("Message to send if max profiles reached.") @Placeholder val maxReachedMessage: String = "<red>Vous avez atteint la limite de profils.", @Help("Whether to switch to the new profile after creation.") val switchToNew: Boolean = false, ) : ActionEntry { override fun ActionTrigger.execute() { if (!ProfilesAPI.canCreateProfile(player)) { if (maxReachedMessage.isNotBlank()) { player.sendMini(maxReachedMessage) } return } val resolvedName = profileName.parsePlaceholders(player) val profile = ProfilesAPI.createProfile(player, resolvedName) if (profile != null) { if (successMessage.isNotBlank()) { val msg = successMessage .replace("{profile_name}", profile.name) .replace("{profile_id}", profile.id) player.sendMini(msg) } // Trigger events Query.find<ProfileCreatedEventEntry>() .triggerAllFor(player) { ProfileContextKeys.PROFILE_ID += profile.id ProfileContextKeys.PROFILE_NAME += profile.name } if (switchToNew) { ProfilesAPI.switchProfile(player, profile.id) } } } } /** Action to delete a profile by ID.

Fields

FieldTypeDescription
profileIdStringThe profile ID to delete. Supports placeholders.
successMessageStringMessage to send on success.
failureMessageStringMessage to send on failure (e.g., profile is active or not found).

Usage Example

- entry: delete_profile_action
name: "Deletes a specific profile"
profileId: ""
successMessage: ""
failureMessage: ""