mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-14 21:34:52 +01:00
Implement setting headicons/skins
This commit is contained in:
@@ -11,8 +11,16 @@ public class HandlerPlayerHeadIconInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Build response
|
||||
var rsp = PlayerHeadIconInfoResp.newInstance();
|
||||
|
||||
|
||||
var icons = session.getPlayer().getInventory().getAllHeadIcons();
|
||||
|
||||
for (int id : icons) {
|
||||
rsp.addList(id);
|
||||
}
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(NetMsgId.player_head_icon_info_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerHeadiconSet.PlayerHeadIconSetReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_head_icon_set_req)
|
||||
public class HandlerPlayerHeadIconSetReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse req
|
||||
var req = PlayerHeadIconSetReq.parseFrom(message);
|
||||
|
||||
// Set head icon
|
||||
boolean result = session.getPlayer().editHeadIcon(req.getHeadIcon());
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(result ? NetMsgId.player_head_icon_set_succeed_ack : NetMsgId.player_head_icon_set_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user