Merge remote-tracking branch 'origin/master'
Conflicts: application/plugins/Donations.php
This commit is contained in:
@ -11,8 +11,8 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
/**
|
||||
* ManiaControl Chat-Message Plugin
|
||||
*
|
||||
* @author kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @author kremsy <kremsy@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
@ -43,6 +43,51 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Version
|
||||
*
|
||||
* @return float,,
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return "Plugin offers various Chat-Commands like /gg /hi /afk /rq...";
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the plugin
|
||||
*
|
||||
@ -113,6 +158,30 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
$this->maniaControl->chat->sendChat($msg, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for
|
||||
* (last joined)
|
||||
*
|
||||
* @param $login
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTarget($login) {
|
||||
/** @var Player $player */
|
||||
$player = null;
|
||||
foreach ($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||
if ($login == $player->login || $login == $player->pid || $login == $player->nickname) {
|
||||
return $player->nickname;
|
||||
}
|
||||
}
|
||||
|
||||
if ($player && $login == 'lj') {
|
||||
return $player->nickname;
|
||||
}
|
||||
|
||||
//returns the text given if nothing matches
|
||||
return $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bye Message
|
||||
*
|
||||
@ -314,7 +383,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
$message = '$39F Thanks for Playing, see you around!$z';
|
||||
try {
|
||||
$this->maniaControl->client->kick($player->login, $message);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line 316: " . $e->getMessage());
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
@ -335,7 +404,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
$message = '$39F Thanks for Playing, please come back soon!$z ';
|
||||
try {
|
||||
$this->maniaControl->client->kick($player->login, $message);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
@ -361,7 +430,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
// force into spec
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($player->login, 3);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
@ -371,7 +440,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
// free player slot
|
||||
try {
|
||||
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
if ($e->getMessage() != 'The player is not a spectator') {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
@ -380,73 +449,4 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for
|
||||
* (last joined)
|
||||
*
|
||||
* @param $login
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTarget($login) {
|
||||
/** @var Player $player */
|
||||
$player = null;
|
||||
foreach($this->maniaControl->playerManager->getPlayers() as $player) {
|
||||
if ($login == $player->login || $login == $player->pid || $login == $player->nickname) {
|
||||
return $player->nickname;
|
||||
}
|
||||
}
|
||||
|
||||
if ($player && $login == 'lj') {
|
||||
return $player->nickname;
|
||||
}
|
||||
|
||||
//returns the text given if nothing matches
|
||||
return $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Version
|
||||
*
|
||||
* @return float,,
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return "Plugin offers various Chat-Commands like /gg /hi /afk /rq...";
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -24,8 +24,8 @@ use ManiaControl\Plugins\Plugin;
|
||||
/**
|
||||
* ManiaControl Widget Plugin
|
||||
*
|
||||
* @author steeffeen and kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
@ -88,6 +88,51 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Version
|
||||
*
|
||||
* @return float,,
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return 'Plugin offers some Widgets';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the plugin
|
||||
*
|
||||
@ -136,22 +181,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload the plugin and its resources
|
||||
*/
|
||||
public function unload() {
|
||||
$this->closeWidget(self::MLID_CLOCKWIDGET);
|
||||
$this->closeWidget(self::MLID_SERVERINFOWIDGET);
|
||||
$this->closeWidget(self::MLID_MAPWIDGET);
|
||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||
$this->maniaControl->timerManager->unregisterTimerListenings($this);
|
||||
unset($this->maniaControl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the Widgets onLoad
|
||||
*
|
||||
* @param array $callback
|
||||
* Display the Widgets
|
||||
*/
|
||||
private function displayWidgets() {
|
||||
// Display Map Widget
|
||||
@ -168,11 +198,11 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the Map Widget
|
||||
* Display the Map Widget
|
||||
*
|
||||
* @param String $login
|
||||
* @param string $login
|
||||
*/
|
||||
public function displayMapWidget($login = false) {
|
||||
public function displayMapWidget($login = null) {
|
||||
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSX);
|
||||
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSY);
|
||||
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_WIDTH);
|
||||
@ -280,11 +310,11 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the Server Info Widget
|
||||
* Display the Server Info Widget
|
||||
*
|
||||
* @param String $login
|
||||
* @param string $login
|
||||
*/
|
||||
public function displayServerInfoWidget($login = false) {
|
||||
public function displayServerInfoWidget($login = null) {
|
||||
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX);
|
||||
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY);
|
||||
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH);
|
||||
@ -318,7 +348,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
/**
|
||||
* @var Player $player
|
||||
*/
|
||||
foreach($players as $player) {
|
||||
foreach ($players as $player) {
|
||||
if ($player->isSpectator) {
|
||||
$spectatorCount++;
|
||||
} else {
|
||||
@ -383,16 +413,16 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle on Begin Map
|
||||
*
|
||||
* @param Map $map
|
||||
* Unload the plugin and its resources
|
||||
*/
|
||||
public function handleOnBeginMap(Map $map) {
|
||||
// Display Map Widget
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||
$this->displayMapWidget();
|
||||
}
|
||||
public function unload() {
|
||||
$this->closeWidget(self::MLID_CLOCKWIDGET);
|
||||
$this->closeWidget(self::MLID_SERVERINFOWIDGET);
|
||||
$this->closeWidget(self::MLID_MAPWIDGET);
|
||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||
$this->maniaControl->timerManager->unregisterTimerListenings($this);
|
||||
unset($this->maniaControl);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,6 +435,19 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$this->maniaControl->manialinkManager->sendManialink($emptyManialink);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle on Begin Map
|
||||
*
|
||||
* @param Map $map
|
||||
*/
|
||||
public function handleOnBeginMap(Map $map) {
|
||||
// Display Map Widget
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||
$this->displayMapWidget();
|
||||
}
|
||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle on End Map
|
||||
*
|
||||
@ -543,49 +586,4 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$this->displayServerInfoWidget();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Version
|
||||
*
|
||||
* @return float,,
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plugin Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return 'Plugin offers some Widgets';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user