build(Builder)   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 11
dl 0
loc 13
ccs 9
cts 9
cp 1
crap 1
rs 9.85
c 0
b 0
f 0
1
/*
2
 * This file is part of Araknemu.
3
 *
4
 * Araknemu is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * Araknemu is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with Araknemu.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2017-2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.admin.player;
21
22
import fr.quatrevieux.araknemu.common.account.Permission;
23
import fr.quatrevieux.araknemu.game.admin.AbstractCommand;
24
import fr.quatrevieux.araknemu.game.admin.AdminPerformer;
25
import fr.quatrevieux.araknemu.game.player.GamePlayer;
26
27
/**
28
 * Info command for a player
29
 */
30
public final class Info extends AbstractCommand<Void> {
31
    private final GamePlayer player;
32
33 1
    public Info(GamePlayer player) {
34 1
        this.player = player;
35 1
    }
36
37
    @Override
38
    protected void build(Builder builder) {
39 1
        builder
40 1
            .help(
41 1
                formatter -> formatter
42 1
                    .description("Display information on the selected player")
43 1
                    .synopsis("[context] info")
44 1
                    .line("<i>Note: this command takes no arguments, the account is only resolved by the context</i>")
45
46 1
                    .example("@Alan info", "Display information about the player Alan")
47 1
                    .example("info", "Display self player information")
48
            )
49 1
            .requires(Permission.MANAGE_PLAYER)
50
        ;
51 1
    }
52
53
    @Override
54
    public String name() {
55 1
        return "info";
56
    }
57
58
    @Override
59
    public void execute(AdminPerformer performer, Void arguments) {
60 1
        performer.success("Player info : {}", player.name());
61 1
        performer.success("==============================");
62 1
        performer.info("ID:    {}", player.id());
63 1
        performer.info("Name:  {}", player.name());
64 1
        performer.info("Level: {}", player.properties().experience().level());
65 1
        performer.info("Race:  {}", player.race().name());
66 1
        performer.info("Sex:   {}", player.spriteInfo().gender());
67 1
        performer.info("GfxID: {}", player.spriteInfo().gfxId());
68 1
        performer.success("==============================");
69 1
    }
70
}
71