PingCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A execute() 0 11 2
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\command\defaults;
10
11
use pocketmine\command\CommandSender;
12
use pocketmine\command\PluginCommand;
13
use pocketmine\Player;
14
use pocketmine\plugin\Plugin;
15
use pocketmine\utils\TextFormat;
16
use VectorNetworkProject\TheMix\command\Permissions;
17
18
class PingCommand extends PluginCommand
19
{
20
    /**
21
     * PingCommand constructor.
22
     *
23
     * @param Plugin $owner
24
     */
25
    public function __construct(Plugin $owner)
26
    {
27
        parent::__construct('ping', $owner);
28
        $this->setDescription('応答速度を計測します。');
29
        $this->setPermission(Permissions::USER.'ping');
30
    }
31
32
    /**
33
     * @param CommandSender $sender
34
     * @param string        $commandLabel
35
     * @param array         $args
36
     *
37
     * @return mixed
38
     */
39
    public function execute(CommandSender $sender, string $commandLabel, array $args)
40
    {
41
        if (!$sender instanceof Player) {
42
            $sender->sendMessage(TextFormat::RED.'このコマンドはプレイヤーのみ実行可能です。');
43
44
            return true;
45
        }
46
        $sender->sendMessage(TextFormat::RED.$sender->getPing().TextFormat::YELLOW.'ms');
47
48
        return true;
49
    }
50
}
51