forked from noxious/server
Minor fixes
This commit is contained in:
parent
9ea12ee458
commit
f2917e67e3
@ -6,7 +6,7 @@ interface IPayload {
|
|||||||
id: UUID
|
id: UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class characterHairDeleteEvent extends BaseEvent {
|
export default class CharacterHairDeleteEvent extends BaseEvent {
|
||||||
public listen(): void {
|
public listen(): void {
|
||||||
this.socket.on('gm:characterHair:remove', this.handleEvent.bind(this))
|
this.socket.on('gm:characterHair:remove', this.handleEvent.bind(this))
|
||||||
}
|
}
|
||||||
@ -15,13 +15,16 @@ export default class characterHairDeleteEvent extends BaseEvent {
|
|||||||
try {
|
try {
|
||||||
if (!(await this.isCharacterGM())) return
|
if (!(await this.isCharacterGM())) return
|
||||||
|
|
||||||
const characterHair = await CharacterHairRepository.getById(data.id)
|
const characterHairRepository = new CharacterHairRepository()
|
||||||
await (await CharacterHairRepository.getById(data.id))?.delete()
|
const characterHair = await characterHairRepository.getById(data.id)
|
||||||
|
if (!characterHair) return callback(false)
|
||||||
|
|
||||||
|
await characterHair.delete()
|
||||||
|
|
||||||
return callback(true)
|
return callback(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`Error deleting character type ${data.id}: ${error instanceof Error ? error.message : String(error)}`)
|
this.logger.error(`Error deleting character hair ${data.id}: ${error instanceof Error ? error.message : String(error)}`)
|
||||||
callback(false)
|
return callback(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { BaseEvent } from '#application/base/baseEvent'
|
import { BaseEvent } from '#application/base/baseEvent'
|
||||||
|
import { ItemRarity, ItemType } from '#application/enums'
|
||||||
import { Item } from '#entities/item'
|
import { Item } from '#entities/item'
|
||||||
|
import SpriteRepository from '#repositories/spriteRepository'
|
||||||
|
|
||||||
export default class ItemCreateEvent extends BaseEvent {
|
export default class ItemCreateEvent extends BaseEvent {
|
||||||
public listen(): void {
|
public listen(): void {
|
||||||
@ -10,8 +12,12 @@ export default class ItemCreateEvent extends BaseEvent {
|
|||||||
try {
|
try {
|
||||||
if (!(await this.isCharacterGM())) return
|
if (!(await this.isCharacterGM())) return
|
||||||
|
|
||||||
|
const spriteRepository = new SpriteRepository()
|
||||||
|
const sprite = await spriteRepository.getFirst()
|
||||||
|
if (!sprite) return callback(false)
|
||||||
|
|
||||||
const newItem = new Item()
|
const newItem = new Item()
|
||||||
await newItem.setName('New Item').setItemType('WEAPON').setStackable(false).setRarity('COMMON').setSprite(null).save()
|
await newItem.setName('New Item').setItemType(ItemType.WEAPON).setStackable(false).setRarity(ItemRarity.COMMON).setSprite(sprite).save()
|
||||||
|
|
||||||
return callback(true, newItem)
|
return callback(true, newItem)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { User } from '@prisma/client'
|
|
||||||
|
|
||||||
import Logger, { LoggerType } from '#application/logger'
|
import Logger, { LoggerType } from '#application/logger'
|
||||||
|
import { User } from '#entities/user'
|
||||||
|
|
||||||
type TLoggedInUsers = {
|
type TLoggedInUsers = {
|
||||||
users: User[]
|
users: User[]
|
||||||
|
@ -23,6 +23,18 @@ class SpriteRepository extends BaseRepository {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getFirst(populate?: any): Promise<Sprite | null> {
|
||||||
|
try {
|
||||||
|
const repository = this.getEntityManager().getRepository(Sprite)
|
||||||
|
const result = await repository.findOne({ id: { $exists: true } }, { populate })
|
||||||
|
if (result) result.setEntityManager(this.getEntityManager())
|
||||||
|
|
||||||
|
return result
|
||||||
|
} catch (error: any) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SpriteRepository
|
export default SpriteRepository
|
||||||
|
Loading…
x
Reference in New Issue
Block a user