mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 16:16:46 +00:00
feature(serenitea pot): Implementation of enter
Ugly hard code
This commit is contained in:
parent
27e817a6ce
commit
295f15eece
17
proto/HomeChooseModuleReq.proto
Normal file
17
proto/HomeChooseModuleReq.proto
Normal file
@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
|
||||
message HomeChooseModuleReq {
|
||||
enum CmdId {
|
||||
option allow_alias = true;
|
||||
ENET_CHANNEL_ID = 0;
|
||||
NONE = 0;
|
||||
ENET_IS_RELIABLE = 1;
|
||||
IS_ALLOW_CLIENT = 1;
|
||||
CMD_ID = 4530;
|
||||
}
|
||||
|
||||
uint32 module_id = 1;
|
||||
}
|
17
proto/HomeChooseModuleRsp.proto
Normal file
17
proto/HomeChooseModuleRsp.proto
Normal file
@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
|
||||
message HomeChooseModuleRsp {
|
||||
enum CmdId {
|
||||
option allow_alias = true;
|
||||
NONE = 0;
|
||||
ENET_CHANNEL_ID = 0;
|
||||
ENET_IS_RELIABLE = 1;
|
||||
CMD_ID = 4653;
|
||||
}
|
||||
|
||||
int32 retcode = 1;
|
||||
uint32 module_id = 2;
|
||||
}
|
17
proto/HomeComfortInfoNotify.proto
Normal file
17
proto/HomeComfortInfoNotify.proto
Normal file
@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "HomeModuleComfortInfo.proto";
|
||||
|
||||
message HomeComfortInfoNotify {
|
||||
enum CmdId {
|
||||
option allow_alias = true;
|
||||
NONE = 0;
|
||||
ENET_CHANNEL_ID = 0;
|
||||
ENET_IS_RELIABLE = 1;
|
||||
CMD_ID = 4557;
|
||||
}
|
||||
|
||||
repeated HomeModuleComfortInfo module_info_list = 1;
|
||||
}
|
10
proto/HomeModuleComfortInfo.proto
Normal file
10
proto/HomeModuleComfortInfo.proto
Normal file
@ -0,0 +1,10 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
|
||||
message HomeModuleComfortInfo {
|
||||
uint32 module_id = 1;
|
||||
repeated uint32 world_scene_block_comfort_value_list = 2;
|
||||
uint32 room_scene_comfort_value = 3;
|
||||
}
|
12
proto/PlayerHomeCompInfo.proto
Normal file
12
proto/PlayerHomeCompInfo.proto
Normal file
@ -0,0 +1,12 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "FriendEnterHomeOption.proto";
|
||||
|
||||
message PlayerHomeCompInfo {
|
||||
FriendEnterHomeOption friend_enter_home_option = 1;
|
||||
repeated uint32 unlocked_module_id_list = 2;
|
||||
repeated uint32 levelup_reward_got_level_list = 3;
|
||||
repeated uint32 seen_module_id_list = 4;
|
||||
}
|
17
proto/PlayerHomeCompInfoNotify.proto
Normal file
17
proto/PlayerHomeCompInfoNotify.proto
Normal file
@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "PlayerHomeCompInfo.proto";
|
||||
|
||||
message PlayerHomeCompInfoNotify {
|
||||
enum CmdId {
|
||||
option allow_alias = true;
|
||||
NONE = 0;
|
||||
ENET_CHANNEL_ID = 0;
|
||||
ENET_IS_RELIABLE = 1;
|
||||
CMD_ID = 4628;
|
||||
}
|
||||
|
||||
PlayerHomeCompInfo comp_info = 1;
|
||||
}
|
18
proto/TryEnterHomeReq.proto
Normal file
18
proto/TryEnterHomeReq.proto
Normal file
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
|
||||
message TryEnterHomeReq {
|
||||
enum CmdId {
|
||||
option allow_alias = true;
|
||||
ENET_CHANNEL_ID = 0;
|
||||
NONE = 0;
|
||||
ENET_IS_RELIABLE = 1;
|
||||
IS_ALLOW_CLIENT = 1;
|
||||
CMD_ID = 4792;
|
||||
}
|
||||
|
||||
uint32 target_uid = 1;
|
||||
uint32 target_point = 2;
|
||||
}
|
18
proto/TryEnterHomeRsp.proto
Normal file
18
proto/TryEnterHomeRsp.proto
Normal file
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
|
||||
message TryEnterHomeRsp {
|
||||
enum CmdId {
|
||||
option allow_alias = true;
|
||||
NONE = 0;
|
||||
ENET_CHANNEL_ID = 0;
|
||||
ENET_IS_RELIABLE = 1;
|
||||
CMD_ID = 4690;
|
||||
}
|
||||
|
||||
int32 retcode = 1;
|
||||
uint32 target_uid = 2;
|
||||
repeated uint32 param_list = 3;
|
||||
}
|
@ -87,6 +87,9 @@ public class Player {
|
||||
|
||||
private Integer widgetId;
|
||||
|
||||
private Set<Integer> realmList;
|
||||
private Integer currentRealmId;
|
||||
|
||||
@Transient private long nextGuid = 0;
|
||||
@Transient private int peerId;
|
||||
@Transient private World world;
|
||||
@ -313,6 +316,31 @@ public class Player {
|
||||
this.widgetId = widgetId;
|
||||
}
|
||||
|
||||
public Set<Integer> getRealmList() {
|
||||
return realmList;
|
||||
}
|
||||
|
||||
public void setRealmList(Set<Integer> realmList) {
|
||||
this.realmList = realmList;
|
||||
}
|
||||
|
||||
public void addRealmList(int realmId) {
|
||||
if (this.realmList == null) {
|
||||
this.realmList = new HashSet<>();
|
||||
} else if (this.realmList.contains(realmId)) {
|
||||
return;
|
||||
}
|
||||
this.realmList.add(realmId);
|
||||
}
|
||||
|
||||
public Integer getCurrentRealmId() {
|
||||
return currentRealmId;
|
||||
}
|
||||
|
||||
public void setCurrentRealmId(Integer currentRealmId) {
|
||||
this.currentRealmId = currentRealmId;
|
||||
}
|
||||
|
||||
public Position getPos() {
|
||||
return pos;
|
||||
}
|
||||
@ -1187,6 +1215,8 @@ public class Player {
|
||||
session.send(new PacketServerCondMeetQuestListUpdateNotify(this));
|
||||
session.send(new PacketAllWidgetDataNotify(this));
|
||||
session.send(new PacketWidgetGadgetAllDataNotify());
|
||||
session.send(new PacketPlayerHomeCompInfoNotify(this));
|
||||
session.send(new PacketHomeComfortInfoNotify(this));
|
||||
|
||||
getTodayMoonCard(); // The timer works at 0:0, some users log in after that, use this method to check if they have received a reward today or not. If not, send the reward.
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.HomeChooseModuleReqOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketHomeChooseModuleRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketHomeComfortInfoNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketPlayerHomeCompInfoNotify;
|
||||
|
||||
|
||||
@Opcodes(PacketOpcodes.HomeChooseModuleReq)
|
||||
public class HandlerHomeChooseModuleReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
HomeChooseModuleReqOuterClass.HomeChooseModuleReq req =
|
||||
HomeChooseModuleReqOuterClass.HomeChooseModuleReq.parseFrom(payload);
|
||||
session.getPlayer().addRealmList(req.getModuleId());
|
||||
session.getPlayer().setCurrentRealmId(req.getModuleId());
|
||||
session.send(new PacketHomeChooseModuleRsp(req.getModuleId()));
|
||||
session.send(new PacketPlayerHomeCompInfoNotify(session.getPlayer()));
|
||||
session.send(new PacketHomeComfortInfoNotify(session.getPlayer()));
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.TryEnterHomeReqOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketTryEnterHomeRsp;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
@Opcodes(PacketOpcodes.TryEnterHomeReq)
|
||||
public class HandlerTryEnterHomeReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
TryEnterHomeReqOuterClass.TryEnterHomeReq req =
|
||||
TryEnterHomeReqOuterClass.TryEnterHomeReq.parseFrom(payload);
|
||||
|
||||
if (req.getTargetUid() != session.getPlayer().getUid()) {
|
||||
// I hope that tomorrow there will be a hero who can support multiplayer mode and write code like a poem
|
||||
session.send(new PacketTryEnterHomeRsp());
|
||||
return;
|
||||
}
|
||||
|
||||
// Hardcoded for now
|
||||
switch (session.getPlayer().getCurrentRealmId()) {
|
||||
case 1:
|
||||
session.getPlayer().getWorld().transferPlayerToScene(
|
||||
session.getPlayer(),
|
||||
2001,
|
||||
new Position(839, 319, 137)
|
||||
);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
session.getPlayer().getWorld().transferPlayerToScene(
|
||||
session.getPlayer(),
|
||||
2002,
|
||||
new Position(605, 444, 554)
|
||||
);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
session.getPlayer().getWorld().transferPlayerToScene(
|
||||
session.getPlayer(),
|
||||
2003,
|
||||
new Position(511, 229, 605)
|
||||
);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
session.getPlayer().getWorld().transferPlayerToScene(
|
||||
session.getPlayer(),
|
||||
2004,
|
||||
new Position(239, 187, 536)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
session.send(new PacketTryEnterHomeRsp());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
session.send(new PacketTryEnterHomeRsp(req.getTargetUid()));
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.HomeChooseModuleRspOuterClass;
|
||||
|
||||
public class PacketHomeChooseModuleRsp extends BasePacket {
|
||||
|
||||
public PacketHomeChooseModuleRsp(int moduleId) {
|
||||
super(PacketOpcodes.HomeChooseModuleRsp);
|
||||
|
||||
HomeChooseModuleRspOuterClass.HomeChooseModuleRsp proto = HomeChooseModuleRspOuterClass.HomeChooseModuleRsp.newBuilder()
|
||||
.setRetcode(0)
|
||||
.setModuleId(moduleId)
|
||||
.build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.HomeComfortInfoNotifyOuterClass;
|
||||
import emu.grasscutter.net.proto.HomeModuleComfortInfoOuterClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketHomeComfortInfoNotify extends BasePacket {
|
||||
|
||||
public PacketHomeComfortInfoNotify(Player player) {
|
||||
super(PacketOpcodes.HomeComfortInfoNotify);
|
||||
|
||||
if (player.getRealmList() == null) {
|
||||
// Do not send
|
||||
return;
|
||||
}
|
||||
|
||||
List<HomeModuleComfortInfoOuterClass.HomeModuleComfortInfo> comfortInfoList = new ArrayList<>();
|
||||
|
||||
for (int moduleId : player.getRealmList()) {
|
||||
comfortInfoList.add(
|
||||
HomeModuleComfortInfoOuterClass.HomeModuleComfortInfo.newBuilder()
|
||||
.setModuleId(moduleId)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
HomeComfortInfoNotifyOuterClass.HomeComfortInfoNotify proto = HomeComfortInfoNotifyOuterClass.HomeComfortInfoNotify
|
||||
.newBuilder()
|
||||
.addAllModuleInfoList(comfortInfoList)
|
||||
.build();
|
||||
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.PlayerHomeCompInfoNotifyOuterClass;
|
||||
import emu.grasscutter.net.proto.PlayerHomeCompInfoOuterClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PacketPlayerHomeCompInfoNotify extends BasePacket {
|
||||
|
||||
public PacketPlayerHomeCompInfoNotify(Player player) {
|
||||
super(PacketOpcodes.PlayerHomeCompInfoNotify);
|
||||
|
||||
if (player.getRealmList() == null) {
|
||||
// Do not send
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHomeCompInfoNotifyOuterClass.PlayerHomeCompInfoNotify proto = PlayerHomeCompInfoNotifyOuterClass.PlayerHomeCompInfoNotify.newBuilder()
|
||||
.setCompInfo(
|
||||
PlayerHomeCompInfoOuterClass.PlayerHomeCompInfo.newBuilder()
|
||||
.addAllUnlockedModuleIdList(player.getRealmList())
|
||||
.addAllLevelupRewardGotLevelList(List.of(1)) // Hardcoded
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.RetcodeOuterClass;
|
||||
import emu.grasscutter.net.proto.TryEnterHomeRspOuterClass;
|
||||
|
||||
public class PacketTryEnterHomeRsp extends BasePacket {
|
||||
|
||||
public PacketTryEnterHomeRsp() {
|
||||
super(PacketOpcodes.TryEnterHomeRsp);
|
||||
|
||||
TryEnterHomeRspOuterClass.TryEnterHomeRsp proto = TryEnterHomeRspOuterClass.TryEnterHomeRsp.newBuilder()
|
||||
.setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
|
||||
.build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
|
||||
public PacketTryEnterHomeRsp(int uid) {
|
||||
super(PacketOpcodes.TryEnterHomeRsp);
|
||||
|
||||
TryEnterHomeRspOuterClass.TryEnterHomeRsp proto = TryEnterHomeRspOuterClass.TryEnterHomeRsp.newBuilder()
|
||||
.setRetcode(0)
|
||||
.setTargetUid(uid)
|
||||
.build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user