diff --git a/.gitignore b/.gitignore index ebb48dcaa..77647f08c 100644 --- a/.gitignore +++ b/.gitignore @@ -56,9 +56,10 @@ resources/* logs/* data/AbilityEmbryos.json data/OpenConfig.json -proto/* GM Handbook.txt config.json mitmdump.exe -grasscutter.jar -mongod.exe \ No newline at end of file +*.jar +mongod.exe +/src/generated/ +/*.sh \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fbab9b375..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Grasscutter-Protos"] - path = Grasscutter-Protos - url = https://github.com/Melledy/Grasscutter-Protos diff --git a/Grasscutter-Protos b/Grasscutter-Protos deleted file mode 160000 index 0537e9cc4..000000000 --- a/Grasscutter-Protos +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0537e9cc4c7856a7c6f88bbbaa908a80c4ee677e diff --git a/build.gradle b/build.gradle index 1be86626c..d9f616ca9 100644 --- a/build.gradle +++ b/build.gradle @@ -6,10 +6,23 @@ * User Manual available at https://docs.gradle.org/5.6.3/userguide/tutorial_java_projects.html */ +buildscript { + repositories { + maven { url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' + } +} + plugins { // Apply the java plugin to add support for Java id 'java' + // Apply the protobuf auto generator + id 'com.google.protobuf' version "0.8.18" + id 'idea' + // Apply the application plugin to add support for building a CLI application id 'application' @@ -17,6 +30,10 @@ plugins { id 'signing' } + +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 + group = 'tech.xigam' version = '1.0.0-dev' @@ -34,7 +51,7 @@ repositories { dependencies { implementation fileTree(dir: 'lib', include: ['*.jar']) - + implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.32' implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.9' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9' @@ -49,6 +66,9 @@ dependencies { implementation group: 'org.greenrobot', name: 'eventbus-java', version: '3.3.1' implementation group: 'org.danilopianini', name: 'java-quadtree', version: '0.1.9' + + protobuf files('proto/') + } application { @@ -125,13 +145,47 @@ publishing { def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - + name = 'sonatype' credentials(PasswordCredentials) } } } +clean { + delete protobuf.generatedFilesBaseDir +} + +protobuf { + protoc { + // The artifact spec for the Protobuf Compiler + artifact = 'com.google.protobuf:protoc:3.18.1' + } +// generatedFilesBaseDir = "$projectDir/src/main/java/emu/grasscutter/net/proto/" + generatedFilesBaseDir = "$projectDir/src/generated/" +} + +sourceSets { + main { + proto { + // In addition to the default 'src/main/proto' + srcDir 'src/generated' + } + java { + srcDir 'src/java' + } + } +} + +idea { + module { + // proto files and generated Java files are automatically added as + // source dirs. + // If you have additional sources, add them here: + sourceDirs += file("/proto/"); + } +} + signing { sign publishing.publications.mavenJava } diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index da9facfd3..57d0ea824 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -140,7 +140,7 @@ public class ResourceLoader { } List scenePointList = new ArrayList<>(); - for (File file : folder.listFiles()) { + for (File file : Objects.requireNonNull(folder.listFiles())) { ScenePointConfig config = null; Integer sceneId = null; @@ -190,7 +190,7 @@ public class ResourceLoader { } else { // Load from BinOutput Pattern pattern = Pattern.compile("(?<=ConfigAvatar_)(.*?)(?=.json)"); - + embryoList = new LinkedList<>(); File folder = new File(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "BinOutput/Avatar/")); File[] files = folder.listFiles(); @@ -198,29 +198,29 @@ public class ResourceLoader { Grasscutter.getLogger().error("Error loading ability embryos: no files found in " + folder.getAbsolutePath()); return; } - + for (File file : files) { AvatarConfig config; String avatarName; - + Matcher matcher = pattern.matcher(file.getName()); if (matcher.find()) { avatarName = matcher.group(0); } else { continue; } - + try (FileReader fileReader = new FileReader(file)) { config = Grasscutter.getGsonFactory().fromJson(fileReader, AvatarConfig.class); } catch (Exception e) { e.printStackTrace(); continue; } - + if (config.abilities == null) { continue; } - + int s = config.abilities.size(); AbilityEmbryoEntry al = new AbilityEmbryoEntry(avatarName, config.abilities.stream().map(Object::toString).toArray(size -> new String[s])); embryoList.add(al); @@ -331,7 +331,7 @@ public class ResourceLoader { GenshinData.getOpenConfigEntries().put(entry.getName(), entry); } } - + // BinOutput configs private static class AvatarConfig { diff --git a/src/main/java/emu/grasscutter/data/def/CombineData.java b/src/main/java/emu/grasscutter/data/def/CombineData.java new file mode 100644 index 000000000..c4c19794f --- /dev/null +++ b/src/main/java/emu/grasscutter/data/def/CombineData.java @@ -0,0 +1,10 @@ +package emu.grasscutter.data.def; + +import emu.grasscutter.data.ResourceType; + +@ResourceType(name = "CombineExcelConfigData.json") +public class CombineData { + + + +} diff --git a/src/main/java/emu/grasscutter/game/GenshinPlayer.java b/src/main/java/emu/grasscutter/game/GenshinPlayer.java index 95edb99b6..eac10a0cc 100644 --- a/src/main/java/emu/grasscutter/game/GenshinPlayer.java +++ b/src/main/java/emu/grasscutter/game/GenshinPlayer.java @@ -27,9 +27,10 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType; import emu.grasscutter.net.proto.MpSettingTypeOuterClass.MpSettingType; import emu.grasscutter.net.proto.OnlinePlayerInfoOuterClass.OnlinePlayerInfo; import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason; +import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass; import emu.grasscutter.net.proto.PlayerLocationInfoOuterClass.PlayerLocationInfo; +import emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass; import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; -import emu.grasscutter.net.proto.WorldPlayerLocationInfoOuterClass.WorldPlayerLocationInfo; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.*; @@ -70,7 +71,7 @@ public class GenshinPlayer { private TeamManager teamManager; private PlayerGachaInfo gachaInfo; private PlayerProfile playerProfile; - private MpSettingType mpSetting = MpSettingType.MpSettingEnterAfterApply; + private MpSettingType mpSetting = MpSettingType.MP_SETTING_ENTER_AFTER_APPLY; private boolean showAvatar; private ArrayList shownAvatars; private Set rewardedLevels; @@ -587,7 +588,7 @@ public class GenshinPlayer { // Add to inventory boolean success = getInventory().addItem(item); if (success) { - this.sendPacket(new PacketGadgetInteractRsp(drop, InteractType.InteractPickItem)); + this.sendPacket(new PacketGadgetInteractRsp(drop, InteractType.INTERACT_PICK_ITEM)); this.sendPacket(new PacketItemAddHintNotify(item, ActionReason.SubfieldDrop)); } } @@ -617,7 +618,7 @@ public class GenshinPlayer { .setMpSettingType(this.getMpSetting()) .setNameCardId(this.getNameCardId()) .setSignature(this.getSignature()) - .setAvatar(HeadImage.newBuilder().setAvatarId(this.getHeadImage())); + .setAvatarId(HeadImage.newBuilder().setAvatarId(this.getHeadImage()).getAvatarId()); if (this.getWorld() != null) { onlineInfo.setCurPlayerNumInWorld(this.getWorld().getPlayers().indexOf(this) + 1); @@ -652,21 +653,19 @@ public class GenshinPlayer { public SocialDetail.Builder getSocialDetail() { SocialDetail.Builder social = SocialDetail.newBuilder() .setUid(this.getUid()) - .setAvatar(HeadImage.newBuilder().setAvatarId(this.getHeadImage())) + .setAvatarId(HeadImage.newBuilder().setAvatarId(this.getHeadImage()).getAvatarId()) .setNickname(this.getNickname()) .setSignature(this.getSignature()) .setLevel(this.getLevel()) .setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty()) .setWorldLevel(this.getWorldLevel()) - .setUnk1(1) - .setUnk3(1) .setNameCardId(this.getNameCardId()) .setFinishAchievementNum(0); return social; } - - public WorldPlayerLocationInfo getWorldPlayerLocationInfo() { - return WorldPlayerLocationInfo.newBuilder() + + public PlayerWorldLocationInfoOuterClass.PlayerWorldLocationInfo getWorldPlayerLocationInfo() { + return PlayerWorldLocationInfoOuterClass.PlayerWorldLocationInfo.newBuilder() .setSceneId(this.getSceneId()) .setPlayerLoc(this.getPlayerLocationInfo()) .build(); @@ -691,7 +690,7 @@ public class GenshinPlayer { while (it.hasNext()) { CoopRequest req = it.next(); if (req.isExpired()) { - req.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(this, false, PlayerApplyEnterMpReason.SystemJudge)); + req.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(this, false, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.SYSTEM_JUDGE)); it.remove(); } } diff --git a/src/main/java/emu/grasscutter/game/GenshinScene.java b/src/main/java/emu/grasscutter/game/GenshinScene.java index 431134b5f..6f8591348 100644 --- a/src/main/java/emu/grasscutter/game/GenshinScene.java +++ b/src/main/java/emu/grasscutter/game/GenshinScene.java @@ -202,7 +202,7 @@ public class GenshinScene { private void removePlayerAvatars(GenshinPlayer player) { Iterator it = player.getTeamManager().getActiveTeam().iterator(); while (it.hasNext()) { - this.removeEntity(it.next(), VisionType.VisionRemove); + this.removeEntity(it.next(), VisionType.VISION_REMOVE); it.remove(); } } @@ -233,7 +233,7 @@ public class GenshinScene { this.addEntityDirectly(entity); } - this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VisionBorn)); + this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_BORN)); } private GenshinEntity removeEntityDirectly(GenshinEntity entity) { @@ -241,7 +241,7 @@ public class GenshinScene { } public void removeEntity(GenshinEntity entity) { - this.removeEntity(entity, VisionType.VisionDie); + this.removeEntity(entity, VisionType.VISION_DIE); } public synchronized void removeEntity(GenshinEntity entity, VisionType visionType) { @@ -254,8 +254,8 @@ public class GenshinScene { public synchronized void replaceEntity(EntityAvatar oldEntity, EntityAvatar newEntity) { this.removeEntityDirectly(oldEntity); this.addEntityDirectly(newEntity); - this.broadcastPacket(new PacketSceneEntityDisappearNotify(oldEntity, VisionType.VisionReplace)); - this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VisionReplace, oldEntity.getId())); + this.broadcastPacket(new PacketSceneEntityDisappearNotify(oldEntity, VisionType.VISION_REPLACE)); + this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VISION_REPLACE, oldEntity.getId())); } public void showOtherEntities(GenshinPlayer player) { @@ -269,7 +269,7 @@ public class GenshinScene { entities.add(entity); } - player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VisionMeet)); + player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_MEET)); } public void handleAttack(AttackResult result) { @@ -381,11 +381,11 @@ public class GenshinScene { if (toAdd.size() > 0) { toAdd.stream().forEach(this::addEntityDirectly); - this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VisionBorn)); + this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_BORN)); } if (toRemove.size() > 0) { toRemove.stream().forEach(this::removeEntityDirectly); - this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VisionRemove)); + this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_REMOVE)); } } @@ -425,7 +425,7 @@ public class GenshinScene { return; } - this.broadcastPacketToOthers(gadget.getOwner(), new PacketSceneEntityDisappearNotify(gadget, VisionType.VisionDie)); + this.broadcastPacketToOthers(gadget.getOwner(), new PacketSceneEntityDisappearNotify(gadget, VisionType.VISION_DIE)); } // Broadcasting diff --git a/src/main/java/emu/grasscutter/game/InvokeHandler.java b/src/main/java/emu/grasscutter/game/InvokeHandler.java index 727f93509..b8272d30b 100644 --- a/src/main/java/emu/grasscutter/game/InvokeHandler.java +++ b/src/main/java/emu/grasscutter/game/InvokeHandler.java @@ -20,18 +20,11 @@ public class InvokeHandler { public synchronized void addEntry(ForwardType forward, T entry) { switch (forward) { - case ForwardToAll: - entryListForwardAll.add(entry); - break; - case ForwardToAllExceptCur: - case ForwardToAllExistExceptCur: - entryListForwardAllExceptCur.add(entry); - break; - case ForwardToHost: - entryListForwardHost.add(entry); - break; - default: - break; + case FORWARD_TO_ALL -> entryListForwardAll.add(entry); + case FORWARD_TO_ALL_EXCEPT_CUR, FORWARD_TO_ALL_EXIST_EXCEPT_CUR -> entryListForwardAllExceptCur.add(entry); + case FORWARD_TO_HOST -> entryListForwardHost.add(entry); + default -> { + } } } diff --git a/src/main/java/emu/grasscutter/game/TeamManager.java b/src/main/java/emu/grasscutter/game/TeamManager.java index 6cd447d49..c32d3edfb 100644 --- a/src/main/java/emu/grasscutter/game/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/TeamManager.java @@ -397,7 +397,7 @@ public class TeamManager { this.setCurrentCharacterIndex(index); // Old entity motion state - oldEntity.setMotionState(MotionState.MotionStandby); + oldEntity.setMotionState(MotionState.MOTION_STANDBY); // Remove and Add getPlayer().getScene().replaceEntity(oldEntity, newEntity); @@ -476,7 +476,7 @@ public class TeamManager { } // Teleport player - getPlayer().sendPacket(new PacketPlayerEnterSceneNotify(getPlayer(), EnterType.EnterSelf, EnterReason.Revival, 3, GenshinConstants.START_POSITION)); + getPlayer().sendPacket(new PacketPlayerEnterSceneNotify(getPlayer(), EnterType.ENTER_SELF, EnterReason.Revival, 3, GenshinConstants.START_POSITION)); // Set player position player.setSceneId(3); diff --git a/src/main/java/emu/grasscutter/game/World.java b/src/main/java/emu/grasscutter/game/World.java index 9dd6b6905..eefaabc16 100644 --- a/src/main/java/emu/grasscutter/game/World.java +++ b/src/main/java/emu/grasscutter/game/World.java @@ -64,7 +64,7 @@ public class World implements Iterable { this.levelEntityId = getNextEntityId(EntityIdType.MPLEVEL); this.worldLevel = player.getWorldLevel(); this.isMultiplayer = isMultiplayer; - + this.owner.getServer().registerWorld(this); } @@ -197,7 +197,7 @@ public class World implements Iterable { World world = new World(victim); world.addPlayer(victim); - victim.sendPacket(new PacketPlayerEnterSceneNotify(victim, EnterType.EnterSelf, EnterReason.TeamKick, victim.getSceneId(), victim.getPos())); + victim.sendPacket(new PacketPlayerEnterSceneNotify(victim, EnterType.ENTER_SELF, EnterReason.TeamKick, victim.getSceneId(), victim.getPos())); } } } @@ -219,12 +219,12 @@ public class World implements Iterable { if (player.getScene() != null) { oldScene = player.getScene(); - + // Dont deregister scenes if the player is going to tp back into them if (oldScene.getId() == sceneId) { oldScene.setDontDestroyWhenEmpty(true); } - + oldScene.removePlayer(player); } @@ -235,12 +235,12 @@ public class World implements Iterable { if (oldScene != null) { oldScene.setDontDestroyWhenEmpty(false); } - + // Teleport packet if (oldScene == newScene) { - player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterGoto, EnterReason.TransPoint, sceneId, pos)); + player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.ENTER_GOTO, EnterReason.TransPoint, sceneId, pos)); } else { - player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterJump, EnterReason.TransPoint, sceneId, pos)); + player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.ENTER_JUMP, EnterReason.TransPoint, sceneId, pos)); } return true; } @@ -281,7 +281,7 @@ public class World implements Iterable { scene.onTick(); } } - + public void close() { } diff --git a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java index b6007e280..a68e2683e 100644 --- a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java @@ -778,7 +778,7 @@ public class GenshinAvatar { .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) .putAllSkillLevelMap(this.getSkillLevelMap()) .addAllInherentProudSkillList(this.getProudSkillList()) - .putAllProudSkillExtraLevel(getProudSkillBonusMap()) + .putAllProudSkillExtraLevelMap(getProudSkillBonusMap()) .setAvatarType(1) .setBornTime(this.getBornTime()) .setFetterInfo(avatarFetter) diff --git a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java index 233da5288..7788f932a 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java @@ -101,13 +101,13 @@ public class EntityAvatar extends GenshinEntity { @Override public void onDeath(int killerId) { - this.killedType = PlayerDieType.PlayerDieKillByMonster; + this.killedType = PlayerDieType.PLAYER_DIE_KILL_BY_MONSTER; this.killedBy = killerId; } public SceneAvatarInfo getSceneAvatarInfo() { SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder() - .setPlayerId(this.getPlayer().getUid()) + .setUid(this.getPlayer().getUid()) .setAvatarId(this.getAvatar().getAvatarId()) .setGuid(this.getAvatar().getGuid()) .setPeerId(this.getPlayer().getPeerId()) @@ -145,7 +145,7 @@ public class EntityAvatar extends GenshinEntity { SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() .setEntityId(getId()) - .setEntityType(ProtEntityType.ProtEntityAvatar) + .setEntityType(ProtEntityType.PROT_ENTITY_AVATAR) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .setEntityClientData(EntityClientData.newBuilder()) .setEntityAuthorityInfo(authority) @@ -161,7 +161,7 @@ public class EntityAvatar extends GenshinEntity { if (entry.getIntKey() == 0) { continue; } - FightPropPair fightProp = FightPropPair.newBuilder().setType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build(); + FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build(); entityInfo.addFightPropList(fightProp); } diff --git a/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java b/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java index 5fbd26502..04f045c03 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java @@ -6,6 +6,7 @@ import emu.grasscutter.game.World; import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; import emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair; +import emu.grasscutter.net.proto.ClientGadgetInfoOuterClass; import emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo; import emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData; import emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo; @@ -112,7 +113,7 @@ public class EntityClientGadget extends EntityGadget { SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() .setEntityId(getId()) - .setEntityType(ProtEntityType.ProtEntityGadget) + .setEntityType(ProtEntityType.PROT_ENTITY_GADGET) .setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder())) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .setEntityClientData(EntityClientData.newBuilder()) @@ -125,7 +126,7 @@ public class EntityClientGadget extends EntityGadget { .build(); entityInfo.addPropList(pair); - GadgetClientParam clientGadget = GadgetClientParam.newBuilder() + ClientGadgetInfoOuterClass.ClientGadgetInfo clientGadget = ClientGadgetInfoOuterClass.ClientGadgetInfo.newBuilder() .setCampId(this.getCampId()) .setCampType(this.getCampType()) .setOwnerEntityId(this.getOwnerEntityId()) diff --git a/src/main/java/emu/grasscutter/game/entity/EntityItem.java b/src/main/java/emu/grasscutter/game/entity/EntityItem.java index ba1188f13..ebd8051e6 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityItem.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityItem.java @@ -92,7 +92,7 @@ public class EntityItem extends EntityGadget { SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() .setEntityId(getId()) - .setEntityType(ProtEntityType.ProtEntityGadget) + .setEntityType(ProtEntityType.PROT_ENTITY_GADGET) .setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder())) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .setEntityClientData(EntityClientData.newBuilder()) @@ -108,7 +108,7 @@ public class EntityItem extends EntityGadget { SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder() .setGadgetId(this.getItemData().getGadgetId()) .setTrifleItem(this.getItem().toProto()) - .setBornType(GadgetBornType.GadgetBornInAir) + .setBornType(GadgetBornType.GADGET_BORN_IN_AIR) .setAuthorityPeerId(this.getWorld().getHostPeerId()) .setIsEnableInteract(true); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityMonster.java b/src/main/java/emu/grasscutter/game/entity/EntityMonster.java index 754def22c..a1900f5c9 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityMonster.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityMonster.java @@ -197,7 +197,7 @@ public class EntityMonster extends GenshinEntity { SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() .setEntityId(getId()) - .setEntityType(ProtEntityType.ProtEntityMonster) + .setEntityType(ProtEntityType.PROT_ENTITY_MONSTER) .setMotionInfo(this.getMotionInfo()) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .setEntityClientData(EntityClientData.newBuilder()) @@ -208,7 +208,7 @@ public class EntityMonster extends GenshinEntity { if (entry.getIntKey() == 0) { continue; } - FightPropPair fightProp = FightPropPair.newBuilder().setType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build(); + FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build(); entityInfo.addFightPropList(fightProp); } @@ -226,7 +226,7 @@ public class EntityMonster extends GenshinEntity { .setAuthorityPeerId(getWorld().getHostPeerId()) .setPoseId(this.getPoseId()) .setBlockId(3001) - .setBornType(MonsterBornType.MonsterBornDefault) + .setBornType(MonsterBornType.MONSTER_BORN_DEFAULT) .setSpecialNameId(40); if (getMonsterData().getDescribeData() != null) { @@ -240,7 +240,7 @@ public class EntityMonster extends GenshinEntity { .setAbilityInfo(AbilitySyncStateInfo.newBuilder()) .build(); - monsterInfo.setWeaponList(weaponInfo); + monsterInfo.addWeaponList(weaponInfo); } entityInfo.setMonster(monsterInfo); diff --git a/src/main/java/emu/grasscutter/game/entity/GenshinEntity.java b/src/main/java/emu/grasscutter/game/entity/GenshinEntity.java index a65d30f07..c766f493c 100644 --- a/src/main/java/emu/grasscutter/game/entity/GenshinEntity.java +++ b/src/main/java/emu/grasscutter/game/entity/GenshinEntity.java @@ -23,7 +23,7 @@ public abstract class GenshinEntity { public GenshinEntity(GenshinScene scene) { this.scene = scene; - this.moveState = MotionState.MotionNone; + this.moveState = MotionState.MOTION_NONE; } public int getId() { diff --git a/src/main/java/emu/grasscutter/game/friends/FriendsList.java b/src/main/java/emu/grasscutter/game/friends/FriendsList.java index 45a11fb1c..c7756763c 100644 --- a/src/main/java/emu/grasscutter/game/friends/FriendsList.java +++ b/src/main/java/emu/grasscutter/game/friends/FriendsList.java @@ -104,7 +104,7 @@ public class FriendsList { } // Handle - if (result == DealAddFriendResultType.DealAddFriendAccept) { // Request accepted + if (result == DealAddFriendResultType.DEAL_ADD_FRIEND_ACCEPT) { // Request accepted myFriendship.setIsFriend(true); theirFriendship.setIsFriend(true); diff --git a/src/main/java/emu/grasscutter/game/friends/Friendship.java b/src/main/java/emu/grasscutter/game/friends/Friendship.java index 28561dc39..81d219901 100644 --- a/src/main/java/emu/grasscutter/game/friends/Friendship.java +++ b/src/main/java/emu/grasscutter/game/friends/Friendship.java @@ -1,5 +1,6 @@ package emu.grasscutter.game.friends; +import emu.grasscutter.net.proto.PlatformTypeOuterClass; import org.bson.types.ObjectId; import dev.morphia.annotations.*; @@ -91,16 +92,16 @@ public class Friendship { .setUid(getFriendProfile().getUid()) .setNickname(getFriendProfile().getName()) .setLevel(getFriendProfile().getPlayerLevel()) - .setAvatar(HeadImage.newBuilder().setAvatarId(getFriendProfile().getAvatarId())) + .setAvatarId(HeadImage.newBuilder().setAvatarId(getFriendProfile().getAvatarId()).getAvatarId()) .setWorldLevel(getFriendProfile().getWorldLevel()) .setSignature(getFriendProfile().getSignature()) - .setOnlineState(getFriendProfile().isOnline() ? FriendOnlineState.FRIEND_ONLINE : FriendOnlineState.FRIEND_DISCONNECT) + .setOnlineState(getFriendProfile().isOnline() ? FriendOnlineState.FRIEND_ONLINE : FriendOnlineState.FREIEND_DISCONNECT) .setIsMpModeAvailable(true) .setLastActiveTime(getFriendProfile().getLastActiveTime()) .setNameCardId(getFriendProfile().getNameCard()) .setParam(getFriendProfile().getDaysSinceLogin()) - .setUnk1(1) - .setUnk2(3) + .setIsGameSource(true) + .setPlatformType(PlatformTypeOuterClass.PlatformType.PC) .build(); return proto; diff --git a/src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java b/src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java index 56d629036..e42f7a789 100644 --- a/src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java +++ b/src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java @@ -7,6 +7,7 @@ import emu.grasscutter.game.props.EnterReason; import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType; import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason; import emu.grasscutter.game.World; +import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpNotify; import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpResultNotify; @@ -26,7 +27,7 @@ public class MultiplayerManager { public void applyEnterMp(GenshinPlayer player, int targetUid) { GenshinPlayer target = getServer().getPlayerByUid(targetUid); if (target == null) { - player.sendPacket(new PacketPlayerApplyEnterMpResultNotify(targetUid, "", false, PlayerApplyEnterMpReason.PlayerCannotEnterMp)); + player.sendPacket(new PacketPlayerApplyEnterMpResultNotify(targetUid, "", false, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_CANNOT_ENTER_MP)); return; } @@ -71,12 +72,12 @@ public class MultiplayerManager { // Sanity checks - Dont let the requesting player join if they are already in multiplayer if (requester.getWorld().isMultiplayer()) { - request.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(hostPlayer, false, PlayerApplyEnterMpReason.PlayerCannotEnterMp)); + request.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(hostPlayer, false, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_CANNOT_ENTER_MP)); return; } // Response packet - request.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(hostPlayer, isAgreed, PlayerApplyEnterMpReason.PlayerJudge)); + request.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(hostPlayer, isAgreed, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_JUDGE)); // Declined if (!isAgreed) { @@ -92,7 +93,7 @@ public class MultiplayerManager { world.addPlayer(hostPlayer); // Rejoin packet - hostPlayer.sendPacket(new PacketPlayerEnterSceneNotify(hostPlayer, hostPlayer, EnterType.EnterSelf, EnterReason.HostFromSingleToMp, hostPlayer.getScene().getId(), hostPlayer.getPos())); + hostPlayer.sendPacket(new PacketPlayerEnterSceneNotify(hostPlayer, hostPlayer, EnterType.ENTER_SELF, EnterReason.HostFromSingleToMp, hostPlayer.getScene().getId(), hostPlayer.getPos())); } // Set scene pos and id of requester to the host player's @@ -104,7 +105,7 @@ public class MultiplayerManager { hostPlayer.getWorld().addPlayer(requester); // Packet - requester.sendPacket(new PacketPlayerEnterSceneNotify(requester, hostPlayer, EnterType.EnterOther, EnterReason.TeamJoin, hostPlayer.getScene().getId(), hostPlayer.getPos())); + requester.sendPacket(new PacketPlayerEnterSceneNotify(requester, hostPlayer, EnterType.ENTER_OTHER, EnterReason.TeamJoin, hostPlayer.getScene().getId(), hostPlayer.getPos())); } public boolean leaveCoop(GenshinPlayer player) { @@ -125,7 +126,7 @@ public class MultiplayerManager { world.addPlayer(player); // Packet - player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterSelf, EnterReason.TeamBack, player.getScene().getId(), player.getPos())); + player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.ENTER_SELF, EnterReason.TeamBack, player.getScene().getId(), player.getPos())); return true; } @@ -152,7 +153,7 @@ public class MultiplayerManager { World world = new World(victim); world.addPlayer(victim); - victim.sendPacket(new PacketPlayerEnterSceneNotify(victim, EnterType.EnterSelf, EnterReason.TeamKick, victim.getScene().getId(), victim.getPos())); + victim.sendPacket(new PacketPlayerEnterSceneNotify(victim, EnterType.ENTER_SELF, EnterReason.TeamKick, victim.getScene().getId(), victim.getPos())); return true; } } diff --git a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java index 365055e26..b65bc5e5c 100644 --- a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java +++ b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java @@ -1009,6 +1009,7 @@ public class PacketOpcodes { public static final int SetNameCardRsp = 4009; public static final int SetOpenStateReq = 162; public static final int SetOpenStateRsp = 189; + public static final int SetPlayerBirthdayReq = 4097; public static final int SetPlayerBirthdayRsp = 4088; public static final int SetPlayerBornDataReq = 155; @@ -1034,8 +1035,6 @@ public class PacketOpcodes { public static final int ShowTemplateReminderNotify = 3164; public static final int SignInInfoReq = 2510; public static final int SignInInfoRsp = 2515; - public static final int SitReq = 354; - public static final int SitRsp = 335; public static final int SocialDataNotify = 4063; public static final int SpringUseReq = 1720; public static final int SpringUseRsp = 1727; diff --git a/src/main/java/emu/grasscutter/net/packet/Retcode.java b/src/main/java/emu/grasscutter/net/packet/Retcode.java deleted file mode 100644 index c061a1897..000000000 --- a/src/main/java/emu/grasscutter/net/packet/Retcode.java +++ /dev/null @@ -1,6 +0,0 @@ -package emu.grasscutter.net.packet; - -public class Retcode { - public static final int SUCCESS = 0; - public static final int FAIL = 1; -} diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index 2c6b9f23d..89adfeda0 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -17,7 +17,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; /** - * Manages the server's plugins & the event system. + * Manages the server's plugins and the event system. */ public final class PluginManager { private final Map plugins = new HashMap<>(); diff --git a/src/main/java/emu/grasscutter/plugin/api/PlayerHook.java b/src/main/java/emu/grasscutter/plugin/api/PlayerHook.java index f4a479acb..3f2961e19 100644 --- a/src/main/java/emu/grasscutter/plugin/api/PlayerHook.java +++ b/src/main/java/emu/grasscutter/plugin/api/PlayerHook.java @@ -82,7 +82,7 @@ public final class PlayerHook { public void teleport(Position position) { this.player.getPos().set(position); this.player.sendPacket(new PacketPlayerEnterSceneNotify(this.player, - EnterType.EnterJump, EnterReason.TransPoint, + EnterType.ENTER_JUMP, EnterReason.TransPoint, this.player.getSceneId(), position )); } diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index e8caaaea8..654cf91b3 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -126,10 +126,10 @@ public final class DispatchServer { servers.add(server); RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder() - .setIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty() + .setGateserverIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty() ? Grasscutter.getConfig().getGameServerOptions().Ip : Grasscutter.getConfig().getGameServerOptions().PublicIp)) - .setPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0 + .setGateserverPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0 ? Grasscutter.getConfig().getGameServerOptions().PublicPort : Grasscutter.getConfig().getGameServerOptions().Port) .setSecretKey(ByteString @@ -169,8 +169,8 @@ public final class DispatchServer { servers.add(server); RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder() - .setIp(regionInfo.Ip) - .setPort(regionInfo.Port) + .setGateserverIp(regionInfo.Ip) + .setGateserverPort(regionInfo.Port) .setSecretKey(ByteString .copyFrom(FileUtils.read(Grasscutter.getConfig().KEY_FOLDER + "dispatchSeed.bin"))) .build(); @@ -181,7 +181,7 @@ public final class DispatchServer { } QueryRegionListHttpRsp regionList = QueryRegionListHttpRsp.newBuilder() - .addAllServers(servers) + .addAllRegionList(servers) .setClientSecretKey(rl.getClientSecretKey()) .setClientCustomConfigEncrypted(rl.getClientCustomConfigEncrypted()) .setEnableLoginPc(true) diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index 50d508bed..e6d6564ed 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -89,7 +89,7 @@ public class GameServerPacketHandler { // Log unhandled packets if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) { - //Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode)); + Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + emu.grasscutter.net.packet.PacketOpcodesUtil.getOpcodeName(opcode)); } } } diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index 53b4f32cc..1beea2f3a 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -3,11 +3,14 @@ package emu.grasscutter.server.game; import java.io.File; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.util.HashSet; +import java.util.Set; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.Account; import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodesUtil; import emu.grasscutter.netty.MihoyoKcpChannel; import emu.grasscutter.server.event.game.SendPacketEvent; @@ -177,10 +180,20 @@ public class GameSession extends MihoyoKcpChannel { //Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(opcode)); //System.out.println(Utils.bytesToHex(genshinPacket.getData())); } - + + private static final Set loopPacket = Set.of( + PacketOpcodes.PingReq, + PacketOpcodes.PingRsp, + PacketOpcodes.WorldPlayerRTTNotify, + PacketOpcodes.UnionCmdNotify, + PacketOpcodes.QueryPathReq + ); + private void logPacket(GenshinPacket genshinPacket) { - Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(genshinPacket.getOpcode()) + " (" + genshinPacket.getOpcode() + ")"); - System.out.println(Utils.bytesToHex(genshinPacket.getData())); + if (!loopPacket.contains(genshinPacket.getOpcode())) { + Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(genshinPacket.getOpcode()) + " (" + genshinPacket.getOpcode() + ")"); + System.out.println(Utils.bytesToHex(genshinPacket.getData())); + } } @Override @@ -226,8 +239,10 @@ public class GameSession extends MihoyoKcpChannel { // Log packet if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) { - Grasscutter.getLogger().info("RECV: " + PacketOpcodesUtil.getOpcodeName(opcode) + " (" + opcode + ")"); - System.out.println(Utils.bytesToHex(payload)); + if (!loopPacket.contains(opcode)) { + Grasscutter.getLogger().info("RECV: " + PacketOpcodesUtil.getOpcodeName(opcode) + " (" + opcode + ")"); + System.out.println(Utils.bytesToHex(payload)); + } } // Handle diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java deleted file mode 100644 index 418d99eef..000000000 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java +++ /dev/null @@ -1,24 +0,0 @@ -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.SitReqOuterClass; -import emu.grasscutter.server.game.GameSession; -import emu.grasscutter.server.packet.send.PacketSitRsp; -import emu.grasscutter.utils.Position; - -@Opcodes(PacketOpcodes.SitReq) -public class HandleSitReq extends PacketHandler { - @Override - public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - SitReqOuterClass.SitReq req = SitReqOuterClass.SitReq.parseFrom(payload); - - float x = req.getPosition().getX(); - float y = req.getPosition().getY(); - float z = req.getPosition().getZ(); - - session.send(new PacketSitRsp(req.getChairId(), new Position(x, y, z), session.getPlayer().getTeamManager().getCurrentAvatarEntity().getId())); - } - -} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java index 570c3e981..e06cd51da 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java @@ -19,12 +19,12 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { for (CombatInvokeEntry entry : notif.getInvokeListList()) { switch (entry.getArgumentType()) { - case CombatEvtBeingHit: + case COMBAT_EVT_BEING_HIT: // Handle damage EvtBeingHitInfo hitInfo = EvtBeingHitInfo.parseFrom(entry.getCombatData()); session.getPlayer().getScene().handleAttack(hitInfo.getAttackResult()); break; - case EntityMove: + case ENTITY_MOVE: // Handle movement EntityMoveInfo moveInfo = EntityMoveInfo.parseFrom(entry.getCombatData()); GenshinEntity entity = session.getPlayer().getScene().getEntityById(moveInfo.getEntityId()); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombineReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombineReq.java new file mode 100644 index 000000000..d5ff27a15 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombineReq.java @@ -0,0 +1,20 @@ +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.CombineReqOuterClass; +import emu.grasscutter.server.game.GameSession; + +@Opcodes(PacketOpcodes.CombineReq) +public class HandlerCombineReq extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + + CombineReqOuterClass.CombineReq req = CombineReqOuterClass.CombineReq.parseFrom(payload); + + } + +} + diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMarkMapReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMarkMapReq.java index 60d58e75e..a46aec718 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMarkMapReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMarkMapReq.java @@ -32,7 +32,7 @@ public class HandlerMarkMapReq extends PacketHandler { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { MarkMapReq req = MarkMapReq.parseFrom(payload); - if (req.getOp() != Operation.Add) { + if (req.getOp() != MarkMapReq.Operation.ADD) { return; } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerGetForceQuitBanInfoReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerGetForceQuitBanInfoReq.java index b7afdb905..65740c7fd 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerGetForceQuitBanInfoReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerGetForceQuitBanInfoReq.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.recv; import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketPlayerGetForceQuitBanInfoRsp; @@ -14,10 +15,10 @@ public class HandlerPlayerGetForceQuitBanInfoReq extends PacketHandler { if (session.getServer().getMultiplayerManager().leaveCoop(session.getPlayer())) { // Success - session.send(new PacketPlayerGetForceQuitBanInfoRsp(0)); + session.send(new PacketPlayerGetForceQuitBanInfoRsp(RetcodeOuterClass.Retcode.RET_SUCC_VALUE)); } else { // Fail - session.send(new PacketPlayerGetForceQuitBanInfoRsp(1)); + session.send(new PacketPlayerGetForceQuitBanInfoRsp(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeNotify.java index 0319fc4c9..4176bf71d 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeNotify.java @@ -11,7 +11,7 @@ public class PacketAvatarChangeCostumeNotify extends GenshinPacket { super(PacketOpcodes.AvatarChangeCostumeNotify); AvatarChangeCostumeNotify proto = AvatarChangeCostumeNotify.newBuilder() - .setEntity(entity.toProto()) + .setEntityInfo(entity.toProto()) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeRsp.java index 66c1d5050..cb39f6bbd 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarChangeCostumeRsp.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.AvatarChangeCostumeRspOuterClass.AvatarChangeCostumeRsp; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketAvatarChangeCostumeRsp extends GenshinPacket { @@ -21,7 +22,7 @@ public class PacketAvatarChangeCostumeRsp extends GenshinPacket { super(PacketOpcodes.AvatarChangeCostumeRsp); AvatarChangeCostumeRsp proto = AvatarChangeCostumeRsp.newBuilder() - .setRetcode(1) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarWearFlycloakRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarWearFlycloakRsp.java index b95cfafcf..6cb513a7a 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarWearFlycloakRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarWearFlycloakRsp.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.AvatarWearFlycloakRspOuterClass.AvatarWearFlycloakRsp; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketAvatarWearFlycloakRsp extends GenshinPacket { public PacketAvatarWearFlycloakRsp(long avatarGuid, int costumeId) { @@ -20,7 +21,7 @@ public class PacketAvatarWearFlycloakRsp extends GenshinPacket { super(PacketOpcodes.AvatarWearFlycloakRsp); AvatarWearFlycloakRsp proto = AvatarWearFlycloakRsp.newBuilder() - .setRetcode(1) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCalcWeaponUpgradeReturnItemsRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCalcWeaponUpgradeReturnItemsRsp.java index d3a30a700..874f7da73 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCalcWeaponUpgradeReturnItemsRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCalcWeaponUpgradeReturnItemsRsp.java @@ -4,9 +4,9 @@ import java.util.List; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.packet.Retcode; import emu.grasscutter.net.proto.CalcWeaponUpgradeReturnItemsRspOuterClass.CalcWeaponUpgradeReturnItemsRsp; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketCalcWeaponUpgradeReturnItemsRsp extends GenshinPacket { @@ -25,7 +25,7 @@ public class PacketCalcWeaponUpgradeReturnItemsRsp extends GenshinPacket { super(PacketOpcodes.CalcWeaponUpgradeReturnItemsRsp); CalcWeaponUpgradeReturnItemsRsp proto = CalcWeaponUpgradeReturnItemsRsp.newBuilder() - .setRetcode(Retcode.FAIL) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketChangeAvatarRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketChangeAvatarRsp.java index ac222a43f..720e924ec 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketChangeAvatarRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketChangeAvatarRsp.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.ChangeAvatarRspOuterClass.ChangeAvatarRsp; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketChangeAvatarRsp extends GenshinPacket { @@ -10,8 +11,8 @@ public class PacketChangeAvatarRsp extends GenshinPacket { super(PacketOpcodes.ChangeAvatarRsp); ChangeAvatarRsp p = ChangeAvatarRsp.newBuilder() - .setRetcode(0) - .setCurrGuid(guid) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) + .setCurGuid(guid) .build(); this.setData(p); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCombineRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCombineRsp.java new file mode 100644 index 000000000..d5fda887b --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCombineRsp.java @@ -0,0 +1,58 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.CombineReqOuterClass; +import emu.grasscutter.net.proto.CombineRspOuterClass; +import emu.grasscutter.net.proto.ItemParamOuterClass; +import emu.grasscutter.net.proto.RetcodeOuterClass; + +public class PacketCombineRsp extends GenshinPacket { + + public PacketCombineRsp() { + super(PacketOpcodes.CombineRsp); + + CombineRspOuterClass.CombineRsp proto = CombineRspOuterClass.CombineRsp.newBuilder() + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE).build(); + + + this.setData(proto); + } + + public PacketCombineRsp(int retcode) { + super(PacketOpcodes.CombineRsp); + + CombineRspOuterClass.CombineRsp proto = CombineRspOuterClass.CombineRsp.newBuilder() + .setRetcode(retcode).build(); + + + this.setData(proto); + } + + public PacketCombineRsp(CombineReqOuterClass.CombineReq combineReq, + Iterable costItemList, + Iterable resultItemList, + Iterable totalRandomItemList, + Iterable totalReturnItemList, + Iterable totalExtraItemList) { + + super(PacketOpcodes.CombineRsp); + + CombineRspOuterClass.CombineRsp proto = CombineRspOuterClass.CombineRsp.newBuilder() + .setRetcode(RetcodeOuterClass.Retcode.RET_SUCC_VALUE) + .setCombineId(combineReq.getCombineId()) + .setCombineCount(combineReq.getCombineCount()) + .setAvatarGuid(combineReq.getAvatarGuid()) + .addAllCostItemList(costItemList) + .addAllResultItemList(resultItemList) + .addAllTotalRandomItemList(totalRandomItemList) + .addAllTotalReturnItemList(totalReturnItemList) + .addAllTotalExtraItemList(totalExtraItemList) + .build(); + + this.setData(proto); + } + + + +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketDoGachaRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketDoGachaRsp.java index 090fcfc23..f019239b9 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketDoGachaRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketDoGachaRsp.java @@ -7,6 +7,7 @@ import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.DoGachaRspOuterClass.DoGachaRsp; import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketDoGachaRsp extends GenshinPacket { @@ -33,7 +34,7 @@ public class PacketDoGachaRsp extends GenshinPacket { super(PacketOpcodes.DoGachaRsp); DoGachaRsp p = DoGachaRsp.newBuilder() - .setRetcode(1) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) .build(); this.setData(p); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGadgetInteractRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGadgetInteractRsp.java index 3cb2661de..e7847dfdb 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGadgetInteractRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGadgetInteractRsp.java @@ -5,6 +5,7 @@ import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.GadgetInteractRspOuterClass.GadgetInteractRsp; import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketGadgetInteractRsp extends GenshinPacket { public PacketGadgetInteractRsp(EntityGadget gadget, InteractType interact) { @@ -23,7 +24,7 @@ public class PacketGadgetInteractRsp extends GenshinPacket { super(PacketOpcodes.GadgetInteractRsp); GadgetInteractRsp proto = GadgetInteractRsp.newBuilder() - .setRetcode(1) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAuthkeyRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAuthkeyRsp.java index da250fec8..2265f2f6f 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAuthkeyRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAuthkeyRsp.java @@ -3,13 +3,14 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.GetAuthkeyRspOuterClass.GetAuthkeyRsp; +import emu.grasscutter.net.proto.RetcodeOuterClass; public class PacketGetAuthkeyRsp extends GenshinPacket { public PacketGetAuthkeyRsp() { super(PacketOpcodes.GetAuthkeyRsp); - GetAuthkeyRsp proto = GetAuthkeyRsp.newBuilder().setRetcode(1).build(); + GetAuthkeyRsp proto = GetAuthkeyRsp.newBuilder().setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE).build(); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerFriendListRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerFriendListRsp.java index 4d22f9603..85e0b9849 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerFriendListRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerFriendListRsp.java @@ -9,6 +9,7 @@ import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief; import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState; import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFriendListRsp; import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage; +import emu.grasscutter.net.proto.PlatformTypeOuterClass; public class PacketGetPlayerFriendListRsp extends GenshinPacket { @@ -19,15 +20,15 @@ public class PacketGetPlayerFriendListRsp extends GenshinPacket { .setUid(GenshinConstants.SERVER_CONSOLE_UID) .setNickname("Server") .setLevel(1) - .setAvatar(HeadImage.newBuilder().setAvatarId(GenshinConstants.MAIN_CHARACTER_FEMALE)) + .setAvatarId(HeadImage.newBuilder().setAvatarId(GenshinConstants.MAIN_CHARACTER_FEMALE).getAvatarId()) .setWorldLevel(0) .setSignature("") .setLastActiveTime((int) (System.currentTimeMillis() / 1000f)) .setNameCardId(210001) .setOnlineState(FriendOnlineState.FRIEND_ONLINE) .setParam(1) - .setUnk1(1) - .setUnk2(3) + .setIsGameSource(true) + .setPlatformType(PlatformTypeOuterClass.PlatformType.PC) .build(); GetPlayerFriendListRsp.Builder proto = GetPlayerFriendListRsp.newBuilder().addFriendList(serverFriend); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerSocialDetailRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerSocialDetailRsp.java index 5529d7227..c704afa2f 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerSocialDetailRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerSocialDetailRsp.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.GetPlayerSocialDetailRspOuterClass.GetPlayerSocialDetailRsp; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; public class PacketGetPlayerSocialDetailRsp extends GenshinPacket { @@ -15,7 +16,7 @@ public class PacketGetPlayerSocialDetailRsp extends GenshinPacket { if (detail != null) { proto.setDetailData(detail); } else { - proto.setRetcode(1); + proto.setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE); } this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java index 00f512ea7..994987232 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java @@ -16,18 +16,18 @@ public class PacketGetPlayerTokenRsp extends GenshinPacket { this.setUseDispatchKey(true); GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() - .setPlayerUid(session.getAccount().getPlayerUid()) - .setAccountToken(session.getAccount().getToken()) + .setUid(session.getAccount().getPlayerUid()) + .setToken(session.getAccount().getToken()) .setAccountType(1) .setIsProficientPlayer(doesPlayerExist) // Not sure where this goes - .setSecretKey(Crypto.ENCRYPT_SEED) - .setSecretKeyBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) + .setSecretKeySeed(Crypto.ENCRYPT_SEED) + .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) .setPlatformType(3) .setChannelId(1) .setCountryCode("US") - .setUnk1("c25-314dd05b0b5f") - .setUnk3(3) - .setClientIp(session.getAddress().getAddress().getHostAddress()) + .setClientVersionRandomKey("c25-314dd05b0b5f") + .setRegPlatform(3) + .setClientIpStr(session.getAddress().getAddress().getHostAddress()) .build(); this.setData(p.toByteArray()); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerApplyEnterMpResultNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerApplyEnterMpResultNotify.java index d2b5be7f5..c55ee3b12 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerApplyEnterMpResultNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerApplyEnterMpResultNotify.java @@ -8,7 +8,7 @@ import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass.Player public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket { - public PacketPlayerApplyEnterMpResultNotify(GenshinPlayer target, boolean isAgreed, PlayerApplyEnterMpReason reason) { + public PacketPlayerApplyEnterMpResultNotify(GenshinPlayer target, boolean isAgreed, PlayerApplyEnterMpResultNotify.Reason reason) { super(PacketOpcodes.PlayerApplyEnterMpResultNotify); PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder() @@ -21,7 +21,7 @@ public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket { this.setData(proto); } - public PacketPlayerApplyEnterMpResultNotify(int targetId, String targetName, boolean isAgreed, PlayerApplyEnterMpReason reason) { + public PacketPlayerApplyEnterMpResultNotify(int targetId, String targetName, boolean isAgreed, PlayerApplyEnterMpResultNotify.Reason reason) { super(PacketOpcodes.PlayerApplyEnterMpResultNotify); PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerChatNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerChatNotify.java index 287292ee4..3118adf57 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerChatNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerChatNotify.java @@ -43,7 +43,7 @@ public class PacketPlayerChatNotify extends GenshinPacket { this.setData(proto); } - public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, SystemHint systemHint) { + public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, ChatInfo.SystemHint systemHint) { super(PacketOpcodes.PlayerChatNotify); ChatInfo info = ChatInfo.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java index 51b043ab3..c5eb76238 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java @@ -13,7 +13,7 @@ public class PacketPlayerDataNotify extends GenshinPacket { PlayerDataNotify.Builder p = PlayerDataNotify.newBuilder() .setNickName(player.getNickname()) - .setClientTime(System.currentTimeMillis()) + .setServerTime(System.currentTimeMillis()) .setIsFirstLoginToday(true) .setRegionId(player.getRegionId()); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneInfoNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneInfoNotify.java index e47021a05..9668a250c 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneInfoNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneInfoNotify.java @@ -5,6 +5,7 @@ import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.AbilityControlBlockOuterClass; import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; import emu.grasscutter.net.proto.AvatarEnterSceneInfoOuterClass.AvatarEnterSceneInfo; import emu.grasscutter.net.proto.MPLevelEntityInfoOuterClass.MPLevelEntityInfo; @@ -26,7 +27,7 @@ public class PacketPlayerEnterSceneInfoNotify extends GenshinPacket { TeamEnterSceneInfo.newBuilder() .setTeamEntityId(player.getTeamManager().getEntityId()) // 150995833 .setTeamAbilityInfo(empty) - .setUnk(empty) + .setAbilityControlBlock(AbilityControlBlockOuterClass.AbilityControlBlock.newBuilder().build()) ); proto.setMpLevelEntityInfo( MPLevelEntityInfo.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java index d66575273..cd2f78a0d 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java @@ -23,14 +23,14 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket { .setSceneId(player.getSceneId()) .setPos(player.getPos().toProto()) .setSceneBeginTime(System.currentTimeMillis()) - .setType(EnterType.EnterSelf) + .setType(EnterType.ENTER_SELF) .setTargetUid(player.getUid()) .setEnterSceneToken(player.getEnterSceneToken()) .setWorldLevel(player.getWorldLevel()) .setEnterReason(EnterReason.Login.getValue()) .setIsFirstLoginEnterScene(player.isFirstLoginEnterScene()) - .setUnk1(1) - .setUnk2("3-" + player.getUid() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402) + .setWorldType(1) + .setSceneTransaction("3-" + player.getUid() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402) .build(); this.setData(proto); @@ -62,8 +62,8 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket { .addSceneTagIdList(109) .addSceneTagIdList(113) .addSceneTagIdList(117) - .setUnk1(1) - .setUnk2(newScene + "-" + target.getUid() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402) + .setWorldType(1) + .setSceneTransaction(newScene + "-" + target.getUid() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java index 3a796c7ad..f48047633 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java @@ -40,8 +40,8 @@ public class PacketPlayerLoginRsp extends GenshinPacket { QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp regionQuery = QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp.parseFrom(decodedCurRegion); RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder() - .setIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty() ? Grasscutter.getConfig().getGameServerOptions().Ip : Grasscutter.getConfig().getGameServerOptions().PublicIp)) - .setPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0 ? Grasscutter.getConfig().getGameServerOptions().PublicPort : Grasscutter.getConfig().getGameServerOptions().Port) + .setGateserverIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty() ? Grasscutter.getConfig().getGameServerOptions().Ip : Grasscutter.getConfig().getGameServerOptions().PublicIp)) + .setGateserverPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0 ? Grasscutter.getConfig().getGameServerOptions().PublicPort : Grasscutter.getConfig().getGameServerOptions().Port) .setSecretKey(ByteString.copyFrom(FileUtils.read(Grasscutter.getConfig().KEY_FOLDER + "dispatchSeed.bin"))) .build(); @@ -64,7 +64,7 @@ public class PacketPlayerLoginRsp extends GenshinPacket { .setClientSilenceDataVersion(info.getClientSilenceDataVersion()) .setClientMd5(info.getClientDataMd5()) .setClientSilenceMd5(info.getClientSilenceDataMd5()) - .setResVersionConfig(info.getConfig()) + .setResVersionConfig(info.getResVersionConfig()) .setClientVersionSuffix(info.getClientVersionSuffix()) .setClientSilenceVersionSuffix(info.getClientSilenceVersionSuffix()) .setIsScOpen(false) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java index a3309a5c1..f9649d4b4 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java @@ -18,7 +18,7 @@ public class PacketPlayerStoreNotify extends GenshinPacket { this.buildHeader(2); PlayerStoreNotify.Builder p = PlayerStoreNotify.newBuilder() - .setStoreType(StoreType.StorePack) + .setStoreType(StoreType.STORE_PACK) .setWeightLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitAll); for (GenshinItem item : player.getInventory()) { diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityAppearNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityAppearNotify.java index 3b8a39025..10cac2453 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityAppearNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityAppearNotify.java @@ -15,7 +15,7 @@ public class PacketSceneEntityAppearNotify extends GenshinPacket { super(PacketOpcodes.SceneEntityAppearNotify, true); SceneEntityAppearNotify.Builder proto = SceneEntityAppearNotify.newBuilder() - .setAppearType(VisionType.VisionBorn) + .setAppearType(VisionType.VISION_BORN) .addEntityList(entity.toProto()); this.setData(proto.build()); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityDrownRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityDrownRsp.java new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneKickPlayerRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneKickPlayerRsp.java index 7f0a6a12e..edc73d5e7 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneKickPlayerRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneKickPlayerRsp.java @@ -2,6 +2,7 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.SceneKickPlayerRspOuterClass.SceneKickPlayerRsp; public class PacketSceneKickPlayerRsp extends GenshinPacket { @@ -20,7 +21,7 @@ public class PacketSceneKickPlayerRsp extends GenshinPacket { super(PacketOpcodes.SceneKickPlayerRsp); SceneKickPlayerRsp proto = SceneKickPlayerRsp.newBuilder() - .setRetcode(1) + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTeamUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTeamUpdateNotify.java index 20e199bc4..ddfc4e154 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTeamUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTeamUpdateNotify.java @@ -19,7 +19,7 @@ public class PacketSceneTeamUpdateNotify extends GenshinPacket { for (GenshinPlayer p : player.getWorld().getPlayers()) { for (EntityAvatar entityAvatar : p.getTeamManager().getActiveTeam()) { SceneTeamAvatar.Builder avatarProto = SceneTeamAvatar.newBuilder() - .setPlayerId(p.getUid()) + .setPlayerUid(p.getUid()) .setAvatarGuid(entityAvatar.getAvatar().getGuid()) .setSceneId(p.getSceneId()) .setEntityId(entityAvatar.getId()) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTransToPointRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTransToPointRsp.java index 4795c5e9f..7aea3e333 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTransToPointRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTransToPointRsp.java @@ -5,6 +5,7 @@ import emu.grasscutter.data.custom.ScenePointEntry; import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.SceneTransToPointRspOuterClass.SceneTransToPointRsp; import emu.grasscutter.utils.Position; @@ -26,7 +27,7 @@ public class PacketSceneTransToPointRsp extends GenshinPacket { super(PacketOpcodes.SceneTransToPointRsp); SceneTransToPointRsp proto = SceneTransToPointRsp.newBuilder() - .setRetcode(1) // Internal server error + .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE) // Internal server error .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java index 8a343bf1d..a023ec761 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java @@ -4,6 +4,7 @@ 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.SetPlayerBornDataReqOuterClass; public class PacketSetPlayerBirthdayRsp extends GenshinPacket { diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerHeadImageRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerHeadImageRsp.java index 148c536f0..b3b17416c 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerHeadImageRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerHeadImageRsp.java @@ -12,7 +12,7 @@ public class PacketSetPlayerHeadImageRsp extends GenshinPacket { super(PacketOpcodes.SetPlayerHeadImageRsp); SetPlayerHeadImageRsp proto = SetPlayerHeadImageRsp.newBuilder() - .setAvatar(HeadImage.newBuilder().setAvatarId(player.getHeadImage())) + .setAvatarId(HeadImage.newBuilder().setAvatarId(player.getHeadImage()).getAvatarId()) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java deleted file mode 100644 index 70893965b..000000000 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java +++ /dev/null @@ -1,21 +0,0 @@ -package emu.grasscutter.server.packet.send; - -import emu.grasscutter.net.packet.GenshinPacket; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.SitRspOuterClass.SitRsp; -import emu.grasscutter.utils.Position; - -public class PacketSitRsp extends GenshinPacket { - - public PacketSitRsp(long chairId, Position pos, int EntityId) { - super(PacketOpcodes.SitRsp); - - SitRsp proto = SitRsp.newBuilder() - .setEntityId(EntityId) - .setPosition(pos.toProto()) - .setChairId(chairId) - .build(); - - this.setData(proto); - } -} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemChangeNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemChangeNotify.java index 70f86b782..20082582e 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemChangeNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemChangeNotify.java @@ -18,7 +18,7 @@ public class PacketStoreItemChangeNotify extends GenshinPacket { this(); StoreItemChangeNotify.Builder proto = StoreItemChangeNotify.newBuilder() - .setStoreType(StoreType.StorePack) + .setStoreType(StoreType.STORE_PACK) .addItemList(item.toProto()); this.setData(proto); @@ -28,9 +28,9 @@ public class PacketStoreItemChangeNotify extends GenshinPacket { this(); StoreItemChangeNotify.Builder proto = StoreItemChangeNotify.newBuilder() - .setStoreType(StoreType.StorePack); + .setStoreType(StoreType.STORE_PACK); - items.stream().forEach(item -> proto.addItemList(item.toProto())); + items.forEach(item -> proto.addItemList(item.toProto())); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java index 0bd585720..6bf377a44 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java @@ -18,7 +18,7 @@ public class PacketStoreItemDelNotify extends GenshinPacket { this(); StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder() - .setStoreType(StoreType.StorePack) + .setStoreType(StoreType.STORE_PACK) .addGuidList(item.getGuid()); this.setData(proto); @@ -28,7 +28,7 @@ public class PacketStoreItemDelNotify extends GenshinPacket { this(); StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder() - .setStoreType(StoreType.StorePack); + .setStoreType(StoreType.STORE_PACK); items.stream().forEach(item -> proto.addGuidList(item.getGuid())); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreWeightLimitNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreWeightLimitNotify.java index 04668b00e..590efd800 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreWeightLimitNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreWeightLimitNotify.java @@ -12,7 +12,7 @@ public class PacketStoreWeightLimitNotify extends GenshinPacket { super(PacketOpcodes.StoreWeightLimitNotify); StoreWeightLimitNotify p = StoreWeightLimitNotify.newBuilder() - .setStoreType(StoreType.StorePack) + .setStoreType(StoreType.STORE_PACK) .setWeightLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitAll) .setWeaponCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitWeapon) .setReliquaryCountLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitRelic) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketUseItemRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketUseItemRsp.java index 0069ee114..b58638ebb 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketUseItemRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketUseItemRsp.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.UseItemRspOuterClass.UseItemRsp; public class PacketUseItemRsp extends GenshinPacket { @@ -22,7 +23,7 @@ public class PacketUseItemRsp extends GenshinPacket { public PacketUseItemRsp() { super(PacketOpcodes.UseItemRsp); - UseItemRsp proto = UseItemRsp.newBuilder().setRetcode(1).build(); + UseItemRsp proto = UseItemRsp.newBuilder().setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE).build(); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketWorldPlayerLocationNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketWorldPlayerLocationNotify.java index 1bb09f8db..9ef9cfb73 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketWorldPlayerLocationNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketWorldPlayerLocationNotify.java @@ -14,7 +14,7 @@ public class PacketWorldPlayerLocationNotify extends GenshinPacket { WorldPlayerLocationNotify.Builder proto = WorldPlayerLocationNotify.newBuilder(); for (GenshinPlayer p : world.getPlayers()) { - proto.addPlayerLocList(p.getWorldPlayerLocationInfo()); + proto.addPlayerWorldLocList(p.getWorldPlayerLocationInfo()); } this.setData(proto); diff --git a/src/main/java/emu/grasscutter/utils/Crypto.java b/src/main/java/emu/grasscutter/utils/Crypto.java index 2d3e96c16..e6d260e94 100644 --- a/src/main/java/emu/grasscutter/utils/Crypto.java +++ b/src/main/java/emu/grasscutter/utils/Crypto.java @@ -34,7 +34,7 @@ public final class Crypto { public static void extractSecretKeyBuffer(byte[] data) { try { GetPlayerTokenRsp p = GetPlayerTokenRsp.parseFrom(data); - FileUtils.write(Grasscutter.getConfig().KEY_FOLDER + "secretKeyBuffer.bin", p.getSecretKeyBuffer().toByteArray()); + FileUtils.write(Grasscutter.getConfig().KEY_FOLDER + "secretKeyBuffer.bin", p.getSecretKeyBytes().toByteArray()); Grasscutter.getLogger().info("Secret Key: " + p.getSecretKey()); } catch (Exception e) { Grasscutter.getLogger().error("Crypto error.", e);