Skip to content

Commit

Permalink
rcon update
Browse files Browse the repository at this point in the history
  • Loading branch information
jgniecki committed Jul 26, 2024
1 parent dbb3c84 commit 2908dc8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ It enables downloading basic server information and sending commands.
$console->sendCommand("bc MCPack");
```

Look [here](https://github.com/jgniecki/MinecraftStatus)
Look [here](https://github.com/jgniecki/MinecraftStatus) for Query

Look [here](https://github.com/jgniecki/MinecraftRcon) for RCON

### ServerManager with SSH

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"require": {
"php": ">=7.4",
"xpaw/php-minecraft-query": "^4.0",
"thedudeguy/rcon": "^1.0",
"phpseclib/phpseclib": "^2.0",
"dev-lancer/minecraft-rcon": "^1.0",
"dev-lancer/minecraft-status": "^3.0",
"dev-lancer/minecraft-motd-parser": "^1.0",
"symfony/polyfill-php83": "^1.30",
"ext-json": "*",
"ext-json": "*",
"symfony/config": "^5.4",
"symfony/serializer": "^5.4",
"symfony/property-access": "^5.4"
Expand Down
2 changes: 1 addition & 1 deletion src/ConsoleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
interface ConsoleInterface
{
public function sendCommand($command): bool;
public function sendCommand(string $command): bool;
public function getResponse(): ?string;
public function isConnected(): bool;
}
28 changes: 6 additions & 22 deletions src/ConsoleRcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,20 @@
namespace DevLancer\MCPack;


use Thedudeguy\Rcon;
use DevLancer\MinecraftRcon\Rcon;

/**
* Class ConsoleRcon
* @package DevLancer\MCPack
*/
class ConsoleRcon extends Rcon implements ConsoleInterface
{
/**
* @param string $command
* @return bool
*/
public function sendCommand($command): bool
public function sendCommand(string $command): bool
{
if (!$this->isConnected())
$this->connect();
if (!$this->isConnected() && !$this->connect()) {
return false;
}

return (bool) parent::sendCommand($command);
}

public function getResponse(): ?string
{
if ($this->isConnected())
return parent::getResponse();

return null;
}

public function isConnected(): bool
{
return parent::isConnected();
return parent::sendCommand($command) !== false;
}
}

0 comments on commit 2908dc8

Please sign in to comment.