Fix avatar command
This commit is contained in:
parent
0ff5564b43
commit
ad1b43ba3e
@ -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();
|
||||||
}
|
}
|
@ -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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user