mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Initial Commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.UI32;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.char_advance_req)
|
||||
public class HandlerCharAdvanceReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = UI32.parseFrom(message);
|
||||
|
||||
// Get character
|
||||
var character = session.getPlayer().getCharacters().getCharacterById(req.getValue());
|
||||
|
||||
if (character == null) {
|
||||
return this.encodeMsg(NetMsgId.char_advance_failed_ack);
|
||||
}
|
||||
|
||||
// Advance character
|
||||
var change = character.advance();
|
||||
|
||||
if (change == null) {
|
||||
return this.encodeMsg(NetMsgId.char_advance_failed_ack);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.char_advance_succeed_ack, change.toProto());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user