mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 20:34:36 +01:00
Implement setting player skin
This commit is contained in:
@@ -284,6 +284,27 @@ public class Player implements GameDatabaseObject {
|
|||||||
// Success
|
// Success
|
||||||
return true;
|
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) {
|
public boolean setShowChars(RepeatedInt charIds) {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user