|
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
|
|
|
import org.kohsuke.args4j.Argument; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Add experience to player |
|
30
|
|
|
*/ |
|
31
|
|
|
public final class AddXp extends AbstractCommand<AddXp.Arguments> { |
|
32
|
|
|
private final GamePlayer player; |
|
33
|
|
|
|
|
34
|
1 |
|
public AddXp(GamePlayer player) { |
|
35
|
1 |
|
this.player = player; |
|
36
|
1 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
@Override |
|
39
|
|
|
protected void build(Builder builder) { |
|
40
|
1 |
|
builder |
|
41
|
1 |
|
.description("Add experience to player") |
|
42
|
1 |
|
.help( |
|
43
|
1 |
|
formatter -> formatter |
|
44
|
1 |
|
.synopsis("addxp [quantity]") |
|
45
|
1 |
|
.options("quantity", "The experience quantity to add. Must be an unsigned number.") |
|
46
|
1 |
|
.example("${player:John} addxp 1000000", "Add 1 million xp to John") |
|
47
|
|
|
) |
|
48
|
1 |
|
.requires(Permission.MANAGE_PLAYER) |
|
49
|
|
|
; |
|
50
|
1 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
@Override |
|
53
|
|
|
public String name() { |
|
54
|
1 |
|
return "addxp"; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
@Override |
|
58
|
|
|
public void execute(AdminPerformer performer, Arguments arguments) { |
|
59
|
1 |
|
player.properties().experience().add(arguments.quantity); |
|
60
|
|
|
|
|
61
|
1 |
|
performer.success("Add {} xp to {} (level = {})", arguments.quantity, player.name(), player.properties().experience().level()); |
|
62
|
1 |
|
} |
|
63
|
|
|
|
|
64
|
|
|
@Override |
|
65
|
|
|
public Arguments createArguments() { |
|
66
|
1 |
|
return new Arguments(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
1 |
|
public static final class Arguments { |
|
70
|
|
|
@Argument(required = true, metaVar = "quantity", usage = "The experience quantity to add. Must be an unsigned number.") |
|
71
|
|
|
private long quantity; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|