Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jgniecki/mcpack
🐘 The library is designed to integrate the minecraft server with the website
https://github.com/jgniecki/mcpack
console devlancer lib library mc mcpack minecraft minecraft-console minecraft-motd minecraft-query minecraft-rcon minecraft-server motd pack package query rcon server website www
Last synced: 3 months ago
JSON representation
🐘 The library is designed to integrate the minecraft server with the website
- Host: GitHub
- URL: https://github.com/jgniecki/mcpack
- Owner: jgniecki
- License: mit
- Created: 2020-07-14T11:06:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-26T19:17:38.000Z (6 months ago)
- Last Synced: 2024-11-06T17:24:59.318Z (3 months ago)
- Topics: console, devlancer, lib, library, mc, mcpack, minecraft, minecraft-console, minecraft-motd, minecraft-query, minecraft-rcon, minecraft-server, motd, pack, package, query, rcon, server, website, www
- Language: PHP
- Homepage: https://packagist.org/packages/dev-lancer/mc-pack
- Size: 53.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP MCPack [![Packagist](https://img.shields.io/packagist/dt/dev-lancer/mc-pack.svg)](https://packagist.org/packages/dev-lancer/mc-pack)
## Installation
This library can installed by issuing the following command:
```bash
composer require dev-lancer/mc-pack
```### Query
This method uses GameSpy4 protocol, and requires enabling `query` listener in your `server.properties` like this:> *enable-query=true*
> *query.port=25565*### Rcon
This method allows you to send commands, it is used in item shop, and requires enabling `rcon` listener in your `server.properties` like this:> *enable-rcon=true*
> *rcon.port=25575*
> *rcon.password=pass*## Example
### Query & RconIt enables downloading basic server information and sending commands.
```php
connect();
$console = new ConsoleRcon("some.minecraftserver.com", 25575, "pass", 3);
$console->connect();$players = $info->getCountPlayers();
echo $players . "/" . $info->getMaxPlayers();$console->sendCommand("bc MCPack");
```Look [here](https://github.com/jgniecki/MinecraftStatus) for Query
Look [here](https://github.com/jgniecki/MinecraftRcon) for RCON
### ServerManager with SSH
It enables downloading basic server information, sending commands and server management.
```php
login("username", "password");$server = new ServerManager($sftp, 25565);
$path = "path/to/minecraft/server.jar";
if(!$server->isRunning()) {
if ($server->run(["-Xmx1G"], $path))
echo "server started";
}
```### Server logs
This class allows downloading logs from the server.
```php
login("username", "password");$path = "path/to/minecraft/logs/latest.log";
$logs = new Logs($sftp, $path);
echo implode("
", $logs->getLogs(true));
```### Properties
```php
login("username", "password");
$manager = new PropertiesManager("path/to/minecraft/server.properties", $sftp);
$properties = $manager->getProperties();
$properties->setRconPassword("new-password");
$manager->saveProperties($properties);
```### Motd
```php
connect();
$motd = new Motd($info);
$motd->sendRequest();
echo $motd->getResponse(Motd::RESPONSE_HTML);
```Look [here](https://github.com/jgniecki/MinecraftMotdParser)
## License
[MIT](LICENSE)