mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-16 22:34:41 +01:00
Initial Commit
This commit is contained in:
17
src/main/java/emu/nebula/server/handlers/Handler.java
Normal file
17
src/main/java/emu/nebula/server/handlers/Handler.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.none)
|
||||
public class Handler extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Template
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.Achievements;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.achievement_info_req)
|
||||
public class HandlerAchievementInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = Achievements.newInstance();
|
||||
|
||||
return this.encodeMsg(NetMsgId.achievement_info_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.ActivityDetail.ActivityMsg;
|
||||
import emu.nebula.proto.ActivityDetail.ActivityResp;
|
||||
import emu.nebula.proto.Public.ActivityTrial;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.activity_detail_req)
|
||||
public class HandlerActivityDetailReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = ActivityResp.newInstance();
|
||||
|
||||
var activity = ActivityMsg.newInstance()
|
||||
.setId(700101)
|
||||
.setTrial(ActivityTrial.newInstance());
|
||||
|
||||
rsp.addList(activity);
|
||||
|
||||
return this.encodeMsg(NetMsgId.activity_detail_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.agent_apply_req)
|
||||
public class HandlerAgentApplyReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.agent_apply_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.battle_pass_info_req)
|
||||
public class HandlerBattlePassInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.battle_pass_info_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.CharSkillUpgrade.CharSkillUpgradeReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.char_skill_upgrade_req)
|
||||
public class HandlerCharSkillUpgradeReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = CharSkillUpgradeReq.parseFrom(message);
|
||||
|
||||
// Get character
|
||||
var character = session.getPlayer().getCharacters().getCharacterById(req.getCharId());
|
||||
|
||||
if (character == null) {
|
||||
return this.encodeMsg(NetMsgId.char_skill_upgrade_failed_ack);
|
||||
}
|
||||
|
||||
// Advance character
|
||||
int index = req.getIndex() - 1; // Lua indexes start at 1
|
||||
var change = character.upgradeSkill(index);
|
||||
|
||||
if (change == null) {
|
||||
return this.encodeMsg(NetMsgId.char_skill_upgrade_failed_ack);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.char_skill_upgrade_succeed_ack, change.toProto());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.CharUpgrade.CharUpgradeReq;
|
||||
import emu.nebula.proto.CharUpgrade.CharUpgradeResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.inventory.ItemParamMap;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.char_upgrade_req)
|
||||
public class HandlerCharUpgradeReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = CharUpgradeReq.parseFrom(message);
|
||||
|
||||
// Get character
|
||||
var character = session.getPlayer().getCharacters().getCharacterById(req.getCharId());
|
||||
|
||||
if (character == null) {
|
||||
return this.encodeMsg(NetMsgId.char_upgrade_failed_ack);
|
||||
}
|
||||
|
||||
// Upgrade character
|
||||
var params = ItemParamMap.fromTemplates(req.getItems());
|
||||
var change = character.upgrade(params);
|
||||
|
||||
if (change == null) {
|
||||
return this.encodeMsg(NetMsgId.char_upgrade_failed_ack);
|
||||
}
|
||||
|
||||
// Create response
|
||||
var rsp = CharUpgradeResp.newInstance()
|
||||
.setChange(change.toProto())
|
||||
.setLevel(character.getLevel())
|
||||
.setExp(character.getExp());
|
||||
|
||||
return this.encodeMsg(NetMsgId.char_upgrade_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.client_event_report_req)
|
||||
public class HandlerClientEventReportReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.client_event_report_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.DiscPromote.DiscPromoteReq;
|
||||
import emu.nebula.proto.DiscPromote.DiscPromoteResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.disc_promote_req)
|
||||
public class HandlerDiscPromoteReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = DiscPromoteReq.parseFrom(message);
|
||||
|
||||
// Get character
|
||||
var disc = session.getPlayer().getCharacters().getDiscById(req.getId());
|
||||
|
||||
if (disc == null) {
|
||||
return this.encodeMsg(NetMsgId.disc_promote_failed_ack);
|
||||
}
|
||||
|
||||
// Advance character
|
||||
var change = disc.promote();
|
||||
|
||||
if (change == null) {
|
||||
return this.encodeMsg(NetMsgId.disc_promote_failed_ack);
|
||||
}
|
||||
|
||||
// Build request
|
||||
var rsp = DiscPromoteResp.newInstance()
|
||||
.setPhase(disc.getPhase())
|
||||
.setChange(change.toProto());
|
||||
|
||||
return this.encodeMsg(NetMsgId.disc_promote_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.disc_read_reward_receive_req)
|
||||
public class HandlerDiscReadRewardReceiveReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.disc_read_reward_receive_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.DiscStrengthen.DiscStrengthenReq;
|
||||
import emu.nebula.proto.DiscStrengthen.DiscStrengthenResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.inventory.ItemParamMap;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.disc_strengthen_req)
|
||||
public class HandlerDiscStrengthenReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = DiscStrengthenReq.parseFrom(message);
|
||||
|
||||
// Get character
|
||||
var disc = session.getPlayer().getCharacters().getDiscById(req.getId());
|
||||
|
||||
if (disc == null) {
|
||||
return this.encodeMsg(NetMsgId.disc_strengthen_failed_ack);
|
||||
}
|
||||
|
||||
// Upgrade character
|
||||
var params = ItemParamMap.fromItemInfos(req.getItems());
|
||||
var change = disc.upgrade(params);
|
||||
|
||||
if (change == null) {
|
||||
return this.encodeMsg(NetMsgId.disc_strengthen_failed_ack);
|
||||
}
|
||||
|
||||
// Create response
|
||||
var rsp = DiscStrengthenResp.newInstance()
|
||||
.setChange(change.toProto())
|
||||
.setLevel(disc.getLevel())
|
||||
.setExp(disc.getExp());
|
||||
|
||||
return this.encodeMsg(NetMsgId.disc_strengthen_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.FriendListGet.FriendListGetResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.friend_list_get_req)
|
||||
public class HandlerFriendListGetReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = FriendListGetResp.newInstance();
|
||||
|
||||
return this.encodeMsg(NetMsgId.friend_list_get_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaInformation.GachaInformationResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_information_req)
|
||||
public class HandlerGachaInformationReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = GachaInformationResp.newInstance();
|
||||
|
||||
// TODO
|
||||
|
||||
return this.encodeMsg(NetMsgId.gacha_information_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaInformation.GachaInformationResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_newbie_info_req)
|
||||
public class HandlerGachaNewbieInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = GachaInformationResp.newInstance();
|
||||
|
||||
return this.encodeMsg(NetMsgId.gacha_newbie_info_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaNewbieObtain.GachaNewbieObtainReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_newbie_obtain_req)
|
||||
public class HandlerGachaNewbieObtainReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
var req = GachaNewbieObtainReq.parseFrom(message);
|
||||
|
||||
// TODO
|
||||
return this.encodeMsg(NetMsgId.gacha_newbie_obtain_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaNewbieSpin.GachaNewbieSpinResp;
|
||||
import emu.nebula.proto.GachaSpin.GachaSpinReq;
|
||||
import emu.nebula.util.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_newbie_spin_req)
|
||||
public class HandlerGachaNewbieSpinReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
var req = GachaSpinReq.parseFrom(message);
|
||||
|
||||
// Temp
|
||||
var list = new IntArrayList();
|
||||
|
||||
for (var d : GameData.getCharacterDataTable()) {
|
||||
if (d.getGrade() == 1) {
|
||||
list.add(d.getId());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
var rsp = GachaNewbieSpinResp.newInstance();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int id = Utils.randomElement(list);
|
||||
rsp.addCards(id);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.gacha_newbie_spin_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaSpin.GachaCard;
|
||||
import emu.nebula.proto.GachaSpin.GachaSpinReq;
|
||||
import emu.nebula.proto.GachaSpin.GachaSpinResp;
|
||||
import emu.nebula.proto.Public.ItemTpl;
|
||||
import emu.nebula.util.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_spin_req)
|
||||
public class HandlerGachaSpinReq extends NetHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = GachaSpinReq.parseFrom(message);
|
||||
|
||||
// Temp
|
||||
var list = new IntArrayList();
|
||||
|
||||
for (var def : GameData.getCharacterDataTable()) {
|
||||
if (def.getGrade() == 1 && def.isAvailable()) {
|
||||
list.add(def.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// Build response
|
||||
var rsp = GachaSpinResp.newInstance()
|
||||
.setTime(Nebula.getCurrentTime());
|
||||
|
||||
rsp.getMutableChange();
|
||||
rsp.getMutableNextPackage();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int id = Utils.randomElement(list);
|
||||
|
||||
var card = GachaCard.newInstance()
|
||||
.setCard(ItemTpl.newInstance().setTid(id).setQty(1));
|
||||
|
||||
rsp.addCards(card);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.gacha_spin_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
61
src/main/java/emu/nebula/server/handlers/HandlerIkeReq.java
Normal file
61
src/main/java/emu/nebula/server/handlers/HandlerIkeReq.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Ike.IKEReq;
|
||||
import emu.nebula.proto.Ike.IKEResp;
|
||||
import emu.nebula.util.Utils;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.ike_req)
|
||||
public class HandlerIkeReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public boolean requireSession() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requirePlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Make sure we dont already have a session
|
||||
if (session != null) {
|
||||
return this.encodeMsg(NetMsgId.ike_failed_ack);
|
||||
}
|
||||
|
||||
// Parse
|
||||
var req = IKEReq.parseFrom(message);
|
||||
|
||||
// Create session
|
||||
session = new GameSession();
|
||||
session.setClientKey(req.getPubKey());
|
||||
session.generateServerKey();
|
||||
session.calculateKey();
|
||||
|
||||
// Register session to game context
|
||||
Nebula.getGameContext().generateSessionToken(session);
|
||||
|
||||
// Create response
|
||||
var rsp = IKEResp.newInstance()
|
||||
.setToken(session.getToken())
|
||||
.setCipher(1) // 0 = gcm, 1 = chacha20
|
||||
.setServerTs(Nebula.getCurrentTime())
|
||||
.setPubKey(session.getServerPublicKey());
|
||||
|
||||
// Debug
|
||||
Nebula.getLogger().info("Client Public: " + Utils.base64Encode(session.getClientPublicKey()));
|
||||
Nebula.getLogger().info("Server Public: " + Utils.base64Encode(session.getServerPublicKey()));
|
||||
Nebula.getLogger().info("Server Private: " + Utils.base64Encode(session.getServerPrivateKey()));
|
||||
Nebula.getLogger().info("Key: " + Utils.base64Encode(session.getKey()));
|
||||
|
||||
// Encode and send to client
|
||||
return this.encodeMsg(NetMsgId.ike_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.Public.Mails;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mail_list_req)
|
||||
public class HandlerMailListReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Build mail list proto
|
||||
var rsp = Mails.newInstance();
|
||||
|
||||
for (var mail : session.getPlayer().getMailbox()) {
|
||||
rsp.addList(mail.toProto());
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mail_list_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MailPin.MailPinRequest;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.mail.GameMail;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mail_pin_req)
|
||||
public class HandlerMailPinReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = MailPinRequest.parseFrom(message);
|
||||
|
||||
// Pin mail
|
||||
GameMail mail = session.getPlayer().getMailbox().pinMail(req.getId(), req.getFlag(), req.hasPin());
|
||||
|
||||
// Sanity check
|
||||
if (mail == null) {
|
||||
return this.encodeMsg(NetMsgId.mail_pin_failed_ack);
|
||||
}
|
||||
|
||||
// Build response
|
||||
var rsp = MailPinRequest.newInstance()
|
||||
.setId(mail.getId())
|
||||
.setFlag(mail.getFlag())
|
||||
.setPin(mail.isPin());
|
||||
|
||||
return this.encodeMsg(NetMsgId.mail_pin_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.MailRequest;
|
||||
import emu.nebula.proto.Public.UI32;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mail_read_req)
|
||||
public class HandlerMailReadReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = MailRequest.parseFrom(message);
|
||||
|
||||
boolean result = session.getPlayer().getMailbox().readMail(req.getId(), req.getFlag());
|
||||
|
||||
if (!result) {
|
||||
return this.encodeMsg(NetMsgId.mail_read_failed_ack);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mail_read_succeed_ack, UI32.newInstance().setValue(req.getId()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MailRecv.MailRecvResp;
|
||||
import emu.nebula.proto.Public.MailRequest;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.player.PlayerChangeInfo;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mail_recv_req)
|
||||
public class HandlerMailRecvReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = MailRequest.parseFrom(message);
|
||||
|
||||
// Claim mail
|
||||
PlayerChangeInfo changes = session.getPlayer().getMailbox().recvMail(session.getPlayer(), req.getId());
|
||||
|
||||
// Build response
|
||||
var rsp = MailRecvResp.newInstance()
|
||||
.setItems(changes.toProto());
|
||||
|
||||
var recvList = (IntList) changes.getExtraData();
|
||||
|
||||
for (int id : recvList) {
|
||||
rsp.addIds(id);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mail_recv_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MailRemove.MailRemoveResp;
|
||||
import emu.nebula.proto.Public.MailRequest;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mail_remove_req)
|
||||
public class HandlerMailRemoveReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = MailRequest.parseFrom(message);
|
||||
|
||||
// Claim mail
|
||||
IntList removed = session.getPlayer().getMailbox().removeMail(session.getPlayer(), req.getId());
|
||||
|
||||
// Build response
|
||||
var rsp = MailRemoveResp.newInstance();
|
||||
|
||||
for (int id : removed) {
|
||||
rsp.addIds(id);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mail_remove_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MallGemListOuterClass.GemInfo;
|
||||
import emu.nebula.proto.MallGemListOuterClass.MallGemList;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mall_gem_list_req)
|
||||
public class HandlerMallGemListReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = MallGemList.newInstance();
|
||||
|
||||
for (var data : GameData.getMallGemDataTable()) {
|
||||
var info = GemInfo.newInstance()
|
||||
.setId(data.getIdString())
|
||||
.setMaiden(true);
|
||||
|
||||
rsp.addList(info);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mall_gem_list_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MallMonthlycardList.MallMonthlyCardList;
|
||||
import emu.nebula.proto.MallMonthlycardList.MonthlyCardInfo;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mall_monthlyCard_list_req)
|
||||
public class HandlerMallMonthlyCardListReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = MallMonthlyCardList.newInstance();
|
||||
|
||||
for (var data : GameData.getMallMonthlyCardDataTable()) {
|
||||
var info = MonthlyCardInfo.newInstance()
|
||||
.setId(data.getIdString())
|
||||
.setRemaining(9);
|
||||
|
||||
rsp.addList(info);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mall_monthlyCard_list_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MallPackageListOuterClass.MallPackageList;
|
||||
import emu.nebula.proto.MallPackageListOuterClass.PackageInfo;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mall_package_list_req)
|
||||
public class HandlerMallPackageListReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = MallPackageList.newInstance();
|
||||
|
||||
for (var data : GameData.getMallPackageDataTable()) {
|
||||
var info = PackageInfo.newInstance()
|
||||
.setId(data.getIdString())
|
||||
.setStock(data.getStock());
|
||||
|
||||
rsp.addList(info);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mall_package_list_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.MallShopList.MallShopProductList;
|
||||
import emu.nebula.proto.MallShopList.ProductInfo;
|
||||
import emu.nebula.net.HandlerId;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.mall_shop_list_req)
|
||||
public class HandlerMallShopListReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = MallShopProductList.newInstance();
|
||||
|
||||
long refreshTime = Nebula.getCurrentTime() + TimeUnit.DAYS.toSeconds(30);
|
||||
|
||||
for (var data : GameData.getMallShopDataTable()) {
|
||||
if (data.getStock() <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var info = ProductInfo.newInstance()
|
||||
.setId(data.getIdString())
|
||||
.setStock(data.getStock())
|
||||
.setRefreshTime(refreshTime);
|
||||
|
||||
rsp.addList(info);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.mall_shop_list_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.phone_contacts_info_req)
|
||||
public class HandlerPhoneContactsInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.phone_contacts_info_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_data_req)
|
||||
public class HandlerPlayerDataReq extends NetHandler {
|
||||
|
||||
public boolean requirePlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Check if player has been created yet
|
||||
if (session.getPlayer() == null) {
|
||||
return this.encodeMsg(NetMsgId.player_new_notify);
|
||||
}
|
||||
|
||||
// Encode player data
|
||||
return this.encodeMsg(NetMsgId.player_data_succeed_ack, session.getPlayer().toProto());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerFormation.PlayerFormationReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_formation_req)
|
||||
public class HandlerPlayerFormationReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = PlayerFormationReq.parseFrom(message);
|
||||
|
||||
boolean success = session.getPlayer().getFormations().updateFormation(req.getFormation());
|
||||
|
||||
return this.encodeMsg(success ? NetMsgId.player_formation_succeed_ack : NetMsgId.player_formation_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_gender_edit_req)
|
||||
public class HandlerPlayerGenderEditReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
session.getPlayer().editGender();
|
||||
|
||||
return this.encodeMsg(NetMsgId.player_gender_edit_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerHeadInfo.PlayerHeadIconInfoResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_head_icon_info_req)
|
||||
public class HandlerPlayerHeadIconInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = PlayerHeadIconInfoResp.newInstance();
|
||||
|
||||
return this.encodeMsg(NetMsgId.player_head_icon_info_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.NewbieInfo;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_learn_req)
|
||||
public class HandlerPlayerLearnReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = NewbieInfo.parseFrom(message);
|
||||
|
||||
// TODO set newbie info
|
||||
session.getPlayer().setNewbieInfo(req.getGroupId(), req.getStepId());
|
||||
|
||||
return this.encodeMsg(NetMsgId.player_learn_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerLogin.LoginReq;
|
||||
import emu.nebula.proto.PlayerLogin.LoginResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_login_req)
|
||||
public class HandlerPlayerLoginReq extends NetHandler {
|
||||
|
||||
public boolean requirePlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = LoginReq.parseFrom(message);
|
||||
var loginToken = req.getOfficialOverseas().getToken();
|
||||
|
||||
// Login
|
||||
boolean result = session.login(loginToken);
|
||||
|
||||
if (!result) {
|
||||
return this.encodeMsg(NetMsgId.player_login_failed_ack);
|
||||
}
|
||||
|
||||
// Regenerate session token because we are switching encrpytion method
|
||||
Nebula.getGameContext().generateSessionToken(session);
|
||||
|
||||
// Create rsp
|
||||
var rsp = LoginResp.newInstance()
|
||||
.setToken(session.getToken());
|
||||
|
||||
// Encode and send to client
|
||||
return this.encodeMsg(NetMsgId.player_login_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_music_set_req)
|
||||
public class HandlerPlayerMusicSetReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.player_music_set_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerNameEdit.PlayerNameEditReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_name_edit_req)
|
||||
public class HandlerPlayerNameEditReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var req = PlayerNameEditReq.parseFrom(message);
|
||||
|
||||
boolean success = session.getPlayer().editName(req.getName());
|
||||
|
||||
return this.encodeMsg(success ? NetMsgId.player_name_edit_succeed_ack : NetMsgId.player_name_edit_failed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerPing.Pong;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_ping_req)
|
||||
public class HandlerPlayerPingReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = Pong.newInstance()
|
||||
.setServerTs(Nebula.getCurrentTime());
|
||||
|
||||
return this.encodeMsg(NetMsgId.player_ping_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.PlayerRegOuterClass.PlayerReg;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.game.player.Player;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_reg_req)
|
||||
public class HandlerPlayerRegReq extends NetHandler {
|
||||
|
||||
public boolean requirePlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = PlayerReg.parseFrom(message);
|
||||
|
||||
// Sanity
|
||||
if (req.getNickname() == null || req.getNickname().isEmpty()) {
|
||||
return this.encodeMsg(NetMsgId.player_reg_failed_ack);
|
||||
}
|
||||
|
||||
// Create player
|
||||
Player player = Nebula.getGameContext().getPlayerModule().createPlayer(session, req.getNickname(), req.getGender());
|
||||
|
||||
if (player == null) {
|
||||
return this.encodeMsg(NetMsgId.player_reg_failed_ack);
|
||||
}
|
||||
|
||||
// Encode player data
|
||||
return this.encodeMsg(NetMsgId.player_data_succeed_ack, session.getPlayer().toProto());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.StarTowerApply.StarTowerApplyReq;
|
||||
import emu.nebula.proto.StarTowerApply.StarTowerApplyResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.star_tower_apply_req)
|
||||
public class HandlerStarTowerApplyReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse req
|
||||
var req = StarTowerApplyReq.parseFrom(message);
|
||||
|
||||
// Apply to create a star tower instance
|
||||
var instance = session.getPlayer().getStarTowerManager().apply(req);
|
||||
|
||||
if (instance == null) {
|
||||
return this.encodeMsg(NetMsgId.star_tower_apply_failed_ack);
|
||||
}
|
||||
|
||||
// Create response
|
||||
var rsp = StarTowerApplyResp.newInstance()
|
||||
.setLastId(req.getId())
|
||||
.setInfo(instance.toProto());
|
||||
|
||||
rsp.getMutableChange();
|
||||
|
||||
return this.encodeMsg(NetMsgId.star_tower_apply_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.star_tower_build_brief_list_get_req)
|
||||
public class HandlerStarTowerBuildBriefListGetReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.star_tower_build_brief_list_get_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.StarTowerInteract.StarTowerInteractReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.star_tower_interact_req)
|
||||
public class HandlerStarTowerInteractReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Get star tower instance
|
||||
var instance = session.getPlayer().getStarTowerManager().getInstance();
|
||||
|
||||
if (instance == null) {
|
||||
return this.encodeMsg(NetMsgId.star_tower_interact_failed_ack);
|
||||
}
|
||||
|
||||
// Parse request
|
||||
var req = StarTowerInteractReq.parseFrom(message);
|
||||
|
||||
// Handle interaction
|
||||
var rsp = instance.handleInteract(req);
|
||||
|
||||
// Template
|
||||
return this.encodeMsg(NetMsgId.star_tower_interact_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.tower_growth_detail_req)
|
||||
public class HandlerTowerGrowthDetailReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.tower_growth_detail_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user