This repository was archived by the owner on Feb 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed
src/VectorNetworkProject/TheMix/game Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 8
8
9
9
namespace VectorNetworkProject \TheMix \game \corepvp ;
10
10
11
+ use VectorNetworkProject \TheMix \game \event \game \PhaseUpdateEvent ;
12
+
11
13
class PhaseManager
12
14
{
13
15
/** @var int */
14
- public const MAX_PHASE = 5 ;
16
+ public const MAX_PHASE = 5 ;
17
+
15
18
/** @var int $phase */
16
19
private static $ phase = 1 ;
17
20
21
+ /**
22
+ * @throws \ReflectionException
23
+ */
18
24
public static function addPhase (): void
19
25
{
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
+ }
22
31
}
23
32
24
33
/**
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