Skip to content
Permalink
Browse files

Merge pull request #12 from EvoTM/develop

Develop
  • Loading branch information...
brakerb committed Jun 14, 2019
2 parents 2814283 + 6bd8a81 commit b4f7e2489fb4799cbb7345233d2090bde4f4a4f5
Showing with 707 additions and 163 deletions.
  1. +2 −5 README.md
  2. +1 −1 config/default/database.config.json
  3. +3 −3 config/default/server.config.json
  4. +6 −2 core/Classes/ChatCommand.php
  5. +28 −9 core/Classes/ManiaLinkDrag.php
  6. +4 −4 core/Classes/Server.php
  7. +11 −44 core/Controllers/BansController.php
  8. +38 −17 core/Controllers/ChatController.php
  9. +35 −2 core/Controllers/ConfigController.php
  10. +2 −1 core/Controllers/ModuleController.php
  11. +5 −1 core/Controllers/PlayerController.php
  12. +251 −0 core/Controllers/SetupController.php
  13. +1 −1 core/Controllers/TemplateController.php
  14. +3 −1 core/Modules/_tester/TestModule.php
  15. +72 −1 core/Modules/ban-gui/BanGUI.php
  16. +106 −0 core/Modules/ban-gui/Templates/add.latte.xml
  17. +64 −0 core/Modules/ban-gui/Templates/list.latte.xml
  18. 0 core/Modules/ban-gui/Templates/manialink.latte.xml
  19. BIN core/Modules/clock/Resources/long.png
  20. BIN core/Modules/clock/Resources/ring.png
  21. BIN core/Modules/clock/Resources/short.png
  22. +3 −3 core/Modules/clock/Templates/clock.latte.xml
  23. +1 −1 core/Modules/dedimania-records/Templates/manialink.latte.xml
  24. +1 −1 core/Modules/discord/Template/widget.latte.xml
  25. +6 −5 core/Modules/gear-info/Templates/meter.latte.xml
  26. +1 −1 core/Modules/group-manager/Templates/overview.latte.xml
  27. +1 −1 core/Modules/help/Templates/window.latte.xml
  28. +1 −1 core/Modules/info-messages/Templates/manialink.latte.xml
  29. +1 −1 core/Modules/key-binds/Templates/settings.latte.xml
  30. +1 −1 core/Modules/local-records/Templates/manialink.latte.xml
  31. +1 −1 core/Modules/map-list/Templates/manialink.latte.xml
  32. +15 −13 core/Modules/matchsettings-manager/MatchSettingsManager.php
  33. +1 −1 core/Modules/music-client/Templates/music-client.latte.xml
  34. +5 −4 core/Modules/music-client/music.config.json
  35. +1 −1 core/Modules/mx-details/Templates/window.latte.xml
  36. +1 −1 core/Modules/patreon-button/Template/widget.latte.xml
  37. BIN core/Modules/patreon-button/patreon.png
  38. +2 −2 core/Modules/paypal/Template/widget.latte.xml
  39. +7 −1 core/Modules/player-list/Playerlist.php
  40. +2 −2 core/Modules/player-list/Templates/window.latte.xml
  41. +1 −1 core/Modules/profile-viewer/Templates/window.latte.xml
  42. +1 −1 core/Modules/roundtime/Templates/meter.latte.xml
  43. +1 −1 core/Modules/speedometer/Templates/meter.latte.xml
  44. +4 −6 core/global-functions.php
  45. +1 −1 core/migrate.php
  46. +16 −20 core/run.php
@@ -21,11 +21,8 @@ A server controller for Trackmania² based on PHP 7.2 with Maniaplanet 4.1 suppo
###### Clean installation
1. Clone project `git clone https://github.com/EvoTM/EvoSC.git`.
2. Switch to the new directory.
3. (Checkout develop branch `git checkout develop` to get the latest version).
4. Install required packages with `composer install`.
5. Run the controller `php esc run` it will exit with "Cannot open socket" because the configs are empty (This step is nessecay to copy all required config files to the /config directory).
6. Run `php esc migrate` to create the database tables.
7. Run EvoSC with `php esc run`.
3. Install required packages with `composer install`.
4. Run EvoSC with `php esc run`.

| ⚠ If the cache and log folder are not created automatically, you need to create them and restart the controller. |
| --- |
@@ -1,5 +1,5 @@
{
"host": "127.0.0.1",
"host": "",
"db": "",
"user": "",
"password": "",
@@ -1,15 +1,15 @@
{
"login": "",
"ip": "127.0.0.1",
"port": 5000,
"ip": "",
"port": 0,
"rpc": {
"login": "",
"password": ""
},
"default-matchsettings": "",
"matchsettings-directory": "MatchSettings",
"map-cooldown": 10,
"afk-timeout": 8,
"afk-timeout": 5,
"controller-interval": 100,
"enable-chat-routing": true,
"echoes": {
@@ -3,6 +3,7 @@
namespace esc\Classes;
use esc\Models\AccessRight;
use esc\Models\Player;
use Illuminate\Support\Collection;
@@ -64,8 +65,11 @@ public static function add(string $command, $callback, string $description = '-'
$chatCommand = new ChatCommand($command, $callback, $description, $access, $hidden);
self::$commands->put($command, $chatCommand);
// if(!config('enable-chat-routing')){
// }
if ($access && $access != 'ma') {
if (!AccessRight::whereName($access)->exists()) {
Log::warning("Missing access-right: $access");
}
}
return $chatCommand;
}
@@ -32,39 +32,58 @@ public function __toString()
{
return '
Void maniaLinkDrag(){
declare frame <=> (Page.MainFrame.GetFirstChild("' . $this->targetId . '") as CMlFrame);
declare Vec2[Text] lastFramePosition for This;
declare handle <=> (Page.MainFrame.GetFirstChild("' . $this->targetId . '") as CMlFrame);
if(!frame.Parent.Visible){
if(!handle.Parent.Visible){
return;
}
declare framePos = frame.AbsolutePosition_V3;
declare frameSize = frame.Size;
declare Text handleId = handle.DataAttributeGet("id");
if(handleId == ""){
handleId = "" ^ handle.Id;
}
declare framePos = handle.AbsolutePosition_V3;
declare frameSize = handle.Size;
if(handle.Parent.DataAttributeGet("centered") != "centered"){
if(lastFramePosition.existskey(handleId)){
handle.Parent.RelativePosition_V3 = lastFramePosition[handleId];
}else{
handle.Parent.RelativePosition_V3 = <handle.Parent.Size[0]/-2.0, handle.Parent.Size[1]/2.0>;
}
handle.Parent.DataAttributeSet("centered", "centered");
}
if(MouseLeftButton){
if(MouseX >= framePos[0]){
if(MouseY <= framePos[1]){
if(MouseX <= (framePos[0] + frameSize[0]) && MouseY >= (framePos[1] - frameSize[1])){
declare Real ZIndex for LocalUser = 305.0;
declare startPos = frame.Parent.RelativePosition_V3;
declare startPos = handle.Parent.RelativePosition_V3;
declare startX = MouseX;
declare startY = MouseY;
if(frame.Parent.ZIndex > ZIndex){
ZIndex = frame.Parent.ZIndex;
if(handle.Parent.ZIndex > ZIndex){
ZIndex = handle.Parent.ZIndex;
}
ZIndex = ZIndex + 1.0;
frame.Parent.ZIndex = ZIndex;
handle.Parent.ZIndex = ZIndex;
while(MouseLeftButton){
yield;
declare newPosX = startPos[0] + (MouseX - startX);
declare newPosY = startPos[1] + (MouseY - startY);
frame.Parent.RelativePosition_V3 = <newPosX, newPosY>;
handle.Parent.RelativePosition_V3 = <newPosX, newPosY>;
}
lastFramePosition[handleId] = handle.Parent.RelativePosition_V3;
}
}
}
@@ -86,7 +86,7 @@
* @method static bool unIgnore(string $string)
* @method static bool unIgnoreId(int $int)
* @method static bool cleanIgnoreList()
* @method static array getIgnoreList(int $int, int $int)
* @method static array getIgnoreList(int $int = null, int $int = null)
* @method static int pay(string $string, int $int, string $string)
* @method static int sendBill(string $string, int $int, string $string, string $string = null)
* @method static object getBillState(int $int)
@@ -246,7 +246,7 @@
* @method static object getNextMapInfo()
* @method static object getMapInfo(string $string)
* @method static bool checkMapForCurrentServerParams(string $string)
* @method static array getMapList(int $int = null, int $int = null)
* @method static array getMapList(int $int = 0, int $int = 0)
* @method static bool addMap(string $string)
* @method static int addMapList(array $array)
* @method static bool removeMap(string $string)
@@ -259,8 +259,8 @@
* @method static int appendPlaylistFromMatchSettings(string $string)
* @method static int saveMatchSettings(string $string)
* @method static int insertPlaylistFromMatchSettings(string $string)
* @method static array getPlayerList(int $int, int $int, int $int = null)
* @method static \Maniaplanet\DedicatedServer\Structures\PlayerInfo getPlayerInfo(string $string, int $int = null)
* @method static array getPlayerList(int $int = 0, int $int = 0, int $int = 0)
* @method static \Maniaplanet\DedicatedServer\Structures\PlayerInfo getPlayerInfo(string $string, int $int = 0)
* @method static \Maniaplanet\DedicatedServer\Structures\PlayerDetailedInfo getDetailedPlayerInfo(string $string)
* @method static object getMainServerPlayerInfo(int $int)
* @method static array getCurrentRanking(int $int, int $int)
@@ -28,66 +28,33 @@ public static function init()
{
AccessRight::createIfNonExistent('player_ban', 'Ban and unban players.');
ChatCommand::add('//ban', [self::class, 'banPlayer'], 'Ban player by nickname.', 'player_ban');
ManiaLinkEvent::add('ban', [self::class, 'banPlayerEvent'], 'player_ban');
}
/**
* Ban a player
*
* @param \esc\Models\Player $player The player to be banned
* @param \esc\Models\Player $toBan The player to be banned
* @param \esc\Models\Player $admin The admin who is banning
* @param string $reason The reason
*/
public static function ban(Player $player, Player $admin, string $reason = '')
public static function ban(Player $toBan, Player $admin, string $reason = '')
{
Server::banAndBlackList($player->Login, $reason, true);
warningMessage($admin, ' banned ', $player, ', reason: ', secondary($reason))->sendAll();
$player->update(['banned' => 1]);
Server::banAndBlackList($toBan->Login, $reason, true);
warningMessage($admin, ' banned ', $toBan, ', reason: ', secondary($reason))->sendAll();
$toBan->update(['banned' => 1]);
}
/**
* Unban a player
*
* @param \esc\Models\Player $player The player to be unbanned
* @param \esc\Models\Player $admin The admin who is unbanning
*/
public static function unban(Player $player, Player $admin)
{
Server::unBan($player->Login);
infoMessage($admin, ' unbanned ', $player)->sendAll();
$player->update(['banned' => 0]);
}
/**
* [INTERNAL] Handle ban player mania script action
*
* @param \esc\Models\Player $admin
* @param $login
* @param string $reason
* @param \esc\Models\Player $toUnban The player to be unbanned
* @param \esc\Models\Player $admin The admin who is unbanning
*/
public static function banPlayerEvent(Player $admin, $cmd, $login, $reason = '')
public static function unban(Player $toUnban, Player $admin)
{
self::ban(player($login), $admin, $reason);
}
/**
* [INTERNAL] Handle ban player chat command
*
* @param \esc\Models\Player $admin
* @param $cmd
* @param $nick
* @param mixed ...$reason
*/
public static function banPlayer(Player $admin, $cmd, $nick, ...$reason)
{
$playerToBeBanned = PlayerController::findPlayerByName($admin, $nick);
if (!$playerToBeBanned) {
return;
}
self::ban($playerToBeBanned, $admin, implode(' ', $reason));
Server::unBan($toUnban->Login);
infoMessage($admin, ' unbanned ', $toUnban)->sendAll();
$toUnban->update(['banned' => 0]);
}
}
@@ -35,7 +35,7 @@ class ChatController implements ControllerInterface
public static function init()
{
self::$mutedPlayers = collect();
self::$routingEnabled = config('server.enable-chat-routing') ?? true;
self::$routingEnabled = config('server.enable-chat-routing');
if (self::$routingEnabled) {
Log::logAddLine('ChatController', 'Enabling manual chat routing.');
@@ -56,19 +56,47 @@ public static function init()
AccessRight::createIfNonExistent('player_mute', 'Mute/unmute player.');
AccessRight::createIfNonExistent('admin_echoes', 'Receive admin messages.');
ChatCommand::add('//mute', [self::class, 'muteCmd'], 'Mutes a player by given nickname', 'player_mute');
ChatCommand::add('//unmute', [self::class, 'unmute'], 'Unmute a player by given nickname', 'player_mute');
ChatCommand::add('//mute', [self::class, 'cmdMute'], 'Mutes a player by given nickname', 'player_mute');
ChatCommand::add('//unmute', [self::class, 'cmdUnmute'], 'Unmute a player by given nickname', 'player_mute');
ChatCommand::add('/pm', [self::class, 'pm'], 'Send a private message. Usage: /pm <partial_nick> message...');
}
/**
* Mute a player
*
* @param \esc\Models\Player $admin
* @param \esc\Models\Player $target
*/
public static function mute(Player $admin, Player $target)
{
if (!self::isPlayerMuted($target)) {
Server::ignore($target->Login);
}
infoMessage($admin, ' muted ', $target)->sendAll();
}
/**
* Unmute a player
*
* @param \esc\Models\Player $player
* @param \esc\Models\Player $target
*/
public static function unmute(Player $player, Player $target)
{
if (!self::isPlayerMuted($target)) {
Server::unIgnore($target->Login);
}
infoMessage($player, ' unmuted ', $target)->sendAll();
}
/**
* Chat-command: mute player.
*
* @param \esc\Models\Player $admin
* @param $cmd
* @param $nick
*/
public static function muteCmd(Player $admin, $cmd, $nick)
public static function cmdMute(Player $admin, $cmd, $nick)
{
$target = PlayerController::findPlayerByName($admin, $nick);
@@ -80,26 +108,14 @@ public static function muteCmd(Player $admin, $cmd, $nick)
self::mute($admin, $target);
}
/**
* Mute a player
*
* @param \esc\Models\Player $admin
* @param \esc\Models\Player $target
*/
public static function mute(Player $admin, Player $target)
{
Server::ignore($target->Login);
infoMessage($admin, ' muted ', $target)->sendAll();
}
/**
* Chat-command: unmute player.
*
* @param \esc\Models\Player $player
* @param $cmd
* @param $nick
*/
public static function unmute(Player $player, $cmd, $nick)
public static function cmdUnmute(Player $player, $cmd, $nick)
{
$target = PlayerController::findPlayerByName($player, $nick);
@@ -112,6 +128,11 @@ public static function unmute(Player $player, $cmd, $nick)
infoMessage($player, ' unmuted ', $target)->sendAll();
}
public static function isPlayerMuted(Player $player)
{
return collect(Server::getIgnoreList())->contains('login', '=', $player->Login);
}
/**
* Chat-command: send pm to a player
*
@@ -5,7 +5,9 @@
use esc\Classes\File;
use esc\Classes\Log;
use esc\Interfaces\ControllerInterface;
use esc\Models\AccessRight;
use Illuminate\Support\Collection;
class ConfigController implements ControllerInterface
@@ -53,11 +55,42 @@ public static function hasConfig(string $id): bool
return self::$config->has($id);
}
/**
* @param string $id
* @param string|\stdClass|array|int|float|double|bool $value
*/
public static function saveConfig(string $id, $value)
{
self::setConfig($id, $value);
$idParts = collect(explode('.', $id));
$file = $idParts->shift();
$configFile = configDir($file . '.config.json');
$jsonData = File::get($configFile, true);
$path = $idParts->map(function ($part) {
return sprintf("{'%s'}", $part);
})->implode('->');
eval('$jsonData->' . $path . ' = $value;');
File::put($configFile, json_encode($jsonData, JSON_PRETTY_PRINT));
Log::logAddLine('ConfigController', "Updated config $id", isVerbose());
}
/**
* @param string $id
* @param string|\stdClass|array|int|float|double|bool $value
*/
public static function setConfig(string $id, $value)
{
self::$config->put($id, $value);
}
private static function loadConfigurationFiles()
{
$defaultConfigFiles = collect();
$defaultConfigFiles = File::getFilesRecursively(configDir('default'), self::$configFilePattern);
$defaultConfigFiles = $defaultConfigFiles->merge(File::getFilesRecursively(coreDir('Modules'), self::$configFilePattern));
$defaultConfigFiles = $defaultConfigFiles->merge(File::getFilesRecursively(coreDir('../config/default'), self::$configFilePattern));
$defaultConfigFiles = $defaultConfigFiles->merge(File::getFilesRecursively(coreDir('../modules'), self::$configFilePattern));
$defaultConfigFiles->each(function ($configFile) {

0 comments on commit b4f7e24

Please sign in to comment.
You can’t perform that action at this time.