Implement /ban command

This commit is contained in:
memetrollsXD 2022-08-05 07:54:05 +02:00
parent 3649681f9f
commit 590236cbfa
No known key found for this signature in database
GPG Key ID: 105C2F3417AC32CD
2 changed files with 20 additions and 2 deletions

17
src/commands/ban.ts Normal file
View File

@ -0,0 +1,17 @@
import Logger from "../util/Logger";
import Interface, { Command } from "./Interface";
const c = new Logger("/ban", "blue");
export default async function handle(command: Command) {
if (!Interface.target) {
c.log("No target specified");
return;
}
const banStatus = Interface.target.player.db.banned;
Interface.target.player.db.banned = !banStatus;
Interface.target.player.save();
Interface.target.kick();
c.log(`${banStatus ? "Banned" : "Unbanned"} ${Interface.target.account.name}`);
}

View File

@ -102,7 +102,7 @@ export default class Session {
const packet = Packet.fromEncodedBuffer(Buffer.from(encodedBuffer), typeName); const packet = Packet.fromEncodedBuffer(Buffer.from(encodedBuffer), typeName);
this.c.verbL(data); this.c.verbL(data);
this.c.verbH(encodedBuffer); this.c.verbH(encodedBuffer);
if(!encodedBuffer) console.log("sad!") if (!encodedBuffer) this.c.error("encodedBuffer is undefined");
if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName); if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName);
//todo: might want to regen the ts-proto types with env = node //todo: might want to regen the ts-proto types with env = node
this.kcpobj.send(packet); this.kcpobj.send(packet);
@ -112,6 +112,7 @@ export default class Session {
public kick(hard: boolean = true) { public kick(hard: boolean = true) {
SRServer.getInstance().sessions.delete(this.id); SRServer.getInstance().sessions.delete(this.id);
this.kicked = true; this.kicked = true;
if (hard) this.send(PlayerKickOutScNotify, { if (hard) this.send(PlayerKickOutScNotify, {
kickType: PlayerKickOutScNotify_KickType.KICK_BLACK, kickType: PlayerKickOutScNotify_KickType.KICK_BLACK,
blackInfo: { blackInfo: {