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; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.core.config.ConfigurationModule; |
23
|
|
|
import fr.quatrevieux.araknemu.core.config.Pool; |
24
|
|
|
import fr.quatrevieux.araknemu.core.config.PoolUtils; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Configuration for admin system |
28
|
|
|
*/ |
29
|
1 |
|
public final class AdminConfiguration implements ConfigurationModule { |
30
|
|
|
private PoolUtils pool; |
31
|
|
|
|
32
|
|
|
@Override |
33
|
|
|
public void setPool(Pool pool) { |
34
|
1 |
|
this.pool = new PoolUtils(pool); |
35
|
1 |
|
} |
36
|
|
|
|
37
|
|
|
@Override |
38
|
|
|
public String name() { |
39
|
1 |
|
return "admin"; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get a command context configuration |
44
|
|
|
* |
45
|
|
|
* @param name The context name |
46
|
|
|
*/ |
47
|
|
|
public ContextConfiguration context(String name) { |
48
|
1 |
|
return new ContextConfiguration(name); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
class ContextConfiguration { |
52
|
|
|
private final String name; |
53
|
|
|
|
54
|
1 |
|
public ContextConfiguration(String name) { |
55
|
1 |
|
this.name = name; |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Are scripts enabled ? |
60
|
|
|
* If set to false, the scripts are not loaded |
61
|
|
|
* Default value: true |
62
|
|
|
*/ |
63
|
|
|
public boolean enableScripts() { |
64
|
1 |
|
return pool.bool(name + ".scripts.enable", true); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get the commands scripts path |
69
|
|
|
* Should be a directory path |
70
|
|
|
* Default: "scripts/commands/[context]" |
71
|
|
|
*/ |
72
|
|
|
public String scriptsPath() { |
73
|
1 |
|
return pool.string(name + ".scripts.path", "scripts/commands/" + name); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|