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; |
10
|
|
|
|
11
|
|
|
use pocketmine\entity\Effect; |
12
|
|
|
use pocketmine\entity\EffectInstance; |
13
|
|
|
use pocketmine\level\Position; |
14
|
|
|
use pocketmine\Player; |
15
|
|
|
use pocketmine\Server; |
16
|
|
|
use VectorNetworkProject\TheMix\game\corepvp\blue\BlueSpawnManager; |
17
|
|
|
use VectorNetworkProject\TheMix\game\corepvp\blue\BlueTeamManager; |
18
|
|
|
use VectorNetworkProject\TheMix\game\corepvp\red\RedSpawnManager; |
19
|
|
|
use VectorNetworkProject\TheMix\game\corepvp\red\RedTeamManager; |
20
|
|
|
use VectorNetworkProject\TheMix\game\DefaultConfig; |
21
|
|
|
use VectorNetworkProject\TheMix\game\kit\BlueKit; |
22
|
|
|
use VectorNetworkProject\TheMix\game\kit\RedKit; |
23
|
|
|
use VectorNetworkProject\TheMix\task\ReSpawnCooldownTask; |
24
|
|
|
use VectorNetworkProject\TheMix\TheMix; |
25
|
|
|
|
26
|
|
|
class SpawnManager |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @param Player $player |
30
|
|
|
*/ |
31
|
|
|
public static function PlayerReSpawn(Player $player) |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
if (RedTeamManager::isJoined($player)) { |
34
|
|
|
self::ReSpawnCooldown($player, RedSpawnManager::getRandomPosition()); |
|
|
|
|
35
|
|
|
RedKit::sendItem($player); |
36
|
|
|
} elseif (BlueTeamManager::isJoined($player)) { |
37
|
|
|
self::ReSpawnCooldown($player, BlueSpawnManager::getRandomPosition()); |
|
|
|
|
38
|
|
|
BlueKit::sendItems($player); |
39
|
|
|
} else { |
40
|
|
|
self::ReSpawnCooldown($player, Server::getInstance()->getDefaultLevel()->getSpawnLocation()); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param Player $player |
46
|
|
|
* @param Position $position |
47
|
|
|
*/ |
48
|
|
|
private static function ReSpawnCooldown(Player $player, Position $position): void |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
$player->addTitle('§l§cYOU DIED', 'あなたは死んでしまった!5秒後行動可能になります。', 20, 100, 20); |
51
|
|
|
$player->teleport(new Position(0, 80, 0, Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName()))); |
52
|
|
|
$player->setGamemode(Player::SPECTATOR); |
53
|
|
|
$player->setHealth(20); |
54
|
|
|
$player->setMaxHealth(20); |
55
|
|
|
$player->setFood(20); |
56
|
|
|
$player->getInventory()->clearAll(); |
57
|
|
|
$player->getArmorInventory()->clearAll(); |
58
|
|
|
$player->removeAllEffects(); |
59
|
|
|
$player->addEffect(new EffectInstance(Effect::getEffect(Effect::NIGHT_VISION), 99999999 * 20, 11, false)); |
|
|
|
|
60
|
|
|
TheMix::getInstance()->getScheduler()->scheduleDelayedTask(new ReSpawnCooldownTask($player, $position), 100); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.