mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Merge branch 'release/3.2'
This commit is contained in:
commit
aa55cd9acf
@ -39,6 +39,7 @@ use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\level\LevelInitEvent;
|
||||
use pocketmine\event\level\LevelLoadEvent;
|
||||
use pocketmine\event\player\PlayerDataSaveEvent;
|
||||
use pocketmine\event\server\CommandEvent;
|
||||
use pocketmine\event\server\DataPacketBroadcastEvent;
|
||||
use pocketmine\event\server\QueryRegenerateEvent;
|
||||
use pocketmine\event\server\ServerCommandEvent;
|
||||
@ -1991,10 +1992,20 @@ class Server{
|
||||
*
|
||||
* @param CommandSender $sender
|
||||
* @param string $commandLine
|
||||
* @param bool $internal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatchCommand(CommandSender $sender, string $commandLine) : bool{
|
||||
public function dispatchCommand(CommandSender $sender, string $commandLine, bool $internal = false) : bool{
|
||||
if(!$internal){
|
||||
$this->pluginManager->callEvent($ev = new CommandEvent($sender, $commandLine));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$commandLine = $ev->getCommand();
|
||||
}
|
||||
|
||||
if($this->commandMap->dispatch($sender, $commandLine)){
|
||||
return true;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class FormattedCommandAlias extends Command{
|
||||
}
|
||||
|
||||
foreach($commands as $command){
|
||||
$result |= Server::getInstance()->dispatchCommand($sender, $command);
|
||||
$result |= Server::getInstance()->dispatchCommand($sender, $command, true);
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
|
73
src/pocketmine/event/server/CommandEvent.php
Normal file
73
src/pocketmine/event/server/CommandEvent.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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\server;
|
||||
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\Cancellable;
|
||||
|
||||
/**
|
||||
* Called when any CommandSender runs a command, early in the process
|
||||
*
|
||||
* You don't want to use this except for a few cases like logging commands,
|
||||
* blocking commands on certain places, or applying modifiers.
|
||||
*
|
||||
* The message DOES NOT contain a slash at the start
|
||||
*/
|
||||
class CommandEvent extends ServerEvent implements Cancellable{
|
||||
/** @var string */
|
||||
protected $command;
|
||||
|
||||
/** @var CommandSender */
|
||||
protected $sender;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param string $command
|
||||
*/
|
||||
public function __construct(CommandSender $sender, string $command){
|
||||
$this->sender = $sender;
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CommandSender
|
||||
*/
|
||||
public function getSender() : CommandSender{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCommand() : string{
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
*/
|
||||
public function setCommand(string $command) : void{
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
@ -27,6 +27,8 @@ use pocketmine\command\CommandSender;
|
||||
|
||||
/**
|
||||
* This event is called when a command is received over RCON.
|
||||
*
|
||||
* @deprecated Use CommandEvent instead.
|
||||
*/
|
||||
class RemoteServerCommandEvent extends ServerCommandEvent{
|
||||
|
||||
|
@ -33,6 +33,8 @@ use pocketmine\event\Cancellable;
|
||||
* blocking commands on certain places, or applying modifiers.
|
||||
*
|
||||
* The message DOES NOT contain a slash at the start
|
||||
*
|
||||
* @deprecated Use CommandEvent instead.
|
||||
*/
|
||||
class ServerCommandEvent extends ServerEvent implements Cancellable{
|
||||
/** @var string */
|
||||
|
Loading…
x
Reference in New Issue
Block a user