mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-30 01:35:24 +00:00
Profile set birthday feature
This commit is contained in:
parent
0c89c2dd73
commit
7fd0b371d0
@ -18,6 +18,7 @@ import emu.grasscutter.game.friends.PlayerProfile;
|
|||||||
import emu.grasscutter.game.gacha.PlayerGachaInfo;
|
import emu.grasscutter.game.gacha.PlayerGachaInfo;
|
||||||
import emu.grasscutter.game.inventory.GenshinItem;
|
import emu.grasscutter.game.inventory.GenshinItem;
|
||||||
import emu.grasscutter.game.inventory.Inventory;
|
import emu.grasscutter.game.inventory.Inventory;
|
||||||
|
import emu.grasscutter.game.player.PlayerBirthday;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
import emu.grasscutter.game.props.PlayerProperty;
|
import emu.grasscutter.game.props.PlayerProperty;
|
||||||
import emu.grasscutter.net.packet.GenshinPacket;
|
import emu.grasscutter.net.packet.GenshinPacket;
|
||||||
@ -73,6 +74,7 @@ public class GenshinPlayer {
|
|||||||
private int nameCardId = 210001;
|
private int nameCardId = 210001;
|
||||||
private Position pos;
|
private Position pos;
|
||||||
private Position rotation;
|
private Position rotation;
|
||||||
|
private PlayerBirthday birthday;
|
||||||
|
|
||||||
private Map<Integer, Integer> properties;
|
private Map<Integer, Integer> properties;
|
||||||
private Set<Integer> nameCardList;
|
private Set<Integer> nameCardList;
|
||||||
@ -139,6 +141,8 @@ public class GenshinPlayer {
|
|||||||
this.combatInvokeHandler = new InvokeHandler(PacketCombatInvocationsNotify.class);
|
this.combatInvokeHandler = new InvokeHandler(PacketCombatInvocationsNotify.class);
|
||||||
this.abilityInvokeHandler = new InvokeHandler(PacketAbilityInvocationsNotify.class);
|
this.abilityInvokeHandler = new InvokeHandler(PacketAbilityInvocationsNotify.class);
|
||||||
this.clientAbilityInitFinishHandler = new InvokeHandler(PacketClientAbilityInitFinishNotify.class);
|
this.clientAbilityInitFinishHandler = new InvokeHandler(PacketClientAbilityInitFinishNotify.class);
|
||||||
|
|
||||||
|
this.birthday = new PlayerBirthday();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On player creation
|
// On player creation
|
||||||
@ -150,6 +154,7 @@ public class GenshinPlayer {
|
|||||||
this.nickname = "Traveler";
|
this.nickname = "Traveler";
|
||||||
this.signature = "";
|
this.signature = "";
|
||||||
this.teamManager = new TeamManager(this);
|
this.teamManager = new TeamManager(this);
|
||||||
|
this.birthday = new PlayerBirthday();
|
||||||
this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, 1);
|
this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, 1);
|
||||||
this.setProperty(PlayerProperty.PROP_IS_SPRING_AUTO_USE, 1);
|
this.setProperty(PlayerProperty.PROP_IS_SPRING_AUTO_USE, 1);
|
||||||
this.setProperty(PlayerProperty.PROP_SPRING_AUTO_USE_PERCENT, 50);
|
this.setProperty(PlayerProperty.PROP_SPRING_AUTO_USE_PERCENT, 50);
|
||||||
@ -642,6 +647,15 @@ public class GenshinPlayer {
|
|||||||
return onlineInfo.build();
|
return onlineInfo.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerBirthday getBirthday(){
|
||||||
|
return this.birthday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirthday(int d, int m) {
|
||||||
|
this.birthday = new PlayerBirthday(d, m);
|
||||||
|
this.updateProfile();
|
||||||
|
}
|
||||||
|
|
||||||
public SocialDetail.Builder getSocialDetail() {
|
public SocialDetail.Builder getSocialDetail() {
|
||||||
SocialDetail.Builder social = SocialDetail.newBuilder()
|
SocialDetail.Builder social = SocialDetail.newBuilder()
|
||||||
.setUid(this.getUid())
|
.setUid(this.getUid())
|
||||||
@ -649,7 +663,7 @@ public class GenshinPlayer {
|
|||||||
.setNickname(this.getNickname())
|
.setNickname(this.getNickname())
|
||||||
.setSignature(this.getSignature())
|
.setSignature(this.getSignature())
|
||||||
.setLevel(this.getLevel())
|
.setLevel(this.getLevel())
|
||||||
.setBirthday(Birthday.newBuilder())
|
.setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty())
|
||||||
.setWorldLevel(this.getWorldLevel())
|
.setWorldLevel(this.getWorldLevel())
|
||||||
.setUnk1(1)
|
.setUnk1(1)
|
||||||
.setUnk3(1)
|
.setUnk3(1)
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package emu.grasscutter.game.player;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday;
|
||||||
|
|
||||||
|
public class PlayerBirthday {
|
||||||
|
private int day;
|
||||||
|
private int month;
|
||||||
|
|
||||||
|
public PlayerBirthday(){
|
||||||
|
this.day = 0;
|
||||||
|
this.month = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerBirthday(int day, int month){
|
||||||
|
this.day = day;
|
||||||
|
this.month = month;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerBirthday set(PlayerBirthday birth){
|
||||||
|
this.day = birth.day;
|
||||||
|
this.month = birth.month;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerBirthday set(int d, int m){
|
||||||
|
this.day = d;
|
||||||
|
this.month = m;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerBirthday setDay(int value){
|
||||||
|
this.day = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerBirthday setMonth(int value){
|
||||||
|
this.month = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDay(){
|
||||||
|
return this.day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMonth(){
|
||||||
|
return this.month;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Birthday toProto(){
|
||||||
|
return Birthday.newBuilder()
|
||||||
|
.setDay(this.getDay())
|
||||||
|
.setMonth(this.getMonth())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Birthday.Builder getFilledProtoWhenNotEmpty(){
|
||||||
|
if(this.getDay() > 0)
|
||||||
|
{
|
||||||
|
return Birthday.newBuilder()
|
||||||
|
.setDay(this.getDay())
|
||||||
|
.setMonth(this.getMonth());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Birthday.newBuilder();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
|
import emu.grasscutter.server.game.GameSession;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
|
||||||
|
import emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
@Opcodes(PacketOpcodes.SetPlayerBirthdayReq)
|
||||||
|
public class HandlerSetPlayerBirthdayReq extends PacketHandler {
|
||||||
|
@Override
|
||||||
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
SetPlayerBirthdayReq req = SetPlayerBirthdayReq.parseFrom(payload);
|
||||||
|
|
||||||
|
if(req.getBirth() != null && req.getBirth().getDay() > 0 && req.getBirth().getMonth() > 0)
|
||||||
|
{
|
||||||
|
int day = req.getBirth().getDay();
|
||||||
|
int month = req.getBirth().getMonth();
|
||||||
|
|
||||||
|
// Update birthday value
|
||||||
|
session.getPlayer().setBirthday(day, month);
|
||||||
|
|
||||||
|
// Save birthday month and day
|
||||||
|
session.getPlayer().save();
|
||||||
|
SocialDetail.Builder detail = session.getPlayer().getSocialDetail();
|
||||||
|
|
||||||
|
session.send(new PacketSetPlayerBirthdayRsp(session.getPlayer()));
|
||||||
|
session.send(new PacketGetPlayerSocialDetailRsp(detail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.game.GenshinPlayer;
|
||||||
|
import emu.grasscutter.net.packet.GenshinPacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp;
|
||||||
|
import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday;
|
||||||
|
|
||||||
|
public class PacketSetPlayerBirthdayRsp extends GenshinPacket {
|
||||||
|
public PacketSetPlayerBirthdayRsp(GenshinPlayer player) {
|
||||||
|
super(PacketOpcodes.SetPlayerBirthdayRsp);
|
||||||
|
|
||||||
|
SetPlayerBirthdayRsp proto = SetPlayerBirthdayRsp.newBuilder()
|
||||||
|
.setBirth(player.getBirthday().toProto())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
|
||||||
|
if(Grasscutter.getConfig().DebugMode == true) Grasscutter.getLogger().info("Sending packet");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user