Package Data | |
---|---|
Maintainer Username: | radic |
Maintainer Contact: | robin@radic.nl (Robin Radic) |
Package Create Date: | 2014-07-07 |
Package Last Update: | 2014-07-16 |
Language: | PHP |
License: | GNU General Public License version 3 (GPLv3) |
Last Refreshed: | 2024-12-17 03:01:38 |
Package Statistics | |
---|---|
Total Downloads: | 36 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Wraps the Apache Thrift generated PHP library for SwiftAPI in a Laravel Package and provides easy access trough a Facade.
SwiftAPI is a Bukkit plugin that allows you to use the generated API to make simple calls to the Bukkit server over the webz. Or if wanted, you can generate it yourself using Apache Thrift. This makes SwiftAPI usable in almost any programming language.
Require with composer:
composer require radic/bukkit-swift-api
Or add to composer.json:
{
"radic/bukkit-swift-api": "dev-master"
}
Register service provder and facade in app/config/app.php
'providers' => array(
// ..
'Radic\BukkitSwiftApi\BukkitSwiftApiServiceProvider',
),
'aliases' => array(
// ..
'SwiftApi' => 'Radic\BukkitSwiftApi\Facades\SwiftApi',
)
Use php artisan config:publish radic/bukkit-swift-api
to edit the default configuration.
array(
'global' => array(
'host' => 'localhost',
'port' => 21111,
'username' => 'admin',
'password' => 'test',
'salt' => 'saltines'
),
'my-other-server' => array(
'host' => '11.11.11.11',
'username' => 'admin',
'password' => 'test'
// If you left out config settings, it will use the global for that setting
)
);
There are several ways to connect:
// Uses global config settings
$api = SwiftAPI::connect();
// Define all connection parameters inline
$api = SwiftAPI::connect('ip-or-host', 4444, 'username', 'password', 'crypt-salt');
// null or left out parameters will default back to the global config
$api = SwiftAPI::connect('ip-or-host', null, 'username', 'password');
// Uses 'my-other-server' from conffig.
$api = SwiftAPI::connectTo('my-other-server');
Example connection:
$api = SwiftApi::connect();
if($api->isConnected())
{
var_dump('Connected');
$serverInfo = $api->getServer();
$api->disconnect();
var_dump($serverInfo);
}
else
{
var_dump( $api->getConnectionException()->getMessage() );
}
$api->addToWhitelist($name);
$api->announce($message);
$api->ban($name);
$api->banIp($ip);
$api->deOp($name, $notifyPlayer);
$api->getBannedIps();
$api->getBannedPlayers();
$api->getBukkitVersion();
$api->getConsoleMessages($since);
$api->getFileContents($fileName);
$api->getOfflinePlayer($name);
$api->getOfflinePlayers();
$api->getOps();
$api->getPlayer($name);
$api->getPlayers();
$api->getPlugin($name);
$api->getPlugins();
$api->getServer();
$api->getServerVersion();
$api->getWhitelist();
$api->getWorld($worldName);
$api->getWorlds();
$api->installPlugin($downloadUrl, $md5);
$api->kick($name, $message);
$api->op($name, $notifyPlayer);
$api->ping();
$api->reloadServer();
$api->removeFromWhitelist($name);
$api->replacePlugin($pluginName, $downloadUrl, $md5);
$api->runConsoleCommand($command);
$api->saveWorld($worldName);
$api->setFileContents($fileName, $fileContents);
$api->setGameMode($name, $mode);
$api->setPvp($worldName, $isPvp);
$api->setStorm($worldName, $hasStorm);
$api->setThundering($worldName, $isThundering);
$api->setWorldTime($worldName, $time);
$api->unBan($name);
$api->unBanIp($ip);
See here which methods return data, and how that data is structured. A quick example:
$api = SwiftApi::connect();
$calls[] = $api->getServer();
$calls[] = $api->getPlugins();
$calls[] = $api->getOfflinePlayers();
$calls[] = $api->ping();
$calls[] = $api->getOps();
$api->disconnect();
var_dump($calls);
You'll get something like this in return
Check my Laravel Bukkit Console. A web based console to directly interact with your Bukkit Server.
GNU General Public License version 3 (GPLv3)