Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Commit 9c04f90

Browse files
committed
Update PhaseUpdateEvent
1 parent 4bdf8dc commit 9c04f90

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

src/VectorNetworkProject/TheMix/game/corepvp/PhaseManager.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@
88

99
namespace VectorNetworkProject\TheMix\game\corepvp;
1010

11+
use VectorNetworkProject\TheMix\game\event\game\PhaseUpdateEvent;
12+
1113
class PhaseManager
1214
{
1315
/** @var int */
14-
public const MAX_PHASE = 5;
16+
public const MAX_PHASE = 5;
17+
1518
/** @var int $phase */
1619
private static $phase = 1;
1720

21+
/**
22+
* @throws \ReflectionException
23+
*/
1824
public static function addPhase(): void
1925
{
20-
if (self::$phase <= self::MAX_PHASE) return;
21-
self::$phase++;
26+
$event = new PhaseUpdateEvent(self::getPhase() + 1);
27+
$event->call();
28+
if (!$event->isCancelled()) {
29+
self::$phase++;
30+
}
2231
}
2332

2433
/**
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2018 VectorNetworkProject. All rights reserved. MIT license.
4+
*
5+
* GitHub: https://github.com/VectorNetworkProject/TheMix
6+
* Website: https://www.vector-network.tk
7+
*/
8+
9+
namespace VectorNetworkProject\TheMix\game\event\game;
10+
11+
12+
use pocketmine\event\Cancellable;
13+
use pocketmine\event\Event;
14+
15+
class PhaseUpdateEvent extends Event implements Cancellable
16+
{
17+
/** @var int $phase */
18+
private $phase;
19+
20+
public function __construct(int $phase)
21+
{
22+
$this->phase = $phase;
23+
}
24+
25+
/**
26+
* @return int
27+
*/
28+
public function getPhase(): int
29+
{
30+
return $this->phase;
31+
}
32+
}

0 commit comments

Comments
 (0)