Is anyone know how to add new variable to an object? For example, PHP: ....->getPlayer()->newFunc(); This code add newFunc() function to Player object. I want to do it... But how?
If I can't do it, I think I should make a new class extends the player class but I don't know to set the variables same as the defined player object...
You're thinking of this in a wrong way. PHP: public $list = [];function addToMatch(Player $player) : void { $this->list[] = $player;}function isPlayerInMatch(Player $player) : bool { return in_array($player, $this->list, true);}function removeFromMatch(Player $player) : void { if(!$this->isPlayerInMatch($player)) return; unset($this->list[array_search($player, $this->list, true)]);} Why the heck you think that these methods needs to be inside of a Player class? PHP: # Context of Listenerfunction onPlayerMove(PlayerMoveEvent $event) { /** @var $plugin PluginBase */ $plugin = $this->getMain(); $player = $event->getPlayer(); $player->sendTip("In Match? - " . ($plugin->isInMatch($player) ? "True" : "False"));} Take a look at other plugins to see how they've done it. Learn from other's code. If none of the code above makes sense to you, then it's time for you take some programming lessons.