From ca461d214c2508d60a8bb950bf6eb238e65a9384 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 10 May 2017 14:22:51 +0200 Subject: [PATCH] performance tweek --- plugins/MCTeam/WidgetPlugin.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index d57a0ba7..4200fcc3 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -75,7 +75,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Private properties */ /** @var ManiaControl $maniaControl */ - private $maniaControl = null; + private $maniaControl = null; + private $lastWidgetUpdateTime = 0; /** * @see \ManiaControl\Plugins\Plugin::prepare() @@ -555,7 +556,12 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { */ public function updateWidgets() { if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { - $this->displayServerInfoWidget(); + $time = time(); + //Update Max once per second + if ($this->lastWidgetUpdateTime < ($time - 1)) { + $this->displayServerInfoWidget(); + $this->lastWidgetUpdateTime = $time; + } } } }