mirror of
https://github.com/Anime-Game-Servers/Grasscutter-Quests.git
synced 2024-11-26 22:10:26 +00:00
Replace PacketOpcodes references with strings (#130)
Replace session.send(new BasePacket(PacketOpcodes.Packet)); with session.send(new BasePacket(session.getPackageIdProvider().getPacketId("Packet")));
This commit is contained in:
parent
67599e89af
commit
46c3ef8e6b
@ -245,8 +245,7 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
||||
player.onLogout();
|
||||
}
|
||||
try {
|
||||
val disconnectPacketId = getPackageIdProvider().getPacketId("ServerDisconnectClientNotify");
|
||||
send(new BasePacket(disconnectPacketId));
|
||||
send(new BasePacket(getPackageIdProvider().getPacketId("ServerDisconnectClientNotify")));
|
||||
} catch (Throwable ignore) {
|
||||
Grasscutter.getLogger().warn("closing {} error", getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class HandlerPlayerForceExitReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
// Client should auto disconnect right now
|
||||
session.send(new BasePacket(PacketOpcodes.PlayerForceExitRsp));
|
||||
session.send(new BasePacket(session.getPackageIdProvider().getPacketId("PlayerForceExitRsp")));
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -31,7 +31,7 @@ public class HandlerPlayerLoginReq extends TypedPacketHandler<PlayerLoginReq> {
|
||||
if (player.getAvatars().getAvatarCount() == 0) {
|
||||
// Pick character
|
||||
session.setState(SessionState.PICKING_CHARACTER);
|
||||
session.send(new BasePacket(PacketOpcodes.DoSetPlayerBornDataNotify));
|
||||
session.send(new BasePacket(session.getPackageIdProvider().getPacketId("DoSetPlayerBornDataNotify")));
|
||||
} else {
|
||||
// Login done
|
||||
session.getPlayer().onLogin();
|
||||
|
@ -14,6 +14,6 @@ public class HandlerPlayerQuitDungeonReq extends PacketHandler {
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
val req = PlayerQuitDungeonReq.parseFrom(payload);
|
||||
session.getPlayer().getServer().getDungeonSystem().exitDungeon(session.getPlayer(), req.getIsQuitImmediately());
|
||||
session.getPlayer().sendPacket(new BasePacket(PacketOpcodes.PlayerQuitDungeonRsp));
|
||||
session.getPlayer().sendPacket(new BasePacket(session.getPackageIdProvider().getPacketId("PlayerQuitDungeonRsp")));
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class HandlerQuickUseWidgetReq extends PacketHandler {
|
||||
}
|
||||
proto.setMaterialId(materialId);
|
||||
inventory.removeItem(item,1);// decrease count
|
||||
BasePacket rsp = new BasePacket(PacketOpcodes.QuickUseWidgetRsp);
|
||||
BasePacket rsp = new BasePacket(session.getPackageIdProvider().getPacketId("QuickUseWidgetRsp"));
|
||||
rsp.setData(proto);
|
||||
session.send(rsp);
|
||||
Grasscutter.getLogger().warn("class has no effects in the game, feel free to implement it");
|
||||
|
@ -24,7 +24,7 @@ public class HandlerSceneInitFinishReq extends TypedPacketHandler<SceneInitFinis
|
||||
session.send(new PacketWorldDataNotify(session.getPlayer().getWorld()));
|
||||
session.send(new PacketWorldOwnerBlossomBriefInfoNotify(session.getPlayer().getWorld()));
|
||||
session.send(new PacketPlayerWorldSceneInfoListNotify(session.getPlayer()));
|
||||
session.send(new BasePacket(PacketOpcodes.SceneForceUnlockNotify));
|
||||
session.send(new BasePacket(session.getPackageIdProvider().getPacketId("SceneForceUnlockNotify")));
|
||||
session.send(new PacketHostPlayerNotify(session.getPlayer().getWorld()));
|
||||
session.send(new PacketSceneDataNotify(session.getPlayer()));
|
||||
session.send(new PacketSceneTimeNotify(session.getPlayer()));
|
||||
|
@ -9,20 +9,20 @@ import emu.grasscutter.server.game.GameSession;
|
||||
|
||||
@Opcodes(PacketOpcodes.SetEntityClientDataNotify)
|
||||
public class HandlerSetEntityClientDataNotify extends PacketHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
// Skip if there is no one to broadcast it too
|
||||
if (session.getPlayer().getScene().getPlayerCount() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Make sure packet is a valid proto before replaying it to the other players
|
||||
SetEntityClientDataNotify notif = SetEntityClientDataNotify.parseFrom(payload);
|
||||
|
||||
BasePacket packet = new BasePacket(PacketOpcodes.SetEntityClientDataNotify, true);
|
||||
|
||||
BasePacket packet = new BasePacket(session.getPackageIdProvider().getPacketId("SetEntityClientDataNotify"), true);
|
||||
packet.setData(notif);
|
||||
|
||||
|
||||
session.getPlayer().getScene().broadcastPacket(packet);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
|
||||
session.getPlayer().onPlayerBorn();
|
||||
|
||||
// Born resp packet
|
||||
session.send(new BasePacket(PacketOpcodes.SetPlayerBornDataRsp));
|
||||
session.send(new BasePacket(session.getPackageIdProvider().getPacketId("SetPlayerBornDataRsp")));
|
||||
|
||||
// Default mail
|
||||
var welcomeMail = GAME_INFO.joinOptions.welcomeMail;
|
||||
|
Loading…
Reference in New Issue
Block a user