Compare commits
2 Commits
13d209a00a
...
3c79f09c77
Author | SHA1 | Date | |
---|---|---|---|
3c79f09c77 | |||
957c7df61c |
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,6 +5,7 @@
|
||||
!MatchManagerSuite
|
||||
!MatchManagerSuite/*
|
||||
!Beu
|
||||
!Beu/AFKNotifier.php
|
||||
!Beu/ChatAdminColorer.php
|
||||
!Beu/ReloadDevTool.php
|
||||
!Beu/GuestlistManager.php
|
||||
@ -12,3 +13,4 @@
|
||||
!Beu/SimpleChatColorer.php
|
||||
!Beu/SimpleSkinsRemover.php
|
||||
!Beu/BeuDonationButton.php
|
||||
!Beu/GameModeLoader.php
|
122
Beu/AFKNotifier.php
Normal file
122
Beu/AFKNotifier.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
namespace Beu;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
|
||||
/**
|
||||
* AFKNotifier
|
||||
*
|
||||
* @author Beu
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AFKNotifier implements CallbackListener, Plugin {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 187;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_NAME = 'AFK Notifier';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
const CB_IsAFK = 'AFK.IsAFK';
|
||||
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return "Notify in the chat that a player has been kicked by the official AFK library";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerScriptCallbackListener(self::CB_IsAFK, $this, 'handleIsAFK');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when a player disconnects
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function handleIsAFK(array $data) {
|
||||
$json = json_decode($data[1][0],false);
|
||||
foreach ($json->accountIds as $accountid) {
|
||||
$login = $this->getLoginFromAccountID($accountid);
|
||||
Logger::log("Player " . $login . " has been kicked by the AFK lib");
|
||||
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
if ($player !== null) {
|
||||
$this->maniaControl->getChat()->sendInformation("\$ff9" . $player->nickname . " has been kicked for being AFK");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getLoginFromAccountID(string $accountid) {
|
||||
$accountid = str_replace("-","", $accountid);
|
||||
$login = "";
|
||||
foreach(str_split($accountid, 2) as $pair){
|
||||
$login .= chr(hexdec($pair));
|
||||
}
|
||||
$login = base64_encode($login);
|
||||
$login = str_replace("+", "-", str_replace("/","_",$login));
|
||||
$login = trim($login,"=");
|
||||
|
||||
return $login;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unload the plugin and its Resources
|
||||
*/
|
||||
public function unload() {
|
||||
|
||||
}
|
||||
}
|
109
Beu/GameModeLoader.php
Normal file
109
Beu/GameModeLoader.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace Beu;
|
||||
|
||||
use Exception;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
|
||||
/**
|
||||
* GameModeLoader
|
||||
*
|
||||
* @author Beu
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class GameModeLoader implements CommandListener, Plugin {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 191;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_NAME = 'GameModeLoader';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return "Simple plugin to load any mode with the command //mode";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('mode', $this, 'commandMode', true, 'Add all connected players to the guestlist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when a player connects
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
public function commandMode(array $chatCallback, Player $player) {
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
if (array_key_exists(1, $params) && $params[1] !== "") {
|
||||
try {
|
||||
$this->maniaControl->getClient()->setScriptName($params[1]);
|
||||
$this->maniaControl->getChat()->sendSuccess("Game mode loaded, restart or skip the map", $player->login);
|
||||
Logger::log("Game mode " . $params[1] . " loaded by " . $player->login);
|
||||
} catch (Exception $e) {
|
||||
$this->maniaControl->getChat()->sendError("Can't load the game mode: " . $e->getMessage(), $player->login);
|
||||
Logger::log("Can't load the game mode: " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError("usage: //mode TrackMania/TM_TimeAttack_Online.Script.txt", $player->login);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload the plugin and its Resources
|
||||
*/
|
||||
public function unload() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user