forked from noxious/server
Added data validation upon creating maps
This commit is contained in:
parent
f6a4bd3369
commit
3b6c11090f
@ -18,6 +18,16 @@ export default class MapCreateEvent extends BaseEvent {
|
||||
|
||||
this.logger.info(`GM ${(await this.getCharacter())!.getId()} has created a new map via map editor.`)
|
||||
|
||||
if (data.name === '') {
|
||||
this.socket.emit('notification', { message: 'Map name cannot be empty.' })
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
if (data.width < 1 || data.height < 1) {
|
||||
this.socket.emit('notification', { message: 'Map width and height must be greater than 0.' })
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
const map = new Map()
|
||||
await map
|
||||
.setName(data.name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user