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

Commit 2d3a7ea

Browse files
committed
Merge branch 'release/0.0.7-BETA'
2 parents 09e138c + 55f8241 commit 2d3a7ea

File tree

12 files changed

+185
-82
lines changed

12 files changed

+185
-82
lines changed

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ softdepend:
66

77
description: "Original game of VectorNetwork"
88
website: "https://vector-network.tk"
9-
version: 0.0.6-BETA
9+
version: 0.0.7-BETA
1010
authors:
1111
- InkoHX
1212
- MazaiCrafty

resources/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 7
2+
dev-mode: true
3+
stage-world-name: stage
4+
event-time: 30
5+
timezone: Asia/Tokyo
6+
red:
7+
spawn1:
8+
x: 1
9+
y: 1
10+
z: 1
11+
spawn2:
12+
x: 1
13+
y: 1
14+
z: 1
15+
core:
16+
x: 1
17+
y: 1
18+
z: 1
19+
20+
blue:
21+
spawn1:
22+
x: 1
23+
y: 1
24+
z: 1
25+
spawn2:
26+
x: 1
27+
y: 1
28+
z: 1
29+
core:
30+
x: 1
31+
y: 1
32+
z: 1

src/VectorNetworkProject/TheMix/TheMix.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,22 @@
3636

3737
class TheMix extends PluginBase
3838
{
39+
public const VERSION = 7;
40+
3941
/* @var TheMix $instance */
4042
private static $instance = null;
4143

42-
public const PLUGIN_CONFIG_VERSION = 1;
43-
4444
public function onLoad()
4545
{
46+
$this->getLogger()->notice('Loading System...');
4647
self::$instance = $this;
47-
DefaultConfig::init();
48+
$this->saveDefaultConfig();
49+
DefaultConfig::getVersion() === self::VERSION
50+
? $this->getLogger()->info('Loaded Config')
51+
: $this->getLogger()->alert('Please update config.yml');
4852
LevelAPI::init();
4953
GoldAPI::init();
50-
date_default_timezone_set('Asia/Tokyo');
51-
$this->getLogger()->notice('Loading System...');
54+
date_default_timezone_set(DefaultConfig::getTimezone());
5255
}
5356

5457
public function onEnable()

src/VectorNetworkProject/TheMix/event/block/TheBlockBreakEvent.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ public function event(BlockBreakEvent $event)
4040
$event->setCancelled();
4141
}
4242
if (!DefaultConfig::isDev()) {
43-
if (RedTeamManager::getListCount() < 1 || BlueTeamManager::getListCount() < 1) {
44-
$player->sendMessage('プレイヤーが足りないのでコアを破壊する事が出来ません。');
45-
$event->setCancelled();
46-
47-
return;
48-
}
4943
if (RedCoreManager::isCore($block)) {
5044
$event->setCancelled();
5145
if (RedTeamManager::isJoined($player)) {
5246
return;
5347
}
48+
if (RedTeamManager::getListCount() < 1 || BlueTeamManager::getListCount() < 1) {
49+
$player->sendMessage('プレイヤーが足りないのでコアを破壊する事が出来ません。');
50+
$event->setCancelled();
51+
52+
return;
53+
}
5454
RedCoreManager::reduceHP(1, $player);
5555
GoldAPI::addGold($player, 15);
5656
LevelAPI::Auto($player, 10);
@@ -65,6 +65,12 @@ public function event(BlockBreakEvent $event)
6565
if (BlueTeamManager::isJoined($player)) {
6666
return;
6767
}
68+
if (RedTeamManager::getListCount() < 1 || BlueTeamManager::getListCount() < 1) {
69+
$player->sendMessage('プレイヤーが足りないのでコアを破壊する事が出来ません。');
70+
$event->setCancelled();
71+
72+
return;
73+
}
6874
BlueCoreManager::reduceHP(1, $player);
6975
GoldAPI::addGold($player, 15);
7076
LevelAPI::Auto($player, 10);

src/VectorNetworkProject/TheMix/event/entity/TheEntityDamageEvent.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function event(EntityDamageEvent $event)
2929
$entity = $event->getEntity();
3030
$entity->extinguish();
3131
if (TheEndGameEvent::isFinish()) {
32+
$event->setCancelled();
33+
3234
return;
3335
}
3436
if (!$entity instanceof Player) {
@@ -38,10 +40,14 @@ public function event(EntityDamageEvent $event)
3840
return;
3941
}
4042
if ($event->getCause() === EntityDamageEvent::CAUSE_FALL) {
43+
$event->setCancelled();
44+
4145
return;
4246
}
4347
if ($entity->getLevel()->getName() === Server::getInstance()->getDefaultLevel()->getName()) {
4448
$event->setCancelled();
49+
50+
return;
4551
}
4652
if ($event instanceof EntityDamageByEntityEvent) {
4753
$event->setCancelled();

src/VectorNetworkProject/TheMix/game/DefaultConfig.php

Lines changed: 45 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,98 +8,81 @@
88

99
namespace VectorNetworkProject\TheMix\game;
1010

11-
use VectorNetworkProject\TheMix\provider\YAML;
1211
use VectorNetworkProject\TheMix\TheMix;
1312

1413
class DefaultConfig
1514
{
16-
public const STAGE_NAME = 'stage-world-name';
15+
/** @var string */
16+
const VERSION = 'version';
1717

18-
public const DEVELOP_MODE = 'develop-mode';
18+
/** @var string */
19+
const STAGE_NAME = 'stage-world-name';
1920

20-
public const EVENT_TIME = 'event-time';
21+
/** @var string */
22+
const DEVELOP_MODE = 'dev-mode';
2123

22-
public const RED = 'red';
24+
/** @var string */
25+
const EVENT_TIME = 'event-time';
2326

24-
public const BLUE = 'blue';
27+
/** @var string */
28+
const TIMEZONE = 'timezone';
2529

26-
public static function init()
30+
/** @var string */
31+
const RED = 'red';
32+
33+
/** @var string */
34+
const BLUE = 'blue';
35+
36+
/**
37+
* @return int
38+
*/
39+
public static function getVersion(): int
2740
{
28-
$db = new YAML();
29-
$db->init([
30-
'version' => TheMix::PLUGIN_CONFIG_VERSION,
31-
'develop-mode' => true,
32-
'stage-world-name' => 'stage',
33-
'event-time' => 30,
34-
'red' => [
35-
'spawn1' => [
36-
'x' => -131,
37-
'y' => 81,
38-
'z' => 25,
39-
],
40-
'spawn2' => [
41-
'x' => -131,
42-
'y' => 81,
43-
'z' => -25,
44-
],
45-
'core' => [
46-
'x' => -152,
47-
'y' => 85,
48-
'z' => 0,
49-
],
50-
],
51-
'blue' => [
52-
'spawn1' => [
53-
'x' => 131,
54-
'y' => 81,
55-
'z' => -25,
56-
],
57-
'spawn2' => [
58-
'x' => -131,
59-
'y' => 81,
60-
'z' => 25,
61-
],
62-
'core' => [
63-
'x' => 152,
64-
'y' => 85,
65-
'z' => 0,
66-
],
67-
],
68-
]);
41+
return TheMix::getInstance()->getConfig()->get(self::VERSION);
6942
}
7043

44+
/**
45+
* @return string
46+
*/
7147
public static function getStageLevelName(): string
7248
{
73-
$db = new YAML();
74-
75-
return $db->get(self::STAGE_NAME);
49+
return TheMix::getInstance()->getConfig()->get(self::STAGE_NAME);
7650
}
7751

52+
/**
53+
* @return bool
54+
*/
7855
public static function isDev(): bool
7956
{
80-
$db = new YAML();
81-
82-
return $db->get(self::DEVELOP_MODE);
57+
return TheMix::getInstance()->getConfig()->get(self::DEVELOP_MODE);
8358
}
8459

60+
/**
61+
* @return int
62+
*/
8563
public static function getEventTime(): int
8664
{
87-
$db = new YAML();
65+
return TheMix::getInstance()->getConfig()->get(self::EVENT_TIME);
66+
}
8867

89-
return $db->get(self::EVENT_TIME);
68+
public static function getTimezone(): string
69+
{
70+
return TheMix::getInstance()->getConfig()->get(self::TIMEZONE);
9071
}
9172

73+
/**
74+
* @return array
75+
*/
9276
public static function getRedConfig(): array
9377
{
94-
$db = new YAML();
95-
96-
return $db->get(self::RED);
78+
return TheMix::getInstance()->getConfig()->get(self::RED);
9779
}
9880

81+
/**
82+
* @return array
83+
*/
9984
public static function getBlueConfig(): array
10085
{
101-
$db = new YAML();
102-
103-
return $db->get(self::BLUE);
86+
return TheMix::getInstance()->getConfig()->get(self::BLUE);
10487
}
10588
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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\corepvp\blue;
10+
11+
use VectorNetworkProject\TheMix\game\DefaultConfig;
12+
13+
class BlueConfig extends DefaultConfig
14+
{
15+
/**
16+
* @return array
17+
*/
18+
public static function getSpawn1(): array
19+
{
20+
return self::getBlueConfig()['spawn1'];
21+
}
22+
23+
/**
24+
* @return array
25+
*/
26+
public static function getSpawn2(): array
27+
{
28+
return self::getBlueConfig()['spawn2'];
29+
}
30+
31+
/**
32+
* @return array
33+
*/
34+
public static function getCore(): array
35+
{
36+
return self::getBlueConfig()['core'];
37+
}
38+
}

src/VectorNetworkProject/TheMix/game/corepvp/blue/BlueCoreManager.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public static function reduceHP(int $hp, Player $player): void
6767
*/
6868
public static function isCore(Block $block): bool
6969
{
70-
$config = DefaultConfig::getBlueConfig();
71-
$core = $config['core'];
70+
$core = BlueConfig::getCore();
7271
if ($block->getLevel()->getName() !== DefaultConfig::getStageLevelName()) {
7372
return false;
7473
}

src/VectorNetworkProject/TheMix/game/corepvp/blue/BlueSpawnManager.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ public static function getRandomPosition(): ?Position
2222
{
2323
switch (mt_rand(1, 2)) {
2424
case 1:
25-
return new Position(131, 80, 25, Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()));
25+
$spawn = BlueConfig::getSpawn1();
26+
27+
return new Position($spawn['x'], $spawn['y'], $spawn['z'], Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()));
2628
break;
2729
case 2:
28-
return new Position(131, 80, -25, Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()));
30+
$spawn = BlueConfig::getSpawn2();
31+
32+
return new Position($spawn['x'], $spawn['y'], $spawn['z'], Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()));
2933
break;
3034
default: return null;
3135
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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\corepvp\red;
10+
11+
use VectorNetworkProject\TheMix\game\DefaultConfig;
12+
13+
class RedConfig extends DefaultConfig
14+
{
15+
public static function getSpawn1(): array
16+
{
17+
return self::getRedConfig()['spawn1'];
18+
}
19+
20+
public static function getSpawn2(): array
21+
{
22+
return self::getRedConfig()['spawn2'];
23+
}
24+
25+
public static function getCore(): array
26+
{
27+
return self::getRedConfig()['core'];
28+
}
29+
}

0 commit comments

Comments
 (0)