TrackManiaControl/application/plugins/obstacle.plugin.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2013-11-07 20:13:13 +01:00
<?php
2013-11-09 11:19:21 +01:00
namespace ManiaControl;
2013-11-07 20:13:13 +01:00
/**
2013-11-09 11:19:21 +01:00
* ManiaControl Obstacle Plugin
2013-11-07 20:13:13 +01:00
*
* @author steeffeen
*/
class Plugin_Obstacle extends Plugin {
/**
* Constants
*/
const CB_JUMPTO = 'Obstacle.JumpTo';
const VERSION = '1.0';
/**
* Private properties
*/
2013-11-09 10:45:29 +01:00
private $mControl = null;
2013-11-07 20:13:13 +01:00
private $config = null;
/**
* Constuct obstacle plugin
*/
2013-11-09 10:45:29 +01:00
public function __construct($mControl) {
$this->mControl = $mControl;
2013-11-07 20:13:13 +01:00
// Load config
$this->config = Tools::loadConfig('obstacle.plugin.xml');
// Check for enabled setting
if (!Tools::toBool($this->config->enabled)) return;
// Register for jump command
$this->iControl->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
error_log('Obstacle Pugin v' . self::VERSION . ' ready!');
}
/**
* Handle jumpto command
*/
public function command_jumpto($chat) {
$login = $chat[1][1];
$rightLevel = (string) $this->config->jumps_rightlevel;
if (!$this->iControl->authentication->checkRight($login, $rightLevel)) {
// Not allowed
$this->iControl->authentication->sendNotAllowed($login);
}
else {
// Send jump callback
$params = explode(' ', $chat[1][2], 2);
$param = $login . ";" . $params[1] . ";";
if (!$this->iControl->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->iControl->getClientErrorText());
}
}
}
}
?>