-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now doesn't crash without EssentialsPE :D
- Loading branch information
Showing
3 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
namespace HealthBar\OtherEvents; | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
use EssentialsPE\Events\PlayerNickChangeEvent; | ||
use HealthBar\Loader; | ||
use pocketmine\event\Listener; | ||
|
||
class EssentialsPEEvents implements Listener{ | ||
/** @var \HealthBar\Loader */ | ||
public $plugin; | ||
|
||
public function __construct(Loader $plugin){ | ||
$this->plugin = $plugin; | ||
} | ||
|
||
/** | ||
* @param PlayerNickChangeEvent $event | ||
*/ | ||
public function onNickChange(PlayerNickChangeEvent $event){ | ||
$player = $event->getPlayer(); | ||
$nick = $event->getNewNick(); | ||
|
||
$bar = $this->plugin->getHealthBar(); | ||
$bar = str_replace("maxhealth", $player->getMaxHealth(), $bar); | ||
$bar = str_replace("health", $player->getHealth(), $bar); | ||
$bar = str_replace("name", $nick, $bar); | ||
|
||
$event->setNameTag($bar); | ||
} | ||
} |
What a great namespace.
P.S. Wrong line :D