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 +66
-4
lines changed
src/VectorNetworkProject/TheMix Expand file tree Collapse file tree 2 files changed +66
-4
lines changed 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
+ /**
10
+ * Created by PhpStorm.
11
+ * User: InkoHX
12
+ * Date: 2018/12/19
13
+ * Time: 4:54
14
+ */
15
+
16
+ namespace VectorNetworkProject \TheMix \game \event \game ;
17
+
18
+
19
+ use pocketmine \event \Cancellable ;
20
+ use pocketmine \event \Event ;
21
+
22
+ class PhaseTimeUpdateEvent extends Event implements Cancellable
23
+ {
24
+ /** @var int $time */
25
+ private $ time ;
26
+
27
+ /**
28
+ * PhaseTimeUpdateEvent constructor.
29
+ *
30
+ * @param int $time
31
+ */
32
+ public function __construct (int $ time )
33
+ {
34
+ $ this ->time = $ time ;
35
+ }
36
+
37
+ /**
38
+ * @return int
39
+ */
40
+ public function getTime (): int
41
+ {
42
+ return $ this ->time ;
43
+ }
44
+ }
Original file line number Diff line number Diff line change 9
9
namespace VectorNetworkProject \TheMix \task ;
10
10
11
11
use pocketmine \scheduler \Task ;
12
+ use VectorNetworkProject \TheMix \game \event \game \PhaseTimeUpdateEvent ;
12
13
13
14
class PhaseTask extends Task
14
15
{
@@ -25,16 +26,33 @@ public function __construct(int $time = 600)
25
26
$ this ->time = $ time ;
26
27
}
27
28
29
+ /**
30
+ * @param int $currentTick
31
+ *
32
+ * @throws \ReflectionException
33
+ */
28
34
public function onRun (int $ currentTick )
29
35
{
30
- // TODO: Implement onRun() method.
36
+ $ event = new PhaseTimeUpdateEvent ($ this ->getTime () - 1 );
37
+ $ event ->call ();
38
+ if (!$ event ->isCancelled ()) {
39
+ $ this ->setTime ($ this ->getTime () - 1 );
40
+ }
41
+ }
42
+
43
+ /**
44
+ * @return int
45
+ */
46
+ public function getTime (): int
47
+ {
48
+ return $ this ->time ;
31
49
}
32
50
33
51
/**
34
- * @return string
52
+ * @param int $time
35
53
*/
36
- public function getTime ( ): string
54
+ public function setTime ( int $ time ): void
37
55
{
38
- return gmdate ( ' i:s ' , $ this ->time ) ;
56
+ $ this ->time = $ time ;
39
57
}
40
58
}
You can’t perform that action at this time.
0 commit comments