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

Commit 475ad76

Browse files
committed
Update
1 parent 106c1d5 commit 475ad76

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

src/VectorNetworkProject/TheMix/TheMix.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use VectorNetworkProject\TheMix\command\defaults\PingCommand;
1616
use VectorNetworkProject\TheMix\command\defaults\TpsCommand;
1717
use VectorNetworkProject\TheMix\command\Permissions;
18+
use VectorNetworkProject\TheMix\event\TheBlockBreakEvent;
1819
use VectorNetworkProject\TheMix\event\ThePlayerJoinEvent;
1920
use VectorNetworkProject\TheMix\event\ThePlayerLoginEvent;
2021
use VectorNetworkProject\TheMix\event\ThePlayerQuitEvent;
@@ -88,5 +89,6 @@ private function registerEvents(): void
8889
$plm->registerEvents(new ThePlayerLoginEvent(), $this);
8990
$plm->registerEvents(new ThePlayerJoinEvent(), $this);
9091
$plm->registerEvents(new ThePlayerQuitEvent(), $this);
92+
$plm->registerEvents(new TheBlockBreakEvent(), $this);
9193
}
9294
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

src/VectorNetworkProject/TheMix/game/DefaultConfig.php

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,56 @@ class DefaultConfig
1717
{
1818
public const STAGE_NAME = 'stage-world-name';
1919

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+
2028
public static function init()
2129
{
2230
$db = new YAML();
2331
$db->init([
2432
'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+
]
2670
]);
2771
}
2872

@@ -40,4 +84,30 @@ public static function getStageWorld(): ?Level
4084
$db = new YAML();
4185
return Server::getInstance()->getLevelByName($db->get(self::STAGE_NAME));
4286
}
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+
}
43113
}

0 commit comments

Comments
 (0)