1
0
forked from noxious/server

More improvements

This commit is contained in:
2025-01-04 19:05:54 +01:00
parent 067976c54a
commit 9a448542d3
11 changed files with 38 additions and 184 deletions

View File

@ -16,21 +16,15 @@ export default class TeleportCommandEvent extends BaseEvent {
private async handleEvent(data: TypePayload, callback: (response: boolean) => void) {
try {
const mapCharacter = MapManager.getCharacterById(this.socket.characterId!)
if (!mapCharacter) {
this.logger.error('chat:message error', 'Character not found')
return
}
const character = mapCharacter.character
if (character.role !== 'gm') {
this.logger.info(`User ${character.id} tried to set time but is not a game master.`)
return
}
// Check if command is teleport
if (!ChatService.isCommand(data.message, 'teleport')) return
// Check if character exists and is GM
if (!(await this.isCharacterGM())) return
const character = await this.getCharacter()
if (!character) return
const args = ChatService.getArgs('teleport', data.message)
if (!args || args.length === 0 || args.length > 3) {
@ -53,7 +47,8 @@ export default class TeleportCommandEvent extends BaseEvent {
return
}
const map = await MapRepository.getById(mapId)
const mapRepository = new MapRepository()
const map = await mapRepository.getById(mapId)
if (!map) {
this.socket.emit('notification', {
title: 'Server message',