Converted more events

This commit is contained in:
2025-01-04 20:11:34 +01:00
parent 47ec425acf
commit 21f4c5328f
21 changed files with 113 additions and 102 deletions

View File

@ -1,6 +1,7 @@
import { BaseEvent } from '#application/base/baseEvent'
import { MapObject } from '#entities/mapObject'
import ObjectRepository from '#repositories/mapObjectRepository'
import MapObjectRepository from '#repositories/mapObjectRepository'
interface IPayload {}
@ -10,10 +11,17 @@ export default class MapObjectListEvent extends BaseEvent {
}
private async handleEvent(data: IPayload, callback: (response: MapObject[]) => void): Promise<void> {
if (!(await this.isCharacterGM())) return
try {
if (!(await this.isCharacterGM())) return
// get all objects
const objects = await ObjectRepository.getAll()
return callback(objects)
// Get all map objects
const mapObjectRepository = new MapObjectRepository()
const mapObjects = await mapObjectRepository.getAll()
return callback(mapObjects)
} catch (error) {
this.logger.error('gm:mapObject:list error', error)
return callback([])
}
}
}