This repository was archived by the owner on Feb 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +104
-1
lines changed
src/VectorNetworkProject/TheMix Expand file tree Collapse file tree 3 files changed +104
-1
lines changed Original file line number Diff line number Diff line change 15
15
use VectorNetworkProject \TheMix \command \defaults \PingCommand ;
16
16
use VectorNetworkProject \TheMix \command \defaults \TpsCommand ;
17
17
use VectorNetworkProject \TheMix \command \Permissions ;
18
+ use VectorNetworkProject \TheMix \event \TheBlockBreakEvent ;
18
19
use VectorNetworkProject \TheMix \event \ThePlayerJoinEvent ;
19
20
use VectorNetworkProject \TheMix \event \ThePlayerLoginEvent ;
20
21
use VectorNetworkProject \TheMix \event \ThePlayerQuitEvent ;
@@ -88,5 +89,6 @@ private function registerEvents(): void
88
89
$ plm ->registerEvents (new ThePlayerLoginEvent (), $ this );
89
90
$ plm ->registerEvents (new ThePlayerJoinEvent (), $ this );
90
91
$ plm ->registerEvents (new ThePlayerQuitEvent (), $ this );
92
+ $ plm ->registerEvents (new TheBlockBreakEvent (), $ this );
91
93
}
92
94
}
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 \event ;
10
+
11
+ use pocketmine \event \block \BlockBreakEvent ;
12
+ use pocketmine \event \Listener ;
13
+ use pocketmine \math \Vector2 ;
14
+ use VectorNetworkProject \TheMix \game \DefaultConfig ;
15
+
16
+ class TheBlockBreakEvent implements Listener
17
+ {
18
+ public function event (BlockBreakEvent $ event )
19
+ {
20
+ $ block = $ event ->getBlock ();
21
+ $ red = DefaultConfig::getRedSafe ();
22
+ $ blue = DefaultConfig::getBlueSafe ();
23
+ $ redsafe = new Vector2 ($ red ['x ' ], $ blue ['z ' ]);
24
+ $ bluesafe = new Vector2 ($ blue ['x ' ], $ blue ['z ' ]);
25
+ if ($ redsafe ->distance ($ block ->x , $ block ->z ) <= $ red ['diameter ' ] || $ bluesafe ->distance ($ block ->x , $ block ->z ) <= $ blue ['diameter ' ]) {
26
+ if (!DefaultConfig::isDev ()) {
27
+ $ event ->setCancelled ();
28
+ }
29
+ }
30
+ }
31
+ }
Original file line number Diff line number Diff line change @@ -17,12 +17,56 @@ class DefaultConfig
17
17
{
18
18
public const STAGE_NAME = 'stage-world-name ' ;
19
19
20
+ public const DEVELOP_MODE = 'develop-mode ' ;
21
+
22
+ public const EVENT_TIME = 'event-time ' ;
23
+
24
+ public const RED = 'red ' ;
25
+
26
+ public const BLUE = 'blue ' ;
27
+
20
28
public static function init ()
21
29
{
22
30
$ db = new YAML ();
23
31
$ db ->init ([
24
32
'version ' => TheMix::PLUGIN_CONFIG_VERSION ,
25
- 'stage-world-name ' => 'stage '
33
+ 'develop-mode ' => true ,
34
+ 'stage-world-name ' => 'stage ' ,
35
+ 'event-time ' => 30 ,
36
+ 'red ' => [
37
+ 'safe ' => [
38
+ 'x ' => 353 ,
39
+ 'z ' => 203 ,
40
+ 'diameter ' => 30 ,
41
+ ],
42
+ 'spawn ' => [
43
+ 'x ' => 245 ,
44
+ 'y ' => 424 ,
45
+ 'z ' => 452 ,
46
+ ],
47
+ 'core ' => [
48
+ 'x ' => 215 ,
49
+ 'y ' => 445 ,
50
+ 'z ' => 455 ,
51
+ ]
52
+ ],
53
+ 'blue ' => [
54
+ 'safe ' => [
55
+ 'x ' => 157 ,
56
+ 'z ' => 203 ,
57
+ 'diameter ' => 30 ,
58
+ ],
59
+ 'spawn ' => [
60
+ 'x ' => 245 ,
61
+ 'y ' => 424 ,
62
+ 'z ' => 452 ,
63
+ ],
64
+ 'core ' => [
65
+ 'x ' => 215 ,
66
+ 'y ' => 445 ,
67
+ 'z ' => 455 ,
68
+ ]
69
+ ]
26
70
]);
27
71
}
28
72
@@ -40,4 +84,30 @@ public static function getStageWorld(): ?Level
40
84
$ db = new YAML ();
41
85
return Server::getInstance ()->getLevelByName ($ db ->get (self ::STAGE_NAME ));
42
86
}
87
+
88
+ public static function isDev (): bool
89
+ {
90
+ $ db = new YAML ();
91
+ return $ db ->get (self ::DEVELOP_MODE );
92
+ }
93
+
94
+ public static function getEventTime (): int
95
+ {
96
+ $ db = new YAML ();
97
+ return $ db ->get (self ::EVENT_TIME );
98
+ }
99
+
100
+ public static function getRedSafe (): array
101
+ {
102
+ $ db = new YAML ();
103
+ $ safe = $ db ->get (self ::RED );
104
+ return $ safe ['safe ' ];
105
+ }
106
+
107
+ public static function getBlueSafe (): array
108
+ {
109
+ $ db = new YAML ();
110
+ $ safe = $ db ->get (self ::BLUE );
111
+ return $ safe ['safe ' ];
112
+ }
43
113
}
You can’t perform that action at this time.
0 commit comments