PHP code example of radic / bukkit-swift-api

1. Go to this page and download the library: Download radic/bukkit-swift-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radic / bukkit-swift-api example snippets


'providers' => array(
    // ..
    'Radic\BukkitSwiftApi\BukkitSwiftApiServiceProvider',
),
'aliases' => array(
    // ..
    'SwiftApi'               => 'Radic\BukkitSwiftApi\Facades\SwiftApi',
)

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        
    )
);

// 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');   

$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);

$api = SwiftApi::connect();
$calls[] = $api->getServer();
$calls[] = $api->getPlugins();
$calls[] = $api->getOfflinePlayers();
$calls[] = $api->ping();
$calls[] = $api->getOps();
$api->disconnect();
var_dump($calls);