/xp
< Commands
/xp| Aliases |
|
|---|---|
| Permission level required |
|
| Restrictions |
Cheat only |
{
"title": "<code>/xp</code>",
"rows": [
{
"field": "\n* <!-- Command --><code ><span>/experience</span></code><!-- /Command --><sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>",
"label": "Aliases"
},
{
"field": "\n* 2 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>\n* 1 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Options article, displayed as Cheat) only<sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Adds, removes or queries player experience.
Syntax
- Java Edition
experience add <targets> <amount> [levels|points]xp add <targets> <amount> [levels|points]- Increases or decreases experience amount or experience level.
- If experience amount, it is counted into the player's Score.
- If experience level, it is not counted into the player's score. The amount of experience points in the current experience bar is scaled proportionally, keeping the progress of experience bar unchanged.
- Increases or decreases experience amount or experience level.
experience set <targets> <amount> [levels|points]xp set <targets> <amount> [levels|points]- Setting experience amount or experience level. Does not change the player's score.
- If setting experience amount, the experience level is not changed. If the specified amount is greater than or equal to the remaining capacity of a player's current experience bar, the setting does not work for the player.
- If setting experience level, the amount of experience points in the current experience bar is scaled proportionally, keeping the progress of experience bar unchanged.
- Setting experience amount or experience level. Does not change the player's score.
experience query <targets> (levels|points)xp query <targets> (levels|points)- Queries experience level or the experience amount in the current experience bar.
- Bedrock Edition
xp <amount: int> [player: target]- Increases experience amount.
xp <amount: int>L [player: target]- Increases or decreases experience level. The amount of experience points in the current experience bar is scaled proportionally, keeping the progress of experience bar unchanged.
Arguments
JE: <amount>: integer (in add mode)
- Specifies the amount of experience points or levels to give to the player. Negative values remove experience instead of adding them.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ).
JE: <amount>: integer (in set mode)
- Specifies the amount of experience points or levels to be set to the player.
- Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). And it must be between 0 and 2147483647 (inclusive).
- Specifies the amount of experience points or levels to be added to the player. This amount may represent either an amount of points or an amount of levels.
- If an
Lis added to the end, adds levels. Negative values remove experience instead of adding them. - Must be a [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). If the amount is expressed in points, it must be not lower than 0.
JE: <targets>: entity (in add and set mode)
BE: player: target: CommandSelector<Player>
- Specifies the target of the command. In Bedrock Edition, if not specified, defaults to the command's executor.
- Must be a player name, a target selector or a UUID. And the target selector must/should be of player type. In Bedrock Edition, the target selector should be of player type.
JE: <targets>: entity (in query mode)
- Specifies the target of the command.
- Must be a player name, a target selector or a UUID. And the target selector must be of single-player type.
Result
| Command | Trigger | Java Edition | Bedrock Edition |
|---|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable | Unparseable |
/... add ... | <targets> fails to resolve to one or more online players. | Failed | N/A |
/... query ... | <targets> fails to resolve to one or more online players. | ||
/... set ... | <amount> is greater than the current capacity of xp bars of all the targeted players. | ||
| Any | player: target is a target selector that is not in player type. | N/A | Failed |
player: target fails to resolve to one or more online players. | |||
player: target is not specified when the command's executor is not a player. | |||
The amount is expressed in points, and amount: int is lower than 0. | |||
| Any | Otherwise | Successful | |
Output
| Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
|---|---|---|---|---|---|
| Any | Java Edition | On fail | 0 | 0 | 0 |
/... query ... | On success | 1 | 1 | The number of experience points or levels the player has | |
/... add ... | On success | 1 | 1 | The number of targeted players | |
| Any | Bedrock Edition | On fail | 0 | N/A | N/A |
| On success | The number of players who are given or taken experience | N/A | N/A |
Examples
- To display Steve's current level:
experience query Steve levels - To give 7 experience to yourself:
xp 7 orexperience add @s 7 - To give 3 levels to Alice:
xp 3L Alice orxp add Alice 3 levels - To remove all levels from all players:
xp -2147483648L @a orxp set @a 0 orxp set @a 0 levels
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.0.0 | Beta 1.9 Prerelease 5 | Added /xp. The command took a player name and then a number of xp orbs to award. | |||||
| 1.3.1 | 12w16a | /xp is now usable in singleplayer. | |||||
| Syntax changed to have the number of orbs first, and then the player, and the player is now optional. | |||||||
| 1.4.2 | 12w39a | Added L notation for levels. Levels can be subtracted, but points cannot, failing with the message "Cannot give player negative experience points". | |||||
The limit for /xp is now 2,147,483,647 (231−1) instead of 5,000. | |||||||
| 1.13 | 17w45a | Added /experience and made /xp alias it. | |||||
Restructured syntax into /experience add, /experience set, and /experience query sub-commands. | |||||||
| Negative points are now supported. | |||||||
| Pocket Edition Alpha | |||||||
| v0.16.0 | build 1 | Added /xp. | |||||