From 610a364b9a7eb927f51c8523aa848605bb973096 Mon Sep 17 00:00:00 2001 From: hamusuke Date: Sun, 16 Oct 2022 00:58:45 +0900 Subject: [PATCH] feat: set friend enter home option (#1860) --- ...SetFriendEnterHomeOptionReqOuterClass.java | 591 ++++++++++++++++++ ...SetFriendEnterHomeOptionRspOuterClass.java | 548 ++++++++++++++++ .../emu/grasscutter/game/home/GameHome.java | 1 + .../emu/grasscutter/game/player/Player.java | 3 +- .../HandlerSetFriendEnterHomeOptionReq.java | 23 + .../packet/recv/HandlerTryEnterHomeReq.java | 22 +- .../send/PacketPlayerHomeCompInfoNotify.java | 1 + .../PacketSetFriendEnterHomeOptionRsp.java | 10 + .../packet/send/PacketTryEnterHomeRsp.java | 11 + 9 files changed, 1207 insertions(+), 3 deletions(-) create mode 100644 src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionReqOuterClass.java create mode 100644 src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionRspOuterClass.java create mode 100644 src/main/java/emu/grasscutter/server/packet/recv/HandlerSetFriendEnterHomeOptionReq.java create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketSetFriendEnterHomeOptionRsp.java diff --git a/src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionReqOuterClass.java b/src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionReqOuterClass.java new file mode 100644 index 000000000..52efc13a6 --- /dev/null +++ b/src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionReqOuterClass.java @@ -0,0 +1,591 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: SetFriendEnterHomeOptionReq.proto + +package emu.grasscutter.net.proto; + +public final class SetFriendEnterHomeOptionReqOuterClass { + private SetFriendEnterHomeOptionReqOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SetFriendEnterHomeOptionReqOrBuilder extends + // @@protoc_insertion_point(interface_extends:SetFriendEnterHomeOptionReq) + com.google.protobuf.MessageOrBuilder { + + /** + * .FriendEnterHomeOption option = 7; + * @return The enum numeric value on the wire for option. + */ + int getOptionValue(); + /** + * .FriendEnterHomeOption option = 7; + * @return The option. + */ + emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption getOption(); + } + /** + *
+   * CmdId: 4494
+   * EnetChannelId: 0
+   * EnetIsReliable: true
+   * IsAllowClient: true
+   * 
+ * + * Protobuf type {@code SetFriendEnterHomeOptionReq} + */ + public static final class SetFriendEnterHomeOptionReq extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SetFriendEnterHomeOptionReq) + SetFriendEnterHomeOptionReqOrBuilder { + private static final long serialVersionUID = 0L; + // Use SetFriendEnterHomeOptionReq.newBuilder() to construct. + private SetFriendEnterHomeOptionReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SetFriendEnterHomeOptionReq() { + option_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SetFriendEnterHomeOptionReq(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SetFriendEnterHomeOptionReq( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 56: { + int rawValue = input.readEnum(); + + option_ = rawValue; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.internal_static_SetFriendEnterHomeOptionReq_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.internal_static_SetFriendEnterHomeOptionReq_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.class, emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.Builder.class); + } + + public static final int OPTION_FIELD_NUMBER = 7; + private int option_; + /** + * .FriendEnterHomeOption option = 7; + * @return The enum numeric value on the wire for option. + */ + @java.lang.Override public int getOptionValue() { + return option_; + } + /** + * .FriendEnterHomeOption option = 7; + * @return The option. + */ + @java.lang.Override public emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption getOption() { + @SuppressWarnings("deprecation") + emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption result = emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.valueOf(option_); + return result == null ? emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (option_ != emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_NEED_CONFIRM.getNumber()) { + output.writeEnum(7, option_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (option_ != emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_NEED_CONFIRM.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(7, option_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq other = (emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq) obj; + + if (option_ != other.option_) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OPTION_FIELD_NUMBER; + hash = (53 * hash) + option_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * CmdId: 4494
+     * EnetChannelId: 0
+     * EnetIsReliable: true
+     * IsAllowClient: true
+     * 
+ * + * Protobuf type {@code SetFriendEnterHomeOptionReq} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SetFriendEnterHomeOptionReq) + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReqOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.internal_static_SetFriendEnterHomeOptionReq_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.internal_static_SetFriendEnterHomeOptionReq_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.class, emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + option_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.internal_static_SetFriendEnterHomeOptionReq_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq getDefaultInstanceForType() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq build() { + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq buildPartial() { + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq result = new emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq(this); + result.option_ = option_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq) { + return mergeFrom((emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq other) { + if (other == emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.getDefaultInstance()) return this; + if (other.option_ != 0) { + setOptionValue(other.getOptionValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int option_ = 0; + /** + * .FriendEnterHomeOption option = 7; + * @return The enum numeric value on the wire for option. + */ + @java.lang.Override public int getOptionValue() { + return option_; + } + /** + * .FriendEnterHomeOption option = 7; + * @param value The enum numeric value on the wire for option to set. + * @return This builder for chaining. + */ + public Builder setOptionValue(int value) { + + option_ = value; + onChanged(); + return this; + } + /** + * .FriendEnterHomeOption option = 7; + * @return The option. + */ + @java.lang.Override + public emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption getOption() { + @SuppressWarnings("deprecation") + emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption result = emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.valueOf(option_); + return result == null ? emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.UNRECOGNIZED : result; + } + /** + * .FriendEnterHomeOption option = 7; + * @param value The option to set. + * @return This builder for chaining. + */ + public Builder setOption(emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.FriendEnterHomeOption value) { + if (value == null) { + throw new NullPointerException(); + } + + option_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .FriendEnterHomeOption option = 7; + * @return This builder for chaining. + */ + public Builder clearOption() { + + option_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SetFriendEnterHomeOptionReq) + } + + // @@protoc_insertion_point(class_scope:SetFriendEnterHomeOptionReq) + private static final emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq(); + } + + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SetFriendEnterHomeOptionReq parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SetFriendEnterHomeOptionReq(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SetFriendEnterHomeOptionReq_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SetFriendEnterHomeOptionReq_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n!SetFriendEnterHomeOptionReq.proto\032\033Fri" + + "endEnterHomeOption.proto\"E\n\033SetFriendEnt" + + "erHomeOptionReq\022&\n\006option\030\007 \001(\0162\026.Friend" + + "EnterHomeOptionB\033\n\031emu.grasscutter.net.p" + + "rotob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.getDescriptor(), + }); + internal_static_SetFriendEnterHomeOptionReq_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SetFriendEnterHomeOptionReq_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SetFriendEnterHomeOptionReq_descriptor, + new java.lang.String[] { "Option", }); + emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionRspOuterClass.java b/src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionRspOuterClass.java new file mode 100644 index 000000000..299894027 --- /dev/null +++ b/src/generated/main/java/emu/grasscutter/net/proto/SetFriendEnterHomeOptionRspOuterClass.java @@ -0,0 +1,548 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: SetFriendEnterHomeOptionRsp.proto + +package emu.grasscutter.net.proto; + +public final class SetFriendEnterHomeOptionRspOuterClass { + private SetFriendEnterHomeOptionRspOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SetFriendEnterHomeOptionRspOrBuilder extends + // @@protoc_insertion_point(interface_extends:SetFriendEnterHomeOptionRsp) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 retcode = 1; + * @return The retcode. + */ + int getRetcode(); + } + /** + *
+   * CmdId: 4743
+   * EnetChannelId: 0
+   * EnetIsReliable: true
+   * 
+ * + * Protobuf type {@code SetFriendEnterHomeOptionRsp} + */ + public static final class SetFriendEnterHomeOptionRsp extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:SetFriendEnterHomeOptionRsp) + SetFriendEnterHomeOptionRspOrBuilder { + private static final long serialVersionUID = 0L; + // Use SetFriendEnterHomeOptionRsp.newBuilder() to construct. + private SetFriendEnterHomeOptionRsp(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SetFriendEnterHomeOptionRsp() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SetFriendEnterHomeOptionRsp(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SetFriendEnterHomeOptionRsp( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + retcode_ = input.readInt32(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.internal_static_SetFriendEnterHomeOptionRsp_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.internal_static_SetFriendEnterHomeOptionRsp_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.class, emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.Builder.class); + } + + public static final int RETCODE_FIELD_NUMBER = 1; + private int retcode_; + /** + * int32 retcode = 1; + * @return The retcode. + */ + @java.lang.Override + public int getRetcode() { + return retcode_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (retcode_ != 0) { + output.writeInt32(1, retcode_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (retcode_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, retcode_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp)) { + return super.equals(obj); + } + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp other = (emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp) obj; + + if (getRetcode() + != other.getRetcode()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RETCODE_FIELD_NUMBER; + hash = (53 * hash) + getRetcode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * CmdId: 4743
+     * EnetChannelId: 0
+     * EnetIsReliable: true
+     * 
+ * + * Protobuf type {@code SetFriendEnterHomeOptionRsp} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:SetFriendEnterHomeOptionRsp) + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRspOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.internal_static_SetFriendEnterHomeOptionRsp_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.internal_static_SetFriendEnterHomeOptionRsp_fieldAccessorTable + .ensureFieldAccessorsInitialized( + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.class, emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.Builder.class); + } + + // Construct using emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + retcode_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.internal_static_SetFriendEnterHomeOptionRsp_descriptor; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp getDefaultInstanceForType() { + return emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.getDefaultInstance(); + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp build() { + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp buildPartial() { + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp result = new emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp(this); + result.retcode_ = retcode_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp) { + return mergeFrom((emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp other) { + if (other == emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp.getDefaultInstance()) return this; + if (other.getRetcode() != 0) { + setRetcode(other.getRetcode()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int retcode_ ; + /** + * int32 retcode = 1; + * @return The retcode. + */ + @java.lang.Override + public int getRetcode() { + return retcode_; + } + /** + * int32 retcode = 1; + * @param value The retcode to set. + * @return This builder for chaining. + */ + public Builder setRetcode(int value) { + + retcode_ = value; + onChanged(); + return this; + } + /** + * int32 retcode = 1; + * @return This builder for chaining. + */ + public Builder clearRetcode() { + + retcode_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:SetFriendEnterHomeOptionRsp) + } + + // @@protoc_insertion_point(class_scope:SetFriendEnterHomeOptionRsp) + private static final emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp(); + } + + public static emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SetFriendEnterHomeOptionRsp parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SetFriendEnterHomeOptionRsp(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public emu.grasscutter.net.proto.SetFriendEnterHomeOptionRspOuterClass.SetFriendEnterHomeOptionRsp getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_SetFriendEnterHomeOptionRsp_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_SetFriendEnterHomeOptionRsp_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n!SetFriendEnterHomeOptionRsp.proto\".\n\033S" + + "etFriendEnterHomeOptionRsp\022\017\n\007retcode\030\001 " + + "\001(\005B\033\n\031emu.grasscutter.net.protob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_SetFriendEnterHomeOptionRsp_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SetFriendEnterHomeOptionRsp_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_SetFriendEnterHomeOptionRsp_descriptor, + new java.lang.String[] { "Retcode", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/emu/grasscutter/game/home/GameHome.java b/src/main/java/emu/grasscutter/game/home/GameHome.java index 7fb306491..dcbe853b9 100644 --- a/src/main/java/emu/grasscutter/game/home/GameHome.java +++ b/src/main/java/emu/grasscutter/game/home/GameHome.java @@ -38,6 +38,7 @@ public class GameHome { List furnitureMakeSlotItemList; ConcurrentHashMap sceneMap; Set unlockedHomeBgmList; + int enterHomeOption; public void save() { DatabaseHelper.saveHome(this); diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 7261af269..26aa4ea23 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -939,7 +939,8 @@ public class Player { .setIsShowAvatar(this.isShowAvatars()) .addAllShowAvatarInfoList(socialShowAvatarInfoList) .addAllShowNameCardIdList(this.getShowNameCardInfoList()) - .setFinishAchievementNum(0); + .setFinishAchievementNum(0) + .setFriendEnterHomeOptionValue(this.getHome() == null ? 0 : this.getHome().getEnterHomeOption()); return social; } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetFriendEnterHomeOptionReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetFriendEnterHomeOptionReq.java new file mode 100644 index 000000000..b2f4d6e54 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetFriendEnterHomeOptionReq.java @@ -0,0 +1,23 @@ +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.SetFriendEnterHomeOptionReqOuterClass; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketPlayerHomeCompInfoNotify; +import emu.grasscutter.server.packet.send.PacketSetFriendEnterHomeOptionRsp; + +@Opcodes(PacketOpcodes.SetFriendEnterHomeOptionReq) +public class HandlerSetFriendEnterHomeOptionReq extends PacketHandler { + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + var req = SetFriendEnterHomeOptionReqOuterClass.SetFriendEnterHomeOptionReq.parseFrom(payload); + + session.getPlayer().getHome().setEnterHomeOption(req.getOptionValue()); + session.getPlayer().getHome().save(); + + session.send(new PacketPlayerHomeCompInfoNotify(session.getPlayer())); + session.send(new PacketSetFriendEnterHomeOptionRsp()); + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index a4fd488f2..108a349b5 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -1,9 +1,12 @@ package emu.grasscutter.server.packet.recv; +import emu.grasscutter.game.home.GameHome; import emu.grasscutter.game.world.Scene; import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.TryEnterHomeReqOuterClass; import emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType; import emu.grasscutter.server.game.GameSession; @@ -15,11 +18,26 @@ public class HandlerTryEnterHomeReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - TryEnterHomeReqOuterClass.TryEnterHomeReq req = - TryEnterHomeReqOuterClass.TryEnterHomeReq.parseFrom(payload); + var req = TryEnterHomeReqOuterClass.TryEnterHomeReq.parseFrom(payload); + var targetPlayer = session.getServer().getPlayerByUid(req.getTargetUid(), true); 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 + var targetHome = GameHome.getByUid(req.getTargetUid()); + switch (targetHome.getEnterHomeOption()) { + case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_NEED_CONFIRM_VALUE: + if (!targetPlayer.isOnline()) { + session.send(new PacketTryEnterHomeRsp(RetcodeOuterClass.Retcode.RET_HOME_OWNER_OFFLINE_VALUE, req.getTargetUid())); + return; + } + break; + case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE: + session.send(new PacketTryEnterHomeRsp(RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, req.getTargetUid())); + return; + case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE: + break; + } + session.send(new PacketTryEnterHomeRsp()); return; } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerHomeCompInfoNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerHomeCompInfoNotify.java index 29a6964b5..b5517df45 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerHomeCompInfoNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerHomeCompInfoNotify.java @@ -23,6 +23,7 @@ public class PacketPlayerHomeCompInfoNotify extends BasePacket { PlayerHomeCompInfoOuterClass.PlayerHomeCompInfo.newBuilder() .addAllUnlockedModuleIdList(player.getRealmList()) .addAllLevelupRewardGotLevelList(List.of(1)) // Hardcoded + .setFriendEnterHomeOptionValue(player.getHome().getEnterHomeOption()) .build() ) .build(); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSetFriendEnterHomeOptionRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSetFriendEnterHomeOptionRsp.java new file mode 100644 index 000000000..240c49179 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSetFriendEnterHomeOptionRsp.java @@ -0,0 +1,10 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.BasePacket; +import emu.grasscutter.net.packet.PacketOpcodes; + +public class PacketSetFriendEnterHomeOptionRsp extends BasePacket { + public PacketSetFriendEnterHomeOptionRsp() { + super(PacketOpcodes.SetFriendEnterHomeOptionRsp); + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketTryEnterHomeRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketTryEnterHomeRsp.java index 369c44140..e6b3b2a86 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketTryEnterHomeRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketTryEnterHomeRsp.java @@ -27,4 +27,15 @@ public class PacketTryEnterHomeRsp extends BasePacket { this.setData(proto); } + + public PacketTryEnterHomeRsp(int retCode, int uid) { + super(PacketOpcodes.TryEnterHomeRsp); + + TryEnterHomeRspOuterClass.TryEnterHomeRsp proto = TryEnterHomeRspOuterClass.TryEnterHomeRsp.newBuilder() + .setRetcode(retCode) + .setTargetUid(uid) + .build(); + + this.setData(proto); + } }