-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented vanilla /xp command. #6429
base: minor-next
Are you sure you want to change the base?
Conversation
} | ||
$xpManager = $player->getXpManager(); | ||
if(str_ends_with($args[0], "L")){ | ||
$xpLevelAttr = $player->getAttributeMap()->get(Attribute::EXPERIENCE_LEVEL) ?? throw new AssumptionFailedError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$xpLevelAttr = $player->getAttributeMap()->get(Attribute::EXPERIENCE_LEVEL) ?? throw new AssumptionFailedError(); | |
/** @var Attribute $xpLevelAttr */ | |
$xpLevelAttr = $player->getAttributeMap()->get(Attribute::EXPERIENCE_LEVEL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, @var
in PM code shouldn’t be used for such assertions. Also, I’ve found similar assertion via AssumptionFailedError
in the code for another attribute that should always exist by default too (https://github.com/pmmp/PocketMine-MP/blob/stable/src/network/mcpe/handler/InGamePacketHandler.php#L510)
Introduction
This PR implements /xp command from vanilla. Also, I think it would be convenient to have a built-in command that can give you experience levels to test enchanting tables / anvils instead of farming experience from bottles.
Changes
API changes
Added
ExperienceCommand
Added 2 new permissions:
Follow-up
Before accepting this PR you need to add new translations into
pmmp/Language
repoSee pmmp/Language#185
Requires translations:
|
pocketmine.command.xp.description
|Adds or removes player experience
||
pocketmine.permission.command.xp.other
|Allows the user to add or remove experience of other players
||
pocketmine.permission.command.xp.self
|Allows the user to add or remove their experience
||
pocketmine.command.xp.usage
|/xp <experience[L]> [player]
||
commands.xp.failure.widthdrawXp
|Cannot give player negative experience points
||
commands.xp.success
|Gave {%0} experience to {%1}
||
commands.xp.success.levels
|Gave {%0} experience levels to {%1}
||
commands.xp.success.negative.levels
|Taken {%0} levels from {%1}
|Tests
I tested this PR by doing the following: