Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
61d2247cee
@ -14,15 +14,22 @@ class UpdateEvent extends Event
|
||||
{
|
||||
public static $handlerList = null;
|
||||
|
||||
public $time;
|
||||
public $tick;
|
||||
public $updateTypes;
|
||||
|
||||
public function __construct($time)
|
||||
public function __construct($tick, $updateTypes)
|
||||
{
|
||||
$this->time = $time;
|
||||
$this->tick = $tick;
|
||||
$this->updateTypes = $updateTypes;
|
||||
}
|
||||
|
||||
public function getTime()
|
||||
public function getTick()
|
||||
{
|
||||
return $this->time;
|
||||
return $this->tick;
|
||||
}
|
||||
|
||||
public function isTiming($type)
|
||||
{
|
||||
return in_array(type, $this->updateTypes);
|
||||
}
|
||||
}
|
@ -11,22 +11,22 @@ namespace mineplex\plugin\core\updater;
|
||||
|
||||
class UpdateType
|
||||
{
|
||||
const MIN_64 = 3840000;
|
||||
const MIN_32 = 1920000;
|
||||
const MIN_16 = 960000;
|
||||
const MIN_08 = 480000;
|
||||
const MIN_04 = 240000;
|
||||
const MIN_02 = 120000;
|
||||
const MIN_01 = 60000;
|
||||
const SLOWEST = 32000;
|
||||
const SLOWER = 16000;
|
||||
const SLOW = 4000;
|
||||
const TWOSEC = 2000;
|
||||
const SEC = 1000;
|
||||
const FAST = 500;
|
||||
const FASTER = 250;
|
||||
const FASTEST = 125;
|
||||
const TICK = 49;
|
||||
const M64 = 3840000;
|
||||
conSt M32 = 1920000;
|
||||
conSt M16 = 960000;
|
||||
conSt M8 = 480000;
|
||||
conSt M4 = 240000;
|
||||
conSt M2 = 120000;
|
||||
conSt M1 = 60000;
|
||||
conSt S32 = 32000;
|
||||
conSt S16 = 16000;
|
||||
conSt S8 = 8000;
|
||||
conSt S4 = 4000;
|
||||
conSt S2 = 2000;
|
||||
conSt S1 = 1000;
|
||||
conSt MS500 = 500;
|
||||
conSt MS250 = 250;
|
||||
conSt MS125 = 125;
|
||||
|
||||
public $time;
|
||||
|
||||
|
@ -21,29 +21,32 @@ class Updater extends PluginTask
|
||||
{
|
||||
$this->plugin = $host;
|
||||
$this->owner = $host;
|
||||
|
||||
$this->plugin->getServer()->getScheduler()->scheduleRepeatingTask($this, 1);
|
||||
|
||||
$this->updateTypes = array(
|
||||
new UpdateType(UpdateType::TICK)
|
||||
, new UpdateType(UpdateType::FASTEST)
|
||||
, new UpdateType(UpdateType::FASTER)
|
||||
, new UpdateType(UpdateType::FAST)
|
||||
, new UpdateType(UpdateType::SEC)
|
||||
, new UpdateType(UpdateType::TWOSEC)
|
||||
, new UpdateType(UpdateType::SLOW)
|
||||
, new UpdateType(UpdateType::SLOWER)
|
||||
, new UpdateType(UpdateType::SLOWEST)
|
||||
, new UpdateType(UpdateType::MIN_01)
|
||||
, new UpdateType(UpdateType::MIN_02)
|
||||
, new UpdateType(UpdateType::MIN_04)
|
||||
, new UpdateType(UpdateType::MIN_08)
|
||||
, new UpdateType(UpdateType::MIN_16)
|
||||
, new UpdateType(UpdateType::MIN_32)
|
||||
, new UpdateType(UpdateType::MIN_64));
|
||||
new UpdateType(UpdateType::MS125)
|
||||
, new UpdateType(UpdateType::MS250)
|
||||
, new UpdateType(UpdateType::MS500)
|
||||
, new UpdateType(UpdateType::S1)
|
||||
, new UpdateType(UpdateType::S2)
|
||||
, new UpdateType(UpdateType::S4)
|
||||
, new UpdateType(UpdateType::S8)
|
||||
, new UpdateType(UpdateType::S16)
|
||||
, new UpdateType(UpdateType::S32)
|
||||
, new UpdateType(UpdateType::M1)
|
||||
, new UpdateType(UpdateType::M2)
|
||||
, new UpdateType(UpdateType::M4)
|
||||
, new UpdateType(UpdateType::M8)
|
||||
, new UpdateType(UpdateType::M16)
|
||||
, new UpdateType(UpdateType::M32));
|
||||
}
|
||||
|
||||
//Fires off an event each tick, containing a list of all updateTypes
|
||||
public function onRun($currentTick)
|
||||
{
|
||||
$updateTypes = array();
|
||||
|
||||
$timeSpent = round(microtime(true) * 1000) - $this->last;
|
||||
$this->last = round(microtime(true) * 1000);
|
||||
|
||||
@ -51,8 +54,11 @@ class Updater extends PluginTask
|
||||
{
|
||||
if ($timeSpent >= $updateType->time)
|
||||
{
|
||||
$this->plugin->getServer()->getPluginManager()->callEvent(new UpdateEvent($updateType->time));
|
||||
array_push($updateTypes, $updateType);
|
||||
}
|
||||
}
|
||||
|
||||
//Call Event
|
||||
$this->plugin->getServer()->getPluginManager()->callEvent(new UpdateEvent($currentTick, $updateTypes));
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace mineplex\plugin\events;
|
||||
|
||||
use pocketmine\event\Event;
|
||||
|
||||
class TickEvent extends Event
|
||||
{
|
||||
public static $handlerList = null;
|
||||
|
||||
public $tick;
|
||||
|
||||
public function __construct($currentTick)
|
||||
{
|
||||
$this->tick = $currentTick;
|
||||
}
|
||||
|
||||
public function getTick()
|
||||
{
|
||||
return $this->tick;
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace mineplex\plugin\tasks;
|
||||
|
||||
use mineplex\plugin\events\TickEvent;
|
||||
use mineplex\plugin\Main;
|
||||
use pocketmine\scheduler\PluginTask;
|
||||
|
||||
class TickTask extends PluginTask
|
||||
{
|
||||
public $plugin;
|
||||
|
||||
public function __construct(Main $host)
|
||||
{
|
||||
$this->plugin = $host;
|
||||
$this->owner = $host;
|
||||
}
|
||||
|
||||
public function onRun($currentTick)
|
||||
{
|
||||
$this->plugin->getServer()->getPluginManager()->callEvent(new TickEvent($currentTick));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user