This repository was archived by the owner on Feb 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
src/VectorNetworkProject/TheMix/game Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99namespace VectorNetworkProject \TheMix \game \corepvp ;
1010
11+ use VectorNetworkProject \TheMix \game \event \game \PhaseUpdateEvent ;
12+
1113class 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 /**
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments