Fix avatar command

This commit is contained in:
memetrollsXD 2022-08-02 03:42:03 +02:00
parent 0ff5564b43
commit ad1b43ba3e
No known key found for this signature in database
GPG Key ID: 105C2F3417AC32CD
3 changed files with 17 additions and 1 deletions

View File

@ -29,4 +29,6 @@ export default async function handle(command: Command) {
Avatar.remove(uid, avatarId).then(() => c.log(`Avatar ${avatarId} removed from ${uid}`)); Avatar.remove(uid, avatarId).then(() => c.log(`Avatar ${avatarId} removed from ${uid}`));
break; break;
} }
Interface.target.sync();
} }

View File

@ -16,7 +16,7 @@ export default async function handle(command: Command) {
SRServer.getInstance().sessions.forEach(client => { SRServer.getInstance().sessions.forEach(client => {
possibleTargets.push({ possibleTargets.push({
id: `${client.ctx.address}:${client.ctx.port}`, id: `${client.ctx.address}:${client.ctx.port}`,
uid: Number(client.account.uid), uid: Number(client.player.db._id),
session: client session: client
}); });
}); });

View File

@ -8,6 +8,8 @@ import Logger, { VerboseLevel } from '../../util/Logger';
import defaultHandler from '../packets/PacketHandler'; import defaultHandler from '../packets/PacketHandler';
import Account from '../../db/Account'; import Account from '../../db/Account';
import Player from '../../db/Player'; import Player from '../../db/Player';
import { PlayerSyncScNotify } from '../../data/proto/StarRail';
import Avatar from '../../db/Avatar';
function r(...args: string[]) { function r(...args: string[]) {
return fs.readFileSync(resolve(__dirname, ...args)); 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: {}) { public send(name: PacketName, body: {}) {
this.c.debug(body); this.c.debug(body);
const packet = Packet.encode(name, body); const packet = Packet.encode(name, body);