mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-12 13:24:36 +01:00
Fix path changing for the trailblazer
This commit is contained in:
@@ -53,6 +53,16 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
*/
|
||||
private int retcode;
|
||||
|
||||
/**
|
||||
* <code>optional uint32 gender = 14;</code>
|
||||
*/
|
||||
private int gender;
|
||||
|
||||
/**
|
||||
* <code>optional bool is_gender_set = 9;</code>
|
||||
*/
|
||||
private boolean isGenderSet;
|
||||
|
||||
/**
|
||||
* <code>optional .PlayerSettingInfo player_setting_info = 4;</code>
|
||||
*/
|
||||
@@ -327,12 +337,86 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional uint32 gender = 14;</code>
|
||||
* @return whether the gender field is set
|
||||
*/
|
||||
public boolean hasGender() {
|
||||
return (bitField0_ & 0x00000080) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional uint32 gender = 14;</code>
|
||||
* @return this
|
||||
*/
|
||||
public GetBasicInfoScRsp clearGender() {
|
||||
bitField0_ &= ~0x00000080;
|
||||
gender = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional uint32 gender = 14;</code>
|
||||
* @return the gender
|
||||
*/
|
||||
public int getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional uint32 gender = 14;</code>
|
||||
* @param value the gender to set
|
||||
* @return this
|
||||
*/
|
||||
public GetBasicInfoScRsp setGender(final int value) {
|
||||
bitField0_ |= 0x00000080;
|
||||
gender = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional bool is_gender_set = 9;</code>
|
||||
* @return whether the isGenderSet field is set
|
||||
*/
|
||||
public boolean hasIsGenderSet() {
|
||||
return (bitField0_ & 0x00000100) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional bool is_gender_set = 9;</code>
|
||||
* @return this
|
||||
*/
|
||||
public GetBasicInfoScRsp clearIsGenderSet() {
|
||||
bitField0_ &= ~0x00000100;
|
||||
isGenderSet = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional bool is_gender_set = 9;</code>
|
||||
* @return the isGenderSet
|
||||
*/
|
||||
public boolean getIsGenderSet() {
|
||||
return isGenderSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional bool is_gender_set = 9;</code>
|
||||
* @param value the isGenderSet to set
|
||||
* @return this
|
||||
*/
|
||||
public GetBasicInfoScRsp setIsGenderSet(final boolean value) {
|
||||
bitField0_ |= 0x00000100;
|
||||
isGenderSet = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>optional .PlayerSettingInfo player_setting_info = 4;</code>
|
||||
* @return whether the playerSettingInfo field is set
|
||||
*/
|
||||
public boolean hasPlayerSettingInfo() {
|
||||
return (bitField0_ & 0x00000080) != 0;
|
||||
return (bitField0_ & 0x00000200) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +424,7 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
* @return this
|
||||
*/
|
||||
public GetBasicInfoScRsp clearPlayerSettingInfo() {
|
||||
bitField0_ &= ~0x00000080;
|
||||
bitField0_ &= ~0x00000200;
|
||||
playerSettingInfo.clear();
|
||||
return this;
|
||||
}
|
||||
@@ -369,7 +453,7 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
* @return internal storage object for modifications
|
||||
*/
|
||||
public PlayerSettingInfoOuterClass.PlayerSettingInfo getMutablePlayerSettingInfo() {
|
||||
bitField0_ |= 0x00000080;
|
||||
bitField0_ |= 0x00000200;
|
||||
return playerSettingInfo;
|
||||
}
|
||||
|
||||
@@ -380,7 +464,7 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
*/
|
||||
public GetBasicInfoScRsp setPlayerSettingInfo(
|
||||
final PlayerSettingInfoOuterClass.PlayerSettingInfo value) {
|
||||
bitField0_ |= 0x00000080;
|
||||
bitField0_ |= 0x00000200;
|
||||
playerSettingInfo.copyFrom(value);
|
||||
return this;
|
||||
}
|
||||
@@ -397,6 +481,8 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
weekCocoonFinishedCount = other.weekCocoonFinishedCount;
|
||||
exchangeTimes = other.exchangeTimes;
|
||||
retcode = other.retcode;
|
||||
gender = other.gender;
|
||||
isGenderSet = other.isGenderSet;
|
||||
playerSettingInfo.copyFrom(other.playerSettingInfo);
|
||||
}
|
||||
return this;
|
||||
@@ -429,6 +515,12 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
if (other.hasRetcode()) {
|
||||
setRetcode(other.retcode);
|
||||
}
|
||||
if (other.hasGender()) {
|
||||
setGender(other.gender);
|
||||
}
|
||||
if (other.hasIsGenderSet()) {
|
||||
setIsGenderSet(other.isGenderSet);
|
||||
}
|
||||
if (other.hasPlayerSettingInfo()) {
|
||||
getMutablePlayerSettingInfo().mergeFrom(other.playerSettingInfo);
|
||||
}
|
||||
@@ -449,6 +541,8 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
weekCocoonFinishedCount = 0;
|
||||
exchangeTimes = 0;
|
||||
retcode = 0;
|
||||
gender = 0;
|
||||
isGenderSet = false;
|
||||
playerSettingInfo.clear();
|
||||
return this;
|
||||
}
|
||||
@@ -481,6 +575,8 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
&& (!hasWeekCocoonFinishedCount() || weekCocoonFinishedCount == other.weekCocoonFinishedCount)
|
||||
&& (!hasExchangeTimes() || exchangeTimes == other.exchangeTimes)
|
||||
&& (!hasRetcode() || retcode == other.retcode)
|
||||
&& (!hasGender() || gender == other.gender)
|
||||
&& (!hasIsGenderSet() || isGenderSet == other.isGenderSet)
|
||||
&& (!hasPlayerSettingInfo() || playerSettingInfo.equals(other.playerSettingInfo));
|
||||
}
|
||||
|
||||
@@ -515,6 +611,14 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
output.writeUInt32NoTag(retcode);
|
||||
}
|
||||
if ((bitField0_ & 0x00000080) != 0) {
|
||||
output.writeRawByte((byte) 112);
|
||||
output.writeUInt32NoTag(gender);
|
||||
}
|
||||
if ((bitField0_ & 0x00000100) != 0) {
|
||||
output.writeRawByte((byte) 72);
|
||||
output.writeBoolNoTag(isGenderSet);
|
||||
}
|
||||
if ((bitField0_ & 0x00000200) != 0) {
|
||||
output.writeRawByte((byte) 34);
|
||||
output.writeMessageNoTag(playerSettingInfo);
|
||||
}
|
||||
@@ -545,6 +649,12 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
|
||||
}
|
||||
if ((bitField0_ & 0x00000080) != 0) {
|
||||
size += 1 + ProtoSink.computeUInt32SizeNoTag(gender);
|
||||
}
|
||||
if ((bitField0_ & 0x00000100) != 0) {
|
||||
size += 2;
|
||||
}
|
||||
if ((bitField0_ & 0x00000200) != 0) {
|
||||
size += 1 + ProtoSink.computeMessageSizeNoTag(playerSettingInfo);
|
||||
}
|
||||
return size;
|
||||
@@ -616,6 +726,24 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
retcode = input.readUInt32();
|
||||
bitField0_ |= 0x00000040;
|
||||
tag = input.readTag();
|
||||
if (tag != 112) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 112: {
|
||||
// gender
|
||||
gender = input.readUInt32();
|
||||
bitField0_ |= 0x00000080;
|
||||
tag = input.readTag();
|
||||
if (tag != 72) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 72: {
|
||||
// isGenderSet
|
||||
isGenderSet = input.readBool();
|
||||
bitField0_ |= 0x00000100;
|
||||
tag = input.readTag();
|
||||
if (tag != 34) {
|
||||
break;
|
||||
}
|
||||
@@ -623,7 +751,7 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
case 34: {
|
||||
// playerSettingInfo
|
||||
input.readMessage(playerSettingInfo);
|
||||
bitField0_ |= 0x00000080;
|
||||
bitField0_ |= 0x00000200;
|
||||
tag = input.readTag();
|
||||
if (tag != 0) {
|
||||
break;
|
||||
@@ -668,6 +796,12 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
output.writeUInt32(FieldNames.retcode, retcode);
|
||||
}
|
||||
if ((bitField0_ & 0x00000080) != 0) {
|
||||
output.writeUInt32(FieldNames.gender, gender);
|
||||
}
|
||||
if ((bitField0_ & 0x00000100) != 0) {
|
||||
output.writeBool(FieldNames.isGenderSet, isGenderSet);
|
||||
}
|
||||
if ((bitField0_ & 0x00000200) != 0) {
|
||||
output.writeMessage(FieldNames.playerSettingInfo, playerSettingInfo);
|
||||
}
|
||||
output.endObject();
|
||||
@@ -763,12 +897,35 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case -1249512767: {
|
||||
if (input.isAtField(FieldNames.gender)) {
|
||||
if (!input.trySkipNullValue()) {
|
||||
gender = input.readUInt32();
|
||||
bitField0_ |= 0x00000080;
|
||||
}
|
||||
} else {
|
||||
input.skipUnknownField();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1425215447:
|
||||
case 1366482969: {
|
||||
if (input.isAtField(FieldNames.isGenderSet)) {
|
||||
if (!input.trySkipNullValue()) {
|
||||
isGenderSet = input.readBool();
|
||||
bitField0_ |= 0x00000100;
|
||||
}
|
||||
} else {
|
||||
input.skipUnknownField();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 616260989:
|
||||
case -1071462949: {
|
||||
if (input.isAtField(FieldNames.playerSettingInfo)) {
|
||||
if (!input.trySkipNullValue()) {
|
||||
input.readMessage(playerSettingInfo);
|
||||
bitField0_ |= 0x00000080;
|
||||
bitField0_ |= 0x00000200;
|
||||
}
|
||||
} else {
|
||||
input.skipUnknownField();
|
||||
@@ -842,6 +999,10 @@ public final class GetBasicInfoScRspOuterClass {
|
||||
|
||||
static final FieldName retcode = FieldName.forField("retcode");
|
||||
|
||||
static final FieldName gender = FieldName.forField("gender");
|
||||
|
||||
static final FieldName isGenderSet = FieldName.forField("isGenderSet", "is_gender_set");
|
||||
|
||||
static final FieldName playerSettingInfo = FieldName.forField("playerSettingInfo", "player_setting_info");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package emu.lunarcore.command.commands;
|
||||
|
||||
import emu.lunarcore.GameConstants;
|
||||
import emu.lunarcore.command.Command;
|
||||
import emu.lunarcore.command.CommandArgs;
|
||||
import emu.lunarcore.command.CommandHandler;
|
||||
import emu.lunarcore.data.GameData;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerGender;
|
||||
import emu.lunarcore.server.packet.send.PacketGetBasicInfoScRsp;
|
||||
|
||||
@Command(label = "gender", permission = "player.gender", requireTarget = true, desc = "/gender {male | female}. Sets the player gender.")
|
||||
public class GenderCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(CommandArgs args) {
|
||||
// Set world level
|
||||
Player target = args.getTarget();
|
||||
|
||||
// Get new gender
|
||||
String gender = args.get(0).toLowerCase();
|
||||
PlayerGender playerGender = switch (gender) {
|
||||
case "m", "male", "boy", "man", "1" -> PlayerGender.GENDER_MAN;
|
||||
case "f", "female", "girl", "woman", "2" -> PlayerGender.GENDER_WOMAN;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
// Change gender
|
||||
if (playerGender != null && playerGender != target.getGender()) {
|
||||
// Get first hero excel that matches our new player gender
|
||||
var excel = GameData.getMultiplePathAvatarExcelMap().values().stream()
|
||||
.filter(path -> path.getBaseAvatarID() == GameConstants.TRAILBLAZER_AVATAR_ID && path.getGender() == playerGender)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// Sanity check. Should never happen
|
||||
if (excel == null) {
|
||||
args.sendMessage("Error: No avatar path was found for this gender");
|
||||
return;
|
||||
}
|
||||
|
||||
// Set our main character's path
|
||||
target.setAvatarPath(excel.getId());
|
||||
|
||||
// Send packet to update our gender
|
||||
target.sendPacket(new PacketGetBasicInfoScRsp(target));
|
||||
|
||||
// Send response message
|
||||
args.sendMessage("Gender for " + target.getName() + " set successfully");
|
||||
} else {
|
||||
args.sendMessage("Error: Invalid input");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -479,13 +479,19 @@ public class Player implements Tickable {
|
||||
// Set new avatar path
|
||||
avatar.setMultiPath(path);
|
||||
|
||||
// Set current avatar path
|
||||
this.getCurAvatarPaths().put(excel.getBaseAvatarID(), pathId);
|
||||
// Set gender if we are changing the main character
|
||||
if (excel.getBaseAvatarID() == GameConstants.TRAILBLAZER_AVATAR_ID && excel.getGender() != null) {
|
||||
this.gender = excel.getGender();
|
||||
}
|
||||
|
||||
// Set current avatar path and save to database
|
||||
this.getCurAvatarPaths().put(excel.getBaseAvatarID(), pathId);
|
||||
this.save();
|
||||
|
||||
// Sync with client
|
||||
this.sendPacket(new PacketAvatarPathChangedNotify(avatar, path));
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(avatar));
|
||||
|
||||
|
||||
// Success
|
||||
return pathId;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class HandlerGetBasicInfoCsReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] data) throws Exception {
|
||||
session.send(new PacketGetBasicInfoScRsp(session));
|
||||
session.send(new PacketGetBasicInfoScRsp(session.getPlayer()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package emu.lunarcore.server.packet.send;
|
||||
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.proto.GetBasicInfoScRspOuterClass.GetBasicInfoScRsp;
|
||||
import emu.lunarcore.proto.PlayerSettingInfoOuterClass.PlayerSettingInfo;
|
||||
import emu.lunarcore.server.game.GameSession;
|
||||
import emu.lunarcore.server.packet.BasePacket;
|
||||
import emu.lunarcore.server.packet.CmdId;
|
||||
|
||||
public class PacketGetBasicInfoScRsp extends BasePacket {
|
||||
|
||||
public PacketGetBasicInfoScRsp(GameSession session) {
|
||||
public PacketGetBasicInfoScRsp(Player player) {
|
||||
super(CmdId.GetBasicInfoScRsp);
|
||||
|
||||
var data = GetBasicInfoScRsp.newInstance()
|
||||
.setCurDay(1)
|
||||
.setNextRecoverTime(session.getPlayer().getNextStaminaRecover() / 1000)
|
||||
.setGameplayBirthday(session.getPlayer().getBirthday())
|
||||
.setIsGenderSet(true)
|
||||
.setGender(player.getGender().getVal())
|
||||
.setNextRecoverTime(player.getNextStaminaRecover() / 1000)
|
||||
.setGameplayBirthday(player.getBirthday())
|
||||
.setPlayerSettingInfo(PlayerSettingInfo.newInstance());
|
||||
|
||||
this.setData(data);
|
||||
|
||||
Reference in New Issue
Block a user