From 213ab89b7efb4ab079508bdb6c672342e62ea2e9 Mon Sep 17 00:00:00 2001 From: sophie Date: Tue, 27 Aug 2024 20:40:34 +0300 Subject: [PATCH] update pianoverse --- bun.lockb | Bin 8473 -> 8374 bytes package.json | 2 +- src/Server.ts | 78 ++++++++++++++++++++++++++------------------------ 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/bun.lockb b/bun.lockb index 5cf526475e4f2fe35cc7afa069677da4b3a89668..65d1cbd957d740b574df354769e60e4747020e80 100755 GIT binary patch delta 1284 zcmZ8g3rtg27(VCrwxunl1;jqUE(NM#Kq;jtuTo&JKnermMkjL{6B`8LG@`&})TZL* z7(}}t3C)b86U`h(FcrpdW)FdFzA|wvbOVA*=G@E}BPKc%=>A&;m)+!?@BXiI{&UXv zx$_2dkLtC5FDd#Dm`DBb-~O=sV!;>olDlU@wjbH-9uk~xH`U7P*1Ag5wK_tGm=H(k z6Z9ZT&^A#*)=V_Pom{Bk_|{k;|QcYcOTxavNUmGa>`kqw%~Qb-hAON1*s5W+eJzK*-KXDK_A z(f*Q=S8{K%$UQbzyvr25<<55JH&+U)nx|u4tkcy`9cz0zMO36a-x2)EiEaN(T-5G; zkgvOZ4c17MFfF!H5yVMsFe#BjyTnQ*;6v+huoTRAD(QcB%v?0{XH*mO^&1a0d=Oe! zAuhe{`S5bj>HFoed~?pC!zb@E~{;s{|r|i_?D$L zQkGFUkUx5bp|2(DlMQ+Uablbk*|w2YCv~#?nn1*$HxbeS?FyCJgKKDQlQs7G{;o)MbI5yxR3vcing` zL-(iYQ?UWEEM-?xW&7Fzb2>(h27R(opJs+cm5O=DLZPZleipmnl-`n-dW|-REJ44@ zp!&bFN*y>W(LlPoSiH0LjW>5R+IKbB;ie{1`_xQIOnPc08ufS!`rS2egFZ4BY?^9l kjnptH2KXfM5#0bZO6whqa#0XQMZ&NqjIQ@y*Az4V0wWl7>;M1& delta 1384 zcma)5drVVT7(eH>rL^?61%~ZyE#QEaXIo0!lp$7N%#orn_vk=$1KQFG6J}AtL;6fV`8>!K1ODoiP>BXLv+rmI2*SKi_Ex%=tvgK%-Ft*gOUB^Nxu909_N1N z_4}R7>C5dhtg6$m8_vu2f4i?Wsi)Ucx;k)EZ|*SP?S6f9<^^u(gs!c-D0A~JLWq=* zW+5dc46z7Ni8zOO7IAyS)&RPsK2YPYK%7R4!2Bgd6(TDjBnt5%^C(}9u>#|8tV_G6 z<4kf9Aree%LgW`1M3fxWLCJ)MEAR|!v4B8$W8pH@LzhqjLB>Ik04H$JyHFxGI20D+e$1SO(k6z&-%_7U`5L)p)A$&fhKTT=F^J zsb6!c`ls6&z+_~($6fob>A%q9El@JAm`4=Ad5H_gBrK#!om2#kQWrEx*}`)-e~-^Q z*j72(>O8n3l*G?=+TR`Rf2;j`T>sUH+sR|P=U<(Rthsmg9o=sGFV70TYPmRkJ?lWs zo|C`DW*yHdNLsdp7?Q$VkQl~7N0^i1tz&cpqimUzhC!Rm1#ik&NRT+!Bg2-4aQH{9 zrQk?|*;s$Zb>fzfRowqX=q|H7p!tWbP?Y?~=U+dV&6>#HlKY}#!@a!f58sm)^}HYH zo9(~#%J}y?nmR|)SYTjM*?_k%RCeK;@&rDFh-7TWmt75CDtHsZm~vvICj0{d^KuBfp>fD>U>HI8>Z%8dJQceCM7RN>Dsg#n3J329v=;$f62WdnEBK+fvi9 zVm4q6w?d&)rKUx2R<)i!1cjPoSOFxf&9oXet2s>VQdco@5lpJp)DeCe z#Ch!*9=F?TvSpN;ZRw_Ro5^Z2TfA1c#fy25J)^?nt-v||{qh)nlLMZ|?F(|93Vzlk wL)S_z)M}#{vkl(X{z+}HLAwf?V#Fh#u570u(^i5jI)YlESQ|6a7M;fY16MeJiU0rr diff --git a/package.json b/package.json index 0ae9210..3daf86d 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,6 @@ }, "type": "module", "dependencies": { - "pianoverse": "git+https://git.sad.ovh/sophie/pianoverse#f83eddf063a2610a605024f5d4fedde83b4fb83e" + "pianoverse": "^2.0.0" } } \ No newline at end of file diff --git a/src/Server.ts b/src/Server.ts index 63ce17a..e206616 100644 --- a/src/Server.ts +++ b/src/Server.ts @@ -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);