mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Limit amount of messages per tick per player to 2
This commit is contained in:
parent
5ad4f44dce
commit
d7be531868
@ -155,6 +155,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
/** @var Inventory[] */
|
/** @var Inventory[] */
|
||||||
protected $windowIndex = [];
|
protected $windowIndex = [];
|
||||||
|
|
||||||
|
protected $messageCounter = 2;
|
||||||
|
|
||||||
protected $sendIndex = 0;
|
protected $sendIndex = 0;
|
||||||
|
|
||||||
protected $moveToSend = [];
|
protected $moveToSend = [];
|
||||||
@ -1381,6 +1383,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->messageCounter = 2;
|
||||||
|
|
||||||
$this->lastUpdate = $currentTick;
|
$this->lastUpdate = $currentTick;
|
||||||
|
|
||||||
if(!$this->isAlive() and $this->spawned){
|
if(!$this->isAlive() and $this->spawned){
|
||||||
@ -2358,7 +2362,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
if($packet->type === TextPacket::TYPE_CHAT){
|
if($packet->type === TextPacket::TYPE_CHAT){
|
||||||
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
|
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
|
||||||
foreach(explode("\n", $packet->message) as $message){
|
foreach(explode("\n", $packet->message) as $message){
|
||||||
if(trim($message) != "" and strlen($message) <= 255){
|
if(trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0){
|
||||||
$this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, $message));
|
$this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, $message));
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user