mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Implement presets
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PotentialPreselectionUpdate.PotentialPreselectionUpdateReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.potential_preselection_update_req)
|
||||
public class HandlerPotentialPreselectionUpdateReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = PotentialPreselectionUpdateReq.parseFrom(message);
|
||||
|
||||
// Get preset
|
||||
var preset = session.getPlayer().getStarTowerManager().getPresetById(req.getId());
|
||||
|
||||
if (preset == null) {
|
||||
return session.encodeMsg(NetMsgId.potential_preselection_update_failed_ack);
|
||||
}
|
||||
|
||||
// Update potentials
|
||||
preset.updatePotentials(req.getCharPotentials());
|
||||
preset.save();
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(NetMsgId.potential_preselection_update_succeed_ack, preset.toProto());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user