Skip to content

Commit

Permalink
added RconCommandSender
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jan 23, 2019
1 parent 7abcd4b commit 9e5dc42
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/pmofficial/RconServer/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace pmofficial\RconServer;

use Particle\Validator\Validator;
use pocketmine\command\RemoteConsoleCommandSender;
use pocketmine\plugin\PluginBase;
use pocketmine\plugin\PluginException;
use function base64_encode;
Expand Down Expand Up @@ -36,7 +35,7 @@ public function onEnable() : void{
$this->rcon = new Rcon(
$config,
function(string $commandLine) : string{
$response = new RemoteConsoleCommandSender();
$response = new RconCommandSender();
$this->getServer()->dispatchCommand($response, $commandLine);
return $response->getMessage();
},
Expand Down
52 changes: 52 additions & 0 deletions src/pmofficial/RconServer/RconCommandSender.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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 pmofficial\RconServer;

use pocketmine\command\ConsoleCommandSender;
use pocketmine\lang\TextContainer;
use function trim;

class RconCommandSender extends ConsoleCommandSender{

/** @var string */
private $messages = "";

public function sendMessage($message){
if($message instanceof TextContainer){
$message = $this->getServer()->getLanguage()->translate($message);
}else{
$message = $this->getServer()->getLanguage()->translateString($message);
}

$this->messages .= trim($message, "\r\n") . "\n";
}

public function getMessage(){
return $this->messages;
}

public function getName() : string{
return "Rcon";
}
}

0 comments on commit 9e5dc42

Please sign in to comment.