Implement setting player skin

This commit is contained in:
Melledy
2025-11-19 03:50:04 -08:00
parent c97300f98a
commit 03c24e6dfa
2 changed files with 49 additions and 0 deletions

View File

@@ -284,6 +284,27 @@ public class Player implements GameDatabaseObject {
// Success
return true;
}
public boolean setSkin(int skinId) {
// Skip if we are setting the same skin
if (this.skinId == skinId) {
return true;
}
// Make sure we own this skin
if (!getInventory().hasSkin(skinId)) {
return false;
}
// Set skin
this.skinId = skinId;
// Update in database
Nebula.getGameDatabase().update(this, this.getUid(), "skinId", this.getSkinId());
// Success
return false;
}
public boolean setShowChars(RepeatedInt charIds) {
// Sanity check

View File

@@ -0,0 +1,28 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.PlayerSkinShow.PlayerSkinShowReq;
import emu.nebula.net.HandlerId;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.player_skin_show_req)
public class HandlerPlayerSkinShowReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Parse req
var req = PlayerSkinShowReq.parseFrom(message);
// Set player skin
boolean success = session.getPlayer().setSkin(req.getSkinId());
if (success == false) {
session.encodeMsg(NetMsgId.player_skin_show_failed_ack);
}
// Encode and send
return session.encodeMsg(NetMsgId.player_skin_show_succeed_ack);
}
}