diff --git a/src/commands/avatar.ts b/src/commands/avatar.ts index 0a7c376..d455b1e 100644 --- a/src/commands/avatar.ts +++ b/src/commands/avatar.ts @@ -29,4 +29,6 @@ export default async function handle(command: Command) { Avatar.remove(uid, avatarId).then(() => c.log(`Avatar ${avatarId} removed from ${uid}`)); break; } + + Interface.target.sync(); } \ No newline at end of file diff --git a/src/commands/target.ts b/src/commands/target.ts index 65fe303..84826d6 100644 --- a/src/commands/target.ts +++ b/src/commands/target.ts @@ -16,7 +16,7 @@ export default async function handle(command: Command) { SRServer.getInstance().sessions.forEach(client => { possibleTargets.push({ id: `${client.ctx.address}:${client.ctx.port}`, - uid: Number(client.account.uid), + uid: Number(client.player.db._id), session: client }); }); diff --git a/src/server/kcp/Session.ts b/src/server/kcp/Session.ts index c99e920..ab7fd8d 100644 --- a/src/server/kcp/Session.ts +++ b/src/server/kcp/Session.ts @@ -8,6 +8,8 @@ import Logger, { VerboseLevel } from '../../util/Logger'; import defaultHandler from '../packets/PacketHandler'; import Account from '../../db/Account'; import Player from '../../db/Player'; +import { PlayerSyncScNotify } from '../../data/proto/StarRail'; +import Avatar from '../../db/Avatar'; function r(...args: string[]) { return fs.readFileSync(resolve(__dirname, ...args)); @@ -68,6 +70,18 @@ export default class Session { }); } + public async sync() { + const avatars = await Avatar.fromUID(this.player.db._id); + this.send("PlayerSyncScNotify", { + avatarSync: { + avatarList: avatars.map(x => x.data), + }, + basicInfo: this.player.db.basicInfo + } as PlayerSyncScNotify); + + this.player.save(); + } + public send(name: PacketName, body: {}) { this.c.debug(body); const packet = Packet.encode(name, body);