-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cosmetics): allow outfit skin updates
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/handlers/c2u/cosmetic/outfit/c2uCosmeticOutfitSkinUpdate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { and, eq } from "drizzle-orm"; | ||
import { db } from "~/db/index.js"; | ||
import { outfits } from "~/db/schema.js"; | ||
import { Handler } from "~/handlers/index.js"; | ||
import cosmeticOutfitSkinUpdate from "~/protocol/packets/cosmetic/outfit/cosmeticOutfitSkinUpdate.js"; | ||
|
||
export default { | ||
def: cosmeticOutfitSkinUpdate, | ||
async handle(client, packet) { | ||
const { a: outfitId, b: skinTexture, c: skinId } = packet.body!; | ||
console.log(skinId, skinTexture); | ||
|
||
const outfit = ( | ||
await db | ||
.select() | ||
.from(outfits) | ||
.where( | ||
and(eq(outfits.id, outfitId), eq(outfits.ownerId, client.profile.id)) | ||
) | ||
.limit(1) | ||
)[0]; | ||
|
||
if (!outfit) | ||
return await client.sendResponse(packet, false, "Outfit not found"); | ||
|
||
await db | ||
.update(outfits) | ||
.set({ skinId, skinTexture }) | ||
.where( | ||
and(eq(outfits.id, outfitId), eq(outfits.ownerId, client.profile.id)) | ||
); | ||
|
||
await client.sendResponse(packet); | ||
|
||
await client.sendOutfitToSubscribers(); | ||
|
||
return { cancelled: true }; | ||
}, | ||
} as Handler<typeof cosmeticOutfitSkinUpdate>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/protocol/packets/cosmetic/outfit/cosmeticOutfitSkinUpdate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { z } from "zod"; | ||
import { PacketDefinition } from "~/protocol/packets.js"; | ||
|
||
const schema = z.object({ | ||
a: z.string(), // outfit id | ||
b: z.string().nullish(), // skin texture | ||
c: z.string().nullish(), // skin id | ||
}); | ||
|
||
export default { | ||
className: "cosmetic.outfit.ClientCosmeticOutfitSkinUpdatePacket", | ||
body: schema, | ||
} as PacketDefinition<typeof schema>; |