Passed
Pull Request — master (#179)
by Vincent
10:13
created

configureHelp(Builder)   A

Complexity

Conditions 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 10
ccs 7
cts 7
cp 1
cc 1
crap 1
rs 9.95
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-2021 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.admin.player;
21
22
import fr.quatrevieux.araknemu.game.admin.AbstractMessageCommand;
23
import fr.quatrevieux.araknemu.game.admin.AdminPerformer;
24
import fr.quatrevieux.araknemu.game.admin.help.CommandHelp;
25
import fr.quatrevieux.araknemu.game.player.GamePlayer;
26
import fr.quatrevieux.araknemu.network.game.out.chat.ServerMessage;
27
28
/**
29
 * Command for send a server message to a player
30
 */
31
public final class Message extends AbstractMessageCommand {
32
    private final GamePlayer player;
33
34 1
    public Message(GamePlayer player) {
35 1
        this.player = player;
36 1
    }
37
38
    @Override
39
    protected void configureHelp(CommandHelp.Builder builder) {
40 1
        builder
41 1
            .description("Send a message to all connected players")
42 1
            .synopsis("@[player] msg [options] MESSAGE")
43
44 1
            .example("@John msg Hello World !", "Send message \"Hello World\" to John")
45 1
            .example("@John msg --color red My import message", "Send a message in red")
46 1
            .example("@John msg --color CD5C5C My message", "Send a message in custom color")
47 1
            .example("@John msg --color blue **Note:** go to link : [My link](https://my-site.com/my-page)", "Send a message using markdown")
48
        ;
49 1
    }
50
51
    @Override
52
    protected void send(AdminPerformer performer, ServerMessage packet) {
53 1
        performer.success("Sending message to {}", player.name());
54 1
        player.send(packet);
55 1
    }
56
}
57