forked from noxious/server
Map event tile improvements
This commit is contained in:
@ -6,9 +6,10 @@ class MapEventTileRepository extends BaseRepository {
|
||||
async getAll(id: UUID): Promise<MapEventTile[]> {
|
||||
try {
|
||||
const repository = this.getEntityManager().getRepository(MapEventTile)
|
||||
return await repository.find({
|
||||
map: id
|
||||
})
|
||||
const results = await repository.find({ map: id })
|
||||
for (const result of results) result.setEntityManager(this.getEntityManager())
|
||||
|
||||
return results
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Failed to get map event tiles: ${error.message}`)
|
||||
return []
|
||||
@ -18,11 +19,14 @@ class MapEventTileRepository extends BaseRepository {
|
||||
async getEventTileByMapIdAndPosition(mapId: UUID, positionX: number, positionY: number) {
|
||||
try {
|
||||
const repository = this.getEntityManager().getRepository(MapEventTile)
|
||||
return await repository.findOne({
|
||||
const result = await repository.findOne({
|
||||
map: mapId,
|
||||
positionX: positionX,
|
||||
positionY: positionY
|
||||
})
|
||||
if (result) result.setEntityManager(this.getEntityManager())
|
||||
|
||||
return result
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Failed to get map event tile: ${error.message}`)
|
||||
return null
|
||||
|
Reference in New Issue
Block a user