mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
Merge branch 'master' of https://github.com/pmmp/pocketmine-mp into master
This commit is contained in:
commit
e17629244c
48
src/event/player/PlayerDisplayNameChangeEvent.php
Normal file
48
src/event/player/PlayerDisplayNameChangeEvent.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\player;
|
||||
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class PlayerDisplayNameChangeEvent extends PlayerEvent{
|
||||
|
||||
/** @var string */
|
||||
private $oldName;
|
||||
/** @var string */
|
||||
private $newName;
|
||||
|
||||
public function __construct(Player $player, string $oldName, string $newName){
|
||||
$this->player = $player;
|
||||
$this->oldName = $oldName;
|
||||
$this->newName = $newName;
|
||||
}
|
||||
|
||||
public function getOldName() : string{
|
||||
return $this->oldName;
|
||||
}
|
||||
|
||||
public function getNewName() : string{
|
||||
return $this->newName;
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ use pocketmine\event\player\PlayerChangeSkinEvent;
|
||||
use pocketmine\event\player\PlayerChatEvent;
|
||||
use pocketmine\event\player\PlayerCommandPreprocessEvent;
|
||||
use pocketmine\event\player\PlayerDeathEvent;
|
||||
use pocketmine\event\player\PlayerDisplayNameChangeEvent;
|
||||
use pocketmine\event\player\PlayerExhaustEvent;
|
||||
use pocketmine\event\player\PlayerGameModeChangeEvent;
|
||||
use pocketmine\event\player\PlayerInteractEvent;
|
||||
@ -622,7 +623,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}
|
||||
|
||||
public function setDisplayName(string $name) : void{
|
||||
$this->displayName = $name;
|
||||
$ev = new PlayerDisplayNameChangeEvent($this, $this->displayName, $name);
|
||||
$ev->call();
|
||||
|
||||
$this->displayName = $ev->getNewName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user