readded team plugins with proper names
added empty files for replacing old files
This commit is contained in:
160
application/plugins/steeffeen/ChatlogPlugin.php
Normal file
160
application/plugins/steeffeen/ChatlogPlugin.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace steeffeen;
|
||||
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Files\FileUtil;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
|
||||
/**
|
||||
* ManiaControl Chatlog Plugin
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ChatlogPlugin implements CallbackListener, Plugin {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const ID = 26;
|
||||
const VERSION = 0.2;
|
||||
const DATE = 'd-m-y h:i:sa T';
|
||||
const SETTING_FOLDERNAME = 'Log-Folder Name';
|
||||
const SETTING_FILENAME = 'Log-File Name';
|
||||
const SETTING_USEPID = 'Use Process-Id for File Name';
|
||||
const SETTING_LOGSERVERMESSAGES = 'Log Server Messages';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
/** @var maniaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $fileName = null;
|
||||
private $logServerMessages = true;
|
||||
|
||||
/**
|
||||
* Prepares the Plugin
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
* @return mixed
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Init settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_FOLDERNAME, 'logs');
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_FILENAME, 'ChatLog.log');
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_USEPID, false);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LOGSERVERMESSAGES, true);
|
||||
|
||||
// Get settings
|
||||
$folderName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FOLDERNAME);
|
||||
$folderName = FileUtil::getClearedFileName($folderName);
|
||||
$folderDir = ManiaControlDir . $folderName;
|
||||
if (!is_dir($folderDir)) {
|
||||
$success = mkdir($folderDir);
|
||||
if (!$success) {
|
||||
trigger_error("Couldn't create chat log folder '{$folderName}'.");
|
||||
}
|
||||
}
|
||||
$fileName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FILENAME);
|
||||
$fileName = FileUtil::getClearedFileName($fileName);
|
||||
$usePId = $this->maniaControl->settingManager->getSetting($this, self::SETTING_USEPID);
|
||||
if ($usePId) {
|
||||
$dotIndex = strripos($fileName, '.');
|
||||
$pIdPart = '_' . getmypid();
|
||||
if ($dotIndex !== false && $dotIndex >= 0) {
|
||||
$fileName = substr($fileName, 0, $dotIndex) . $pIdPart . substr($fileName, $dotIndex);
|
||||
} else {
|
||||
$fileName .= $pIdPart;
|
||||
}
|
||||
}
|
||||
$this->fileName = $folderDir . DIRECTORY_SEPARATOR . $fileName;
|
||||
$this->logServerMessages = $this->maniaControl->settingManager->getSetting($this, self::SETTING_LOGSERVERMESSAGES);
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
public function unload() {
|
||||
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||
unset($this->maniaControl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||
*/
|
||||
public static function getName() {
|
||||
return 'Chatlog Plugin';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return 'steeffeen';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return 'Plugin logging the Chat Messages of the Server for later Checks and Controlling.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PlayerChat callback
|
||||
*
|
||||
* @param array $chatCallback
|
||||
*/
|
||||
public function handlePlayerChatCallback(array $chatCallback) {
|
||||
$data = $chatCallback[1];
|
||||
if ($data[0] <= 0 && !$this->logServerMessages) {
|
||||
// Skip server message
|
||||
return;
|
||||
}
|
||||
$this->logText($data[2], $data[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given message
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $login
|
||||
*/
|
||||
private function logText($text, $login = null) {
|
||||
if (!$login) {
|
||||
$login = '';
|
||||
}
|
||||
$message = date(self::DATE) . " >> {$login}: {$text}" . PHP_EOL;
|
||||
file_put_contents($this->fileName, $message, FILE_APPEND);
|
||||
}
|
||||
}
|
157
application/plugins/steeffeen/EndurancePlugin.php
Normal file
157
application/plugins/steeffeen/EndurancePlugin.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace steeffeen;
|
||||
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Maps\Map;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Maps\MapManager;
|
||||
|
||||
/**
|
||||
* Plugin for the TM Game Mode 'Endurance' by TGYoshi
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class EndurancePlugin implements CallbackListener, Plugin {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const ID = 25;
|
||||
const VERSION = 0.2;
|
||||
const CB_CHECKPOINT = 'Endurance.Checkpoint';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
/** @var maniaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var Map $currentMap */
|
||||
private $currentMap = null;
|
||||
private $playerLapTimes = array();
|
||||
|
||||
/**
|
||||
* Prepares the Plugin
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
* @return mixed
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'callback_OnInit');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'callback_BeginMap');
|
||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::CB_CHECKPOINT, $this, 'callback_Checkpoint');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
public function unload() {
|
||||
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||
$this->maniaControl->callbackManager->unregisterScriptCallbackListener($this);
|
||||
unset($this->maniaControl);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::ID;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||
*/
|
||||
public static function getName() {
|
||||
return 'Endurance Plugin';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return 'steeffeen';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return "Plugin enabling Support for the TM Game Mode 'Endurance' by TGYoshi.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle ManiaControl OnInit callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function callback_OnInit(array $callback) {
|
||||
$this->currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
||||
$this->playerLapTimes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle BeginMap callback
|
||||
*
|
||||
* @param Map $map
|
||||
*/
|
||||
public function callback_BeginMap(Map $map) {
|
||||
$this->currentMap = $map;
|
||||
$this->playerLapTimes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Endurance Checkpoint callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function callback_Checkpoint(array $callback) {
|
||||
$callbackData = json_decode($callback[1]);
|
||||
if (!$this->currentMap->nbCheckpoints || $callbackData->Checkpoint % $this->currentMap->nbCheckpoints != 0) {
|
||||
return;
|
||||
}
|
||||
$player = $this->maniaControl->playerManager->getPlayer($callbackData->Login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
$time = $callbackData->Time;
|
||||
if ($time <= 0) {
|
||||
return;
|
||||
}
|
||||
if (isset($this->playerLapTimes[$player->login])) {
|
||||
$time -= $this->playerLapTimes[$player->login];
|
||||
}
|
||||
$this->playerLapTimes[$player->login] = $callbackData->Time;
|
||||
// Trigger trackmania player finish callback
|
||||
$finishCallback = array($player->pid, $player->login, $time);
|
||||
$finishCallback = array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback);
|
||||
}
|
||||
}
|
181
application/plugins/steeffeen/ObstaclePlugin.php
Normal file
181
application/plugins/steeffeen/ObstaclePlugin.php
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace steeffeen;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* ManiaControl Obstacle Plugin
|
||||
*
|
||||
* @author steeffeen
|
||||
*/
|
||||
class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const ID = 24;
|
||||
const VERSION = 0.2;
|
||||
const CB_JUMPTO = 'Obstacle.JumpTo';
|
||||
const SCB_ONFINISH = 'OnFinish';
|
||||
const SCB_ONCHECKPOINT = 'OnCheckpoint';
|
||||
const SETTING_JUMPTOAUTHLEVEL = 'Authentication level for JumpTo commands';
|
||||
|
||||
/**
|
||||
* Private Properties
|
||||
*/
|
||||
/**
|
||||
* @var maniaControl $maniaControl
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
* Prepares the Plugin
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
* @return mixed
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Init settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JUMPTOAUTHLEVEL, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
// Register for commands
|
||||
$this->maniaControl->commandManager->registerCommandListener('jumpto', $this, 'command_JumpTo');
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::SCB_ONFINISH, $this, 'callback_OnFinish');
|
||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::SCB_ONCHECKPOINT, $this, 'callback_OnCheckpoint');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
public function unload() {
|
||||
$this->maniaControl->commandManager->unregisterCommandListener($this);
|
||||
$this->maniaControl->callbackManager->unregisterScriptCallbackListener($this);
|
||||
unset($this->maniaControl);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::ID;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||
*/
|
||||
public static function getName() {
|
||||
return 'Obstacle Plugin';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return 'steeffeen';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return "Plugin offering CP Jumping and Local Records Support for the ShootManie Gamemode 'Obstacle'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle JumpTo command
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function command_JumpTo(array $chatCallback, Player $player) {
|
||||
$authLevel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_JUMPTOAUTHLEVEL);
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, $authLevel)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
// Send jump callback
|
||||
$params = explode(' ', $chatCallback[1][2], 2);
|
||||
$param = $player->login . ";" . $params[1] . ";";
|
||||
try {
|
||||
$this->maniaControl->client->triggerModeScriptEvent(self::CB_JUMPTO, $param);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
trigger_error("Couldn't send jump callback for '{$player->login}'. " . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle OnFinish script callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function callback_OnFinish(array $callback) {
|
||||
$data = json_decode($callback[1]);
|
||||
$player = $this->maniaControl->playerManager->getPlayer($data->Player->Login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
$time = $data->Run->Time;
|
||||
// Trigger trackmania player finish callback
|
||||
$finishCallback = array($player->pid, $player->login, $time);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH,
|
||||
array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle OnCheckpoint script callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function callback_OnCheckpoint(array $callback) {
|
||||
$data = json_decode($callback[1]);
|
||||
$player = $this->maniaControl->playerManager->getPlayer($data->Player->Login);
|
||||
$time = $data->Run->Time;
|
||||
if (!$player || $time <= 0) {
|
||||
return;
|
||||
}
|
||||
// Trigger Trackmania player checkpoint callback
|
||||
$checkpointCallback = array($player->pid, $player->login, $time, 0, 0);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT,
|
||||
array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user