add BeuCustomConfig

This commit is contained in:
Beu 2023-12-14 18:18:40 +01:00
parent a1cdbe93e2
commit 9428fc3a64
2 changed files with 166 additions and 1 deletions

4
.gitignore vendored
View File

@ -6,6 +6,7 @@
!MatchManagerSuite/* !MatchManagerSuite/*
!Beu !Beu
!Beu/AFKNotifier.php !Beu/AFKNotifier.php
!Beu/BeuCustomConfig.php
!Beu/BeuDonationButton.php !Beu/BeuDonationButton.php
!Beu/ChatAdminColorer.php !Beu/ChatAdminColorer.php
!Beu/ClimbTheMap.php !Beu/ClimbTheMap.php
@ -14,4 +15,5 @@
!Beu/MoreModesTools.php !Beu/MoreModesTools.php
!Beu/ReloadDevTool.php !Beu/ReloadDevTool.php
!Beu/SimpleChatColorer.php !Beu/SimpleChatColorer.php
!Beu/SimpleSkinsRemover.php !Beu/SimpleSkinsRemover.php
!Beu/SmallTextOverlay.php

163
Beu/BeuCustomConfig.php Normal file
View File

@ -0,0 +1,163 @@
<?php
namespace Beu;
use ManiaControl\ManiaControl;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Settings\Setting;
use ManiaControl\Settings\SettingManager;
use FML\Controls\Quads\Quad_BgsPlayerCard;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Configurator\Configurator;
use ManiaControl\Manialinks\StyleManager;
use ManiaControl\Maps\MapManager;
use ManiaControl\Maps\MapQueue;
use ManiaControl\Plugins\PluginMenu;
use ManiaControl\Server\UsageReporter;
use ManiaControl\Update\UpdateManager;
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
/**
* BeuCustomConfig
*
* @author Beu
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class BeuCustomConfig implements CallbackListener, Plugin {
/*
* Constants
*/
const PLUGIN_ID = 193;
const PLUGIN_VERSION = 1.1;
const PLUGIN_NAME = 'BeuCustomConfig';
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 "A plugin to display a donation button";
}
/**
* @see \ManiaControl\Plugins\Plugin::load()
*/
public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
$this->changeManiacontrolSettings();
}
private function changeManiacontrolSettings() {
$settingstochange = [
AuthenticationManager::class => [
MapQueue::SETTING_PERMISSION_ADD_TO_QUEUE => AuthenticationManager::AUTH_LEVEL_ADMIN
],
UpdateManager::class => [
UpdateManager::SETTING_ENABLE_UPDATECHECK => false
],
UsageReporter::class => [
UsageReporter::SETTING_REPORT_USAGE => false
],
MapManager::class => [
MapManager::SETTING_AUTOSAVE_MAPLIST => false,
MapManager::SETTING_ENABLE_MX => false
],
PlayerManager::class => [
PlayerManager::SETTING_VERSION_JOIN_MESSAGE => false
],
PluginMenu::class => [
PluginMenu::SETTING_CHECK_UPDATE_WHEN_OPENING => false
],
Configurator::class => [
Configurator::SETTING_MENU_HEIGHT => 120,
Configurator::SETTING_MENU_WIDTH => 220,
],
StyleManager::class => [
StyleManager::SETTING_LIST_WIDGETS_HEIGHT => 120,
StyleManager::SETTING_LIST_WIDGETS_WIDTH => 220,
StyleManager::SETTING_LABEL_DEFAULT_STYLE => "TextClock",
StyleManager::SETTING_QUAD_DEFAULT_STYLE => Quad_BgsPlayerCard::STYLE,
StyleManager::SETTING_QUAD_DEFAULT_SUBSTYLE => Quad_BgsPlayerCard::SUBSTYLE_BgPlayerName
]
];
foreach ($settingstochange as $classname => $settings) {
foreach ($settings as $settingname => $value) {
$setting = $this->maniaControl->getSettingManager()->getSettingObject($classname, $settingname);
$setting->value = $value;
$this->maniaControl->getSettingManager()->saveSetting($setting);
}
}
// Disable all votes
$this->maniaControl->getClient()->setCallVoteRatios([
new VoteRatio(VoteRatio::COMMAND_DEFAULT, -1.),
new VoteRatio(VoteRatio::COMMAND_SCRIPT_SETTINGS, -1.),
new VoteRatio(VoteRatio::COMMAND_JUMP_MAP, -1.),
new VoteRatio(VoteRatio::COMMAND_SET_NEXT_MAP, -1.),
new VoteRatio(VoteRatio::COMMAND_KICK, -1.),
new VoteRatio(VoteRatio::COMMAND_RESTART_MAP, -1.),
new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, -1.),
new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, -1.),
new VoteRatio(VoteRatio::COMMAND_BAN, -1.)
]);
}
public function updateSettings(Setting $setting = null) {
if ($setting !== null && $setting->belongsToClass($this)) {
$this->changeManiacontrolSettings();
}
}
/**
* Unload the plugin and its Resources
*/
public function unload() {
}
}