mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Added RemoteServerCommandEvent
This commit is contained in:
parent
7e4a191593
commit
eee0eb5458
@ -1661,10 +1661,9 @@ class Server{
|
||||
Timings::$serverCommandTimer->startTiming();
|
||||
if(($line = $this->console->getLine()) !== null){
|
||||
$this->pluginManager->callEvent($ev = new ServerCommandEvent($this->consoleSender, $line));
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
if(!$ev->isCancelled()){
|
||||
$this->dispatchCommand($ev->getSender(), $ev->getCommand());
|
||||
}
|
||||
$this->dispatchCommand($this->consoleSender, $ev->getCommand());
|
||||
}
|
||||
Timings::$serverCommandTimer->stopTiming();
|
||||
}
|
||||
|
40
src/pocketmine/event/server/RemoteServerCommandEvent.php
Normal file
40
src/pocketmine/event/server/RemoteServerCommandEvent.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\server;
|
||||
|
||||
use pocketmine\command\CommandSender;
|
||||
|
||||
/**
|
||||
* This event is called when a command is received over RCON.
|
||||
*/
|
||||
class RemoteServerCommandEvent extends ServerCommandEvent{
|
||||
public static $handlerList = null;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param string $command
|
||||
*/
|
||||
public function __construct(CommandSender $sender, $command){
|
||||
parent::__construct($sender, $command);
|
||||
}
|
||||
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
namespace pocketmine\network\rcon;
|
||||
|
||||
use pocketmine\command\RemoteConsoleCommandSender;
|
||||
use pocketmine\event\server\RemoteServerCommandEvent;
|
||||
use pocketmine\scheduler\CallbackTask;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\MainLogger;
|
||||
@ -90,7 +91,16 @@ class RCON{
|
||||
$thread->notify();
|
||||
}, $this->workers[$n]);
|
||||
}else{
|
||||
$this->server->dispatchCommand($response = new RemoteConsoleCommandSender(), $this->workers[$n]->cmd);
|
||||
|
||||
$response = new RemoteConsoleCommandSender();
|
||||
$command = $this->workers[$n]->cmd;
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$this->server->dispatchCommand($ev->getSender(), $ev->getCommand());
|
||||
}
|
||||
|
||||
$this->workers[$n]->response = TextFormat::clean($response->getMessage());
|
||||
$this->workers[$n]->synchronized(function(RCONInstance $thread){
|
||||
$thread->notify();
|
||||
|
Loading…
x
Reference in New Issue
Block a user