|
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; |
|
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
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
26
|
|
|
|
|
27
|
|
|
import java.time.Duration; |
|
28
|
|
|
import java.util.Arrays; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Configuration class for game server |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public final class GameConfiguration implements ConfigurationModule { |
|
34
|
|
|
private PoolUtils pool; |
|
35
|
|
|
|
|
36
|
|
|
@Override |
|
37
|
|
|
public void setPool(Pool pool) { |
|
38
|
1 |
|
this.pool = new PoolUtils(pool); |
|
39
|
1 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
@Override |
|
42
|
|
|
public String name() { |
|
43
|
1 |
|
return "game"; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get the server ID. By default 1 |
|
48
|
|
|
*/ |
|
49
|
|
|
public int id() { |
|
50
|
1 |
|
return pool.integer("id", 1); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get the server port |
|
55
|
|
|
*/ |
|
56
|
|
|
public int port() { |
|
57
|
1 |
|
return pool.integer("server.port", 5555); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get the server IP address |
|
62
|
|
|
*/ |
|
63
|
|
|
public String ip() { |
|
64
|
1 |
|
return pool.string("server.ip", "127.0.0.1"); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* The maximum inactivity time, as duration |
|
69
|
|
|
* By default, 15min ("PT15M" or "15m") |
|
70
|
|
|
*/ |
|
71
|
|
|
public Duration inactivityTime() { |
|
72
|
1 |
|
return pool.duration("inactivityTime", Duration.ofMinutes(15)); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Maximum number of received packets per seconds per clients |
|
77
|
|
|
* When the limit is reached, the client session is closed |
|
78
|
|
|
*/ |
|
79
|
|
|
public int packetRateLimit() { |
|
80
|
1 |
|
return pool.integer("packetRateLimit", 100); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get the shutdown reminder delays, in minutes |
|
85
|
|
|
* The values are integer separated by a comma "," |
|
86
|
|
|
* Default value : "1,10,30,60,120" |
|
87
|
|
|
*/ |
|
88
|
|
|
public long[] shutdownReminderMinutes() { |
|
89
|
1 |
|
return Arrays.stream(StringUtils.split(pool.string("shutdownReminderMinutes", "1,10,30,60,120"), ",")) |
|
90
|
1 |
|
.map(String::trim) |
|
91
|
1 |
|
.mapToLong(Long::parseLong) |
|
92
|
1 |
|
.sorted() |
|
93
|
1 |
|
.toArray() |
|
94
|
|
|
; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Get the refresh interval for the ban ip table |
|
99
|
|
|
* Default: 10 minutes (10m) |
|
100
|
|
|
*/ |
|
101
|
|
|
public Duration banIpRefresh() { |
|
102
|
1 |
|
return pool.duration("banip.refresh", Duration.ofMinutes(10)); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Get player configuration |
|
107
|
|
|
*/ |
|
108
|
|
|
public PlayerConfiguration player() { |
|
109
|
1 |
|
return new PlayerConfiguration(); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Get the chat configuration |
|
114
|
|
|
*/ |
|
115
|
|
|
public ChatConfiguration chat() { |
|
116
|
1 |
|
return new ChatConfiguration(); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Get the configuration for the game activity |
|
121
|
|
|
*/ |
|
122
|
|
|
public ActivityConfiguration activity() { |
|
123
|
1 |
|
return new ActivityConfiguration(); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Get the configuration for the Dofus economy |
|
128
|
|
|
*/ |
|
129
|
|
|
public EconomyConfiguration economy() { |
|
130
|
1 |
|
return new EconomyConfiguration(); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Get the configuration for the fight system |
|
135
|
|
|
*/ |
|
136
|
|
|
public FightConfiguration fight() { |
|
137
|
1 |
|
return new FightConfiguration(); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
1 |
|
public final class PlayerConfiguration { |
|
141
|
|
|
/** |
|
142
|
|
|
* The player name regex |
|
143
|
|
|
*/ |
|
144
|
|
|
public String nameRegex() { |
|
145
|
1 |
|
return pool.string("player.name.regex", "[A-Z][a-z]+(-[A-Z]?[a-z]+)?"); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Minimal length of player name |
|
150
|
|
|
*/ |
|
151
|
|
|
public int nameMinLength() { |
|
152
|
1 |
|
return pool.integer("player.name.minLength", 2); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Maximal length of player name |
|
157
|
|
|
*/ |
|
158
|
|
|
public int nameMaxLength() { |
|
159
|
1 |
|
return pool.integer("player.name.maxLength", 20); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Maximal length for generated name |
|
164
|
|
|
*/ |
|
165
|
|
|
public int maxNameGeneratedLength() { |
|
166
|
1 |
|
return pool.integer("player.name.generated.maxLength", 8); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* Minimal length for generated name |
|
171
|
|
|
*/ |
|
172
|
|
|
public int minNameGeneratedLength() { |
|
173
|
1 |
|
return pool.integer("player.name.generated.minLength", 4); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Maximum number for characters per account per server |
|
178
|
|
|
*/ |
|
179
|
|
|
public int maxPerAccount() { |
|
180
|
1 |
|
return pool.integer("player.max", 5); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Minimum level which needs secret answer for delete the character |
|
185
|
|
|
* By default, value is set to 20 |
|
186
|
|
|
* |
|
187
|
|
|
* To change this value, you should also change in lang.swf, the value `C.SECRET_ANSWER_SINCE_LEVEL` |
|
188
|
|
|
*/ |
|
189
|
|
|
public int deleteAnswerLevel() { |
|
190
|
1 |
|
return pool.integer("player.deleteAnswerLevel", 20); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Get the level up spell points |
|
195
|
|
|
* By default, value is set to 1 |
|
196
|
|
|
*/ |
|
197
|
|
|
public int spellBoostPointsOnLevelUp() { |
|
198
|
1 |
|
return pool.integer("player.level.spellPoints", 1); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Get the level up characteristic points |
|
203
|
|
|
* By default, value is set to 5 |
|
204
|
|
|
*/ |
|
205
|
|
|
public int characteristicPointsOnLevelUp() { |
|
206
|
1 |
|
return pool.integer("player.level.characteristicPoints", 5); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* The life regeneration rate. |
|
211
|
|
|
* This is the number of milliseconds required to regenerate 1 life point. Set to 0 to disable. |
|
212
|
|
|
* By default 1000 (1 LP / sec) |
|
213
|
|
|
*/ |
|
214
|
|
|
public int baseLifeRegeneration() { |
|
215
|
1 |
|
return pool.integer("player.lifeRegeneration.base", 1000); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Restore life points when player reach a new level |
|
220
|
|
|
* By default true |
|
221
|
|
|
*/ |
|
222
|
|
|
public boolean restoreLifeOnLevelUp() { |
|
223
|
1 |
|
return pool.bool("player.restoreLifeOnLevelUp", true); |
|
224
|
|
|
} |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
1 |
|
public final class ChatConfiguration { |
|
228
|
|
|
/** |
|
229
|
|
|
* Get the waiting time in seconds for global channel flood |
|
230
|
|
|
* |
|
231
|
|
|
* Set to -1 for deactivate |
|
232
|
|
|
*/ |
|
233
|
|
|
public int floodTime() { |
|
234
|
1 |
|
return pool.integer("chat.flood.time", 30); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* Get list of default channels to add on character creation |
|
239
|
|
|
*/ |
|
240
|
|
|
public String defaultChannels() { |
|
241
|
1 |
|
return pool.string("chat.channels.default", "*#%!pi$:?"); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* Channels to add on admin characters |
|
246
|
|
|
*/ |
|
247
|
|
|
public String adminChannels() { |
|
248
|
1 |
|
return pool.string("chat.channels.admin", "@"); |
|
249
|
|
|
} |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
1 |
|
public final class ActivityConfiguration { |
|
253
|
|
|
/** |
|
254
|
|
|
* Number of threads to use for the activity service |
|
255
|
|
|
*/ |
|
256
|
|
|
public int threadsCount() { |
|
257
|
1 |
|
return pool.integer("activity.threadsCount", 1); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* Number of seconds for move monster groups |
|
262
|
|
|
* By default 120s = 2min |
|
263
|
|
|
*/ |
|
264
|
|
|
public int monsterMoveInterval() { |
|
265
|
1 |
|
return pool.integer("activity.monsters.moveInterval", 120); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* Percent of chance that a monster group on a map move |
|
270
|
|
|
* The value must be an integer value between ]0, 100] |
|
271
|
|
|
* By default 25% |
|
272
|
|
|
*/ |
|
273
|
|
|
public int monsterMovePercent() { |
|
274
|
1 |
|
return pool.integer("activity.monsters.movePercent", 25); |
|
275
|
|
|
} |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
1 |
|
public final class EconomyConfiguration { |
|
279
|
|
|
/** |
|
280
|
|
|
* Get the selling item to an NPC price multiplier |
|
281
|
|
|
* By default 0.1 |
|
282
|
|
|
* |
|
283
|
|
|
* Should corresponds to "C.SELL_PRICE_MULTIPLICATOR" in lang_xx_xxx.swf |
|
284
|
|
|
*/ |
|
285
|
|
|
public double npcSellPriceMultiplier() { |
|
286
|
1 |
|
return pool.decimal("economy.npc.sellPriceMultiplier", .1d); |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* The bank cost per item entries |
|
291
|
|
|
* The value must be a positive double |
|
292
|
|
|
* Default to 1 |
|
293
|
|
|
* Set to 0 to disable the bank cost |
|
294
|
|
|
*/ |
|
295
|
|
|
public double bankCostPerEntry() { |
|
296
|
1 |
|
return pool.decimal("economy.bank.costPerEntry", 1); |
|
297
|
|
|
} |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
1 |
|
public final class FightConfiguration { |
|
301
|
|
|
/** |
|
302
|
|
|
* The threads count for run fight actions and AI |
|
303
|
|
|
* This value should be greater than 2. A good value may be around 1 thread per 100 fights |
|
304
|
|
|
* By default, 4 |
|
305
|
|
|
*/ |
|
306
|
|
|
public int threadsCount() { |
|
307
|
1 |
|
return pool.integer("fight.threadsCount", 4); |
|
308
|
|
|
} |
|
309
|
|
|
} |
|
310
|
|
|
} |
|
311
|
|
|
|