58 $player = $this->fetchPermittedPlayerTarget($sender, $args[1] ??
null, DefaultPermissionNames::COMMAND_XP_SELF, DefaultPermissionNames::COMMAND_XP_OTHER);
63 $xpManager = $player->getXpManager();
64 if(str_ends_with($args[0],
"L")){
65 $xpLevelAttr = $player->getAttributeMap()->get(Attribute::EXPERIENCE_LEVEL) ??
throw new AssumptionFailedError();
66 $maxXpLevel = (int) $xpLevelAttr->getMaxValue();
67 $currentXpLevel = $xpManager->getXpLevel();
68 $xpLevels = $this->getInteger($sender, substr($args[0], 0, -1), -$currentXpLevel, $maxXpLevel - $currentXpLevel);
70 $xpManager->addXpLevels($xpLevels,
false);
71 $sender->sendMessage(KnownTranslationFactory::commands_xp_success_levels((
string) $xpLevels, $player->getName()));
73 $xpLevels = abs($xpLevels);
74 $xpManager->subtractXpLevels($xpLevels);
75 $sender->sendMessage(KnownTranslationFactory::commands_xp_success_negative_levels((
string) $xpLevels, $player->getName()));
78 $xp = $this->getInteger($sender, $args[0], max: Limits::INT32_MAX);
80 $sender->sendMessage(KnownTranslationFactory::commands_xp_failure_widthdrawXp()->prefix(TextFormat::RED));
82 $xpManager->addXp($xp,
false);
83 $sender->sendMessage(KnownTranslationFactory::commands_xp_success((
string) $xp, $player->getName()));