How would I go about creating a command say /xp <amount> which would let a player bottle their xp into a bottle and right click the bottle to redeem the experience again?
Here is the code I've got, but it tends to yield no results and there's no error messages either: PHP: public function calculateExpReduction($p, $exp) { if($p instanceof Human){ $xp = $p->getTotalXp(); $p->setTotalXp($xp - $exp); } } public function redeemExp($player, $exp) { if($player instanceof Human){ $currentExp = $player->getTotalXp(); if ($exp > 32000) { $player->sendMessage(TF::RED . TF::BOLD . "(!) " . TF::RESET . TF::RED . "You cannot redeem more than 32000 XP at once."); return false; } if ($currentExp >= $exp) { $this->calculateExpReduction($player, $exp); $xpBottle = Item::get(384, $exp, 1); $xpBottle->setCustomName(TF::GREEN . TF::BOLD . "Experience Bottle " . TF::RESET . TF::GRAY . "(Throw)\n" . TF::LIGHT_PURPLE . "Value: " . TF::WHITE . $exp . "\n" . TF::LIGHT_PURPLE . "Redeemed by: " . TF::WHITE . $player->getName()); $player->getInventory()->addItem($xpBottle); $player->sendMessage(TF::GREEN . TF::BOLD . "XPBottle " . TF::RESET . TF::GREEN . "You have successfully redeemed " . TF::YELLOW . $exp . TF::GREEN . "."); $player->getLevel()->addSound(new ExpPickupSound($player), [$player]); } else { $player->sendMessage(TF::RED . TF::BOLD . "XPBottle " . TF::RESET . TF::RED . "You don't have enough experience. Your current experience is " . TF::YELLOW . $currentExp); } }----------------------------------------- if ($args[0] == "xpbottle") { if($sender instanceof Human){ if (!isset($args[1])) { $sender->sendMessage(TF::YELLOW . "/xpbottle <amount>\n" . TF::GRAY . "Converts <amount> xp into bottle form.\n" . TF::GRAY . "Use " . TF::YELLOW . "/xp" . TF::GRAY . " to view your current exp points.\n".TF::ITALIC.TF::GRAY."Your current XP: ".TF::GOLD.$sender->getTotalXp()); } if (isset($args[1])) { if (is_numeric($args[1]) && $args[1] > 0) $this->redeemExp($sender, $args[0]); else $sender->sendMessage(TF::RED . TF::BOLD . "XPBottle " . TF::RESET . TF::RED . "You have provided an invalid amount."); } } } When I run the command /o xpbottle, I get no results