mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-23 10:44:36 +01:00
full TextJoinQuery handler
This commit is contained in:
@@ -4,6 +4,7 @@ import java.lang.reflect.Field;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import emu.lunarcore.data.config.FloorInfo;
|
||||
import emu.lunarcore.data.excel.*;
|
||||
import emu.lunarcore.game.battle.MazeBuff;
|
||||
@@ -143,6 +144,19 @@ public class GameData {
|
||||
return allIds;
|
||||
}
|
||||
|
||||
public static int TextJoinItemFromId(int id) {
|
||||
for (Int2ObjectMap.Entry<TextJoinExcel> entry : textJoinExcelMap.int2ObjectEntrySet()) {
|
||||
TextJoinExcel textJoinExcel = entry.getValue();
|
||||
if (textJoinExcel.getId() == id) {
|
||||
IntArrayList textJoinItemList = textJoinExcel.getTextJoinItemList();
|
||||
if (textJoinItemList.size() > 0) {
|
||||
return textJoinItemList.getInt(textJoinItemList.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return id * 10; // or return a default value if needed
|
||||
}
|
||||
|
||||
public static List<Integer> getAllQuestIds() {
|
||||
List<Integer> allIds = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -5,13 +5,15 @@ import emu.lunarcore.server.packet.CmdId;
|
||||
import emu.lunarcore.server.packet.Opcodes;
|
||||
import emu.lunarcore.server.packet.PacketHandler;
|
||||
import emu.lunarcore.server.packet.send.PacketTextJoinQueryScRsp;
|
||||
import emu.lunarcore.proto.TextJoinQueryCsReqOuterClass.TextJoinQueryCsReq;
|
||||
|
||||
@Opcodes(CmdId.TextJoinQueryCsReq)
|
||||
public class HandlerTextJoinQueryCsReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] data) throws Exception {
|
||||
session.send(new PacketTextJoinQueryScRsp(session.getPlayer()));
|
||||
var req = TextJoinQueryCsReq.parseFrom(data);
|
||||
session.send(new PacketTextJoinQueryScRsp(session.getPlayer(), req.getTextJoinIdList().toArray()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
package emu.lunarcore.server.packet.send;
|
||||
|
||||
import emu.lunarcore.game.mail.Mail;
|
||||
import emu.lunarcore.data.GameData;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.proto.TextJoinQueryScRspOuterClass.TextJoinQueryScRsp;
|
||||
import emu.lunarcore.proto.TextJoinQueryScRspOuterClass.TextJoinQueryScRsp.TextJoinInfo;
|
||||
import emu.lunarcore.server.packet.BasePacket;
|
||||
import emu.lunarcore.server.packet.CmdId;
|
||||
|
||||
public class PacketTextJoinQueryScRsp extends BasePacket {
|
||||
|
||||
public PacketTextJoinQueryScRsp(Player player) {
|
||||
public PacketTextJoinQueryScRsp(Player player, int[] textJoinIdList) {
|
||||
super(CmdId.TextJoinQueryScRsp);
|
||||
|
||||
|
||||
var data = TextJoinQueryScRsp.newInstance();
|
||||
|
||||
for (int joinId : textJoinIdList) {
|
||||
TextJoinInfo joinInfo = TextJoinInfo.newInstance()
|
||||
.setTextItemId(joinId)
|
||||
.setTextItemConfigId(GameData.TextJoinItemFromId(joinId));
|
||||
data.addTextJoinList(joinInfo);
|
||||
}
|
||||
|
||||
this.setData(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user