update pianoverse
This commit is contained in:
parent
9969a17590
commit
213ab89b7e
|
@ -9,6 +9,6 @@
|
|||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"pianoverse": "git+https://git.sad.ovh/sophie/pianoverse#f83eddf063a2610a605024f5d4fedde83b4fb83e"
|
||||
"pianoverse": "^2.0.0"
|
||||
}
|
||||
}
|
|
@ -79,6 +79,7 @@ export class Server {
|
|||
if (typeof message == "string") return;
|
||||
if (!ws.data) return;
|
||||
|
||||
//@ts-expect-error
|
||||
const decode = proto.ClientMessage.fromBinary(message);
|
||||
|
||||
if (decode.event == CEventType.KICK) {
|
||||
|
@ -132,6 +133,46 @@ export class Server {
|
|||
if (!player.data.room) return;
|
||||
player.data.room.ban(player, decode.ban!.minutes);
|
||||
}
|
||||
if(decode.event == CEventType.UNMOD) {
|
||||
let eventSenderProfile = Server.profiles.get(ws.data.id);
|
||||
if (!eventSenderProfile) return;
|
||||
if(eventSenderProfile.role == proto.Role.USER) return;
|
||||
const profile = Server.profiles.get(decode.unmod);
|
||||
if (!profile) return;
|
||||
if (profile.role !== proto.Role.MODERATOR) return;
|
||||
profile.role = proto.Role.USER;
|
||||
profile.commit();
|
||||
profile.emit("update");
|
||||
Server.wses.forEach((z) => {
|
||||
if (z.data.id == profile.id) z.close(6969);
|
||||
});
|
||||
ws.data.send(
|
||||
Server.systemMessage(
|
||||
"Removed moderator status from ID " + decode.unmod + "."
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (decode.event == CEventType.MOD) {
|
||||
let eventSenderProfile = Server.profiles.get(ws.data.id);
|
||||
if (!eventSenderProfile) return;
|
||||
if(eventSenderProfile.role == proto.Role.USER) return;
|
||||
|
||||
const profile = Server.profiles.get(decode.mod);
|
||||
if (!profile) return;
|
||||
if (profile.role == proto.Role.MODERATOR) return;
|
||||
profile.role = proto.Role.MODERATOR;
|
||||
profile.commit();
|
||||
profile.emit("update");
|
||||
Server.wses.forEach((z) => {
|
||||
if (z.data.id == profile.id) z.close(6969);
|
||||
});
|
||||
|
||||
ws.data.send(
|
||||
Server.systemMessage("Added moderator status to ID " + decode.mod + ".")
|
||||
);
|
||||
return;
|
||||
}
|
||||
//#region All of these packets just regurgiated info
|
||||
if (decode.event == CEventType.CHAT) {
|
||||
let profile = Server.profiles.get(ws.data.id);
|
||||
|
@ -171,43 +212,6 @@ export class Server {
|
|||
ws.data.send(Server.systemMessage("Unbanned ID " + id + "."));
|
||||
return;
|
||||
}
|
||||
if (command == "/unmod") {
|
||||
const id = args[0];
|
||||
const profile = Server.profiles.get(id);
|
||||
if (!profile) return;
|
||||
if (profile.role !== proto.Role.MODERATOR) return;
|
||||
profile.role = proto.Role.USER;
|
||||
profile.commit();
|
||||
profile.emit("update");
|
||||
Server.wses.forEach((z) => {
|
||||
if (z.data.id == profile.id) z.close(6969);
|
||||
});
|
||||
ws.data.send(
|
||||
Server.systemMessage(
|
||||
"Removed moderator status from ID " + id + "."
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (command == "/mod") {
|
||||
const id = args[0];
|
||||
const profile = Server.profiles.get(id);
|
||||
if (!profile) return;
|
||||
if (profile.role == proto.Role.MODERATOR) return;
|
||||
profile.role = proto.Role.MODERATOR;
|
||||
profile.commit();
|
||||
profile.emit("update");
|
||||
Server.wses.forEach((z) => {
|
||||
if (z.data.id == profile.id) z.close(6969);
|
||||
});
|
||||
|
||||
ws.data.send(
|
||||
Server.systemMessage(
|
||||
"Added moderator status to ID " + id + "."
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ws.data.room!.chat(ws, decode.chat);
|
||||
|
|
Loading…
Reference in a new issue