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.data.world.repository.implementation.sql; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.core.dbal.ConnectionPool; |
23
|
|
|
import fr.quatrevieux.araknemu.core.dbal.executor.ConnectionPoolExecutor; |
24
|
|
|
import fr.quatrevieux.araknemu.core.dbal.executor.LoggedQueryExecutor; |
25
|
|
|
import fr.quatrevieux.araknemu.core.dbal.executor.QueryExecutor; |
26
|
|
|
import fr.quatrevieux.araknemu.core.di.ContainerConfigurator; |
27
|
|
|
import fr.quatrevieux.araknemu.core.di.ContainerModule; |
28
|
|
|
import fr.quatrevieux.araknemu.data.transformer.ImmutableCharacteristicsTransformer; |
29
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.SpellTemplateRepository; |
30
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.character.PlayerExperienceRepository; |
31
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.character.PlayerRaceRepository; |
32
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.MapTemplateRepository; |
33
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.MapTriggerRepository; |
34
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.area.AreaRepository; |
35
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.area.SubAreaRepository; |
36
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.npc.NpcExchangeRepository; |
37
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.npc.NpcRepository; |
38
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.npc.NpcTemplateRepository; |
39
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.npc.QuestionRepository; |
40
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.environment.npc.ResponseActionRepository; |
41
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.AreaRepositoryCache; |
42
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.ItemSetRepositoryCache; |
43
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.ItemTemplateRepositoryCache; |
44
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.ItemTypeRepositoryCache; |
45
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.MonsterGroupDataRepositoryCache; |
46
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.NpcRepositoryCache; |
47
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.NpcTemplateRepositoryCache; |
48
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.implementation.local.PlayerRaceRepositoryCache; |
49
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.item.ItemSetRepository; |
50
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.item.ItemTemplateRepository; |
51
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.item.ItemTypeRepository; |
52
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.monster.MonsterGroupDataRepository; |
53
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.monster.MonsterGroupPositionRepository; |
54
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.monster.MonsterRewardItemRepository; |
55
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.monster.MonsterRewardRepository; |
56
|
|
|
import fr.quatrevieux.araknemu.data.world.repository.monster.MonsterTemplateRepository; |
57
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.BoostStatsDataTransformer; |
58
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.ColorsTransformer; |
59
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.EffectAreaTransformer; |
60
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.ExchangeItemsTransformer; |
61
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.FightPlacesTransformer; |
62
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.ItemEffectsTransformer; |
63
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.ItemSetBonusTransformer; |
64
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.MapCellsTransformer; |
65
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.MonsterListTransformer; |
66
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.RaceBaseStatsTransformer; |
67
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.SpellTemplateLevelTransformer; |
68
|
|
|
import org.apache.logging.log4j.LogManager; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* DI module for world repositories |
72
|
|
|
*/ |
73
|
|
|
public final class SqlWorldRepositoriesModule implements ContainerModule { |
74
|
|
|
private final QueryExecutor executor; |
75
|
|
|
|
76
|
1 |
|
public SqlWorldRepositoriesModule(ConnectionPool connection) { |
77
|
1 |
|
this.executor = new LoggedQueryExecutor( |
78
|
|
|
new ConnectionPoolExecutor(connection), |
79
|
1 |
|
LogManager.getLogger(SqlWorldRepositoriesModule.class) |
80
|
|
|
); |
81
|
1 |
|
} |
82
|
|
|
|
83
|
|
|
@Override |
84
|
|
|
public void configure(ContainerConfigurator configurator) { |
85
|
1 |
|
configurator.persist( |
86
|
|
|
PlayerRaceRepository.class, |
87
|
1 |
|
container -> new PlayerRaceRepositoryCache( |
88
|
|
|
new SqlPlayerRaceRepository( |
89
|
|
|
executor, |
90
|
1 |
|
container.get(RaceBaseStatsTransformer.class), |
91
|
1 |
|
container.get(BoostStatsDataTransformer.class) |
92
|
|
|
) |
93
|
|
|
) |
94
|
|
|
); |
95
|
|
|
|
96
|
1 |
|
configurator.persist( |
97
|
|
|
MapTemplateRepository.class, |
98
|
1 |
|
container -> new SqlMapTemplateRepository( |
99
|
|
|
executor, |
100
|
1 |
|
container.get(MapCellsTransformer.class), |
101
|
1 |
|
container.get(FightPlacesTransformer.class) |
102
|
|
|
) |
103
|
|
|
); |
104
|
|
|
|
105
|
1 |
|
configurator.persist( |
106
|
|
|
MapTriggerRepository.class, |
107
|
1 |
|
container -> new SqlMapTriggerRepository(executor) |
108
|
|
|
); |
109
|
|
|
|
110
|
1 |
|
configurator.persist( |
111
|
|
|
ItemTemplateRepository.class, |
112
|
1 |
|
container -> new ItemTemplateRepositoryCache( |
113
|
|
|
new SqlItemTemplateRepository( |
114
|
|
|
executor, |
115
|
1 |
|
container.get(ItemEffectsTransformer.class) |
116
|
|
|
) |
117
|
|
|
) |
118
|
|
|
); |
119
|
|
|
|
120
|
1 |
|
configurator.persist( |
121
|
|
|
ItemSetRepository.class, |
122
|
1 |
|
container -> new ItemSetRepositoryCache( |
123
|
|
|
new SqlItemSetRepository( |
124
|
|
|
executor, |
125
|
1 |
|
container.get(ItemSetBonusTransformer.class) |
126
|
|
|
) |
127
|
|
|
) |
128
|
|
|
); |
129
|
|
|
|
130
|
1 |
|
configurator.persist( |
131
|
|
|
ItemTypeRepository.class, |
132
|
1 |
|
container -> new ItemTypeRepositoryCache( |
133
|
|
|
new SqlItemTypeRepository( |
134
|
|
|
executor, |
135
|
1 |
|
container.get(EffectAreaTransformer.class) |
136
|
|
|
) |
137
|
|
|
) |
138
|
|
|
); |
139
|
|
|
|
140
|
1 |
|
configurator.persist( |
141
|
|
|
SpellTemplateRepository.class, |
142
|
1 |
|
container -> new SqlSpellTemplateRepository( |
143
|
|
|
executor, |
144
|
1 |
|
container.get(SpellTemplateLevelTransformer.class) |
145
|
|
|
) |
146
|
|
|
); |
147
|
|
|
|
148
|
1 |
|
configurator.persist( |
149
|
|
|
PlayerExperienceRepository.class, |
150
|
1 |
|
container -> new SqlPlayerExperienceRepository(executor) |
151
|
|
|
); |
152
|
|
|
|
153
|
1 |
|
configurator.persist( |
154
|
|
|
NpcTemplateRepository.class, |
155
|
1 |
|
container -> new NpcTemplateRepositoryCache(new SqlNpcTemplateRepository(executor)) |
156
|
|
|
); |
157
|
|
|
|
158
|
1 |
|
configurator.persist( |
159
|
|
|
NpcRepository.class, |
160
|
1 |
|
container -> new NpcRepositoryCache(new SqlNpcRepository(executor)) |
161
|
|
|
); |
162
|
|
|
|
163
|
1 |
|
configurator.persist( |
164
|
|
|
QuestionRepository.class, |
165
|
1 |
|
container -> new SqlQuestionRepository(executor) |
166
|
|
|
); |
167
|
|
|
|
168
|
1 |
|
configurator.persist( |
169
|
|
|
ResponseActionRepository.class, |
170
|
1 |
|
container -> new SqlResponseActionRepository(executor) |
171
|
|
|
); |
172
|
|
|
|
173
|
1 |
|
configurator.persist( |
174
|
|
|
NpcExchangeRepository.class, |
175
|
1 |
|
container -> new SqlNpcExchangeRepository(executor, container.get(ExchangeItemsTransformer.class)) |
176
|
|
|
); |
177
|
|
|
|
178
|
1 |
|
configurator.persist( |
179
|
|
|
MonsterTemplateRepository.class, |
180
|
1 |
|
container -> new SqlMonsterTemplateRepository( |
181
|
|
|
executor, |
182
|
1 |
|
container.get(ColorsTransformer.class), |
183
|
1 |
|
container.get(ImmutableCharacteristicsTransformer.class) |
184
|
|
|
) |
185
|
|
|
); |
186
|
|
|
|
187
|
1 |
|
configurator.persist( |
188
|
|
|
MonsterGroupDataRepository.class, |
189
|
1 |
|
container -> new MonsterGroupDataRepositoryCache( |
190
|
|
|
new SqlMonsterGroupDataRepository( |
191
|
|
|
executor, |
192
|
1 |
|
container.get(MonsterListTransformer.class) |
193
|
|
|
) |
194
|
|
|
) |
195
|
|
|
); |
196
|
|
|
|
197
|
1 |
|
configurator.persist( |
198
|
|
|
MonsterGroupPositionRepository.class, |
199
|
1 |
|
container -> new SqlMonsterGroupPositionRepository(executor) |
200
|
|
|
); |
201
|
|
|
|
202
|
1 |
|
configurator.persist( |
203
|
|
|
MonsterRewardRepository.class, |
204
|
1 |
|
container -> new SqlMonsterRewardRepository(executor) |
205
|
|
|
); |
206
|
|
|
|
207
|
1 |
|
configurator.persist( |
208
|
|
|
MonsterRewardItemRepository.class, |
209
|
1 |
|
container -> new SqlMonsterRewardItemRepository(executor) |
210
|
|
|
); |
211
|
|
|
|
212
|
1 |
|
configurator.persist( |
213
|
|
|
SubAreaRepository.class, |
214
|
1 |
|
container -> new SqlSubAreaRepository(executor) |
215
|
|
|
); |
216
|
|
|
|
217
|
1 |
|
configurator.persist( |
218
|
|
|
AreaRepository.class, |
219
|
1 |
|
container -> new AreaRepositoryCache(new SqlAreaRepository(executor)) |
220
|
|
|
); |
221
|
|
|
|
222
|
1 |
|
configurator.persist( |
223
|
|
|
RaceBaseStatsTransformer.class, |
224
|
1 |
|
container -> new RaceBaseStatsTransformer( |
225
|
1 |
|
container.get(ImmutableCharacteristicsTransformer.class) |
226
|
|
|
) |
227
|
|
|
); |
228
|
|
|
|
229
|
1 |
|
configurator.persist( |
230
|
|
|
MapCellsTransformer.class, |
231
|
1 |
|
container -> new MapCellsTransformer() |
232
|
|
|
); |
233
|
|
|
|
234
|
1 |
|
configurator.persist( |
235
|
|
|
ItemEffectsTransformer.class, |
236
|
1 |
|
container -> new ItemEffectsTransformer() |
237
|
|
|
); |
238
|
|
|
|
239
|
1 |
|
configurator.persist( |
240
|
|
|
BoostStatsDataTransformer.class, |
241
|
1 |
|
container -> new BoostStatsDataTransformer() |
242
|
|
|
); |
243
|
|
|
|
244
|
1 |
|
configurator.persist( |
245
|
|
|
ItemSetBonusTransformer.class, |
246
|
1 |
|
container -> new ItemSetBonusTransformer() |
247
|
|
|
); |
248
|
|
|
|
249
|
1 |
|
configurator.persist( |
250
|
|
|
SpellTemplateLevelTransformer.class, |
251
|
1 |
|
container -> new SpellTemplateLevelTransformer( |
252
|
1 |
|
container.get(EffectAreaTransformer.class) |
253
|
|
|
) |
254
|
|
|
); |
255
|
|
|
|
256
|
1 |
|
configurator.persist( |
257
|
|
|
FightPlacesTransformer.class, |
258
|
1 |
|
container -> new FightPlacesTransformer() |
259
|
|
|
); |
260
|
|
|
|
261
|
1 |
|
configurator.persist( |
262
|
|
|
EffectAreaTransformer.class, |
263
|
1 |
|
container -> new EffectAreaTransformer() |
264
|
|
|
); |
265
|
|
|
|
266
|
1 |
|
configurator.persist( |
267
|
|
|
ColorsTransformer.class, |
268
|
1 |
|
container -> new ColorsTransformer() |
269
|
|
|
); |
270
|
|
|
|
271
|
1 |
|
configurator.persist( |
272
|
|
|
ImmutableCharacteristicsTransformer.class, |
273
|
1 |
|
container -> new ImmutableCharacteristicsTransformer() |
274
|
|
|
); |
275
|
|
|
|
276
|
1 |
|
configurator.persist( |
277
|
|
|
MonsterListTransformer.class, |
278
|
1 |
|
container -> new MonsterListTransformer() |
279
|
|
|
); |
280
|
|
|
|
281
|
1 |
|
configurator.persist( |
282
|
|
|
ExchangeItemsTransformer.class, |
283
|
1 |
|
container -> new ExchangeItemsTransformer() |
284
|
|
|
); |
285
|
1 |
|
} |
286
|
|
|
} |
287
|
|
|
|