Commit addfb5eb authored by WetABQ's avatar WetABQ Committed by GitHub
Browse files

[BREAKING CHANGE] proto auto compiled by gradle (#226)

* [BREAK] proto auto compiled by gradle

* [BREAK] move proto to submodule

* update gitmodules

* [BREAK] move proto to submodule

* move proto to submodule

* fix merge conflict

* fix github action after merging

* fix merge conflicts and del submodule

* upload the proto
parent 627a2f1e
...@@ -56,9 +56,10 @@ resources/* ...@@ -56,9 +56,10 @@ resources/*
logs/* logs/*
data/AbilityEmbryos.json data/AbilityEmbryos.json
data/OpenConfig.json data/OpenConfig.json
proto/*
GM Handbook.txt GM Handbook.txt
config.json config.json
mitmdump.exe mitmdump.exe
grasscutter.jar *.jar
mongod.exe mongod.exe
\ No newline at end of file /src/generated/
/*.sh
\ No newline at end of file
[submodule "Grasscutter-Protos"]
path = Grasscutter-Protos
url = https://github.com/Melledy/Grasscutter-Protos
Subproject commit 0537e9cc4c7856a7c6f88bbbaa908a80c4ee677e
...@@ -6,10 +6,23 @@ ...@@ -6,10 +6,23 @@
* User Manual available at https://docs.gradle.org/5.6.3/userguide/tutorial_java_projects.html * 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 { plugins {
// Apply the java plugin to add support for Java // Apply the java plugin to add support for Java
id '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 // Apply the application plugin to add support for building a CLI application
id 'application' id 'application'
...@@ -17,6 +30,10 @@ plugins { ...@@ -17,6 +30,10 @@ plugins {
id 'signing' id 'signing'
} }
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
group = 'tech.xigam' group = 'tech.xigam'
version = '1.0.0-dev' version = '1.0.0-dev'
...@@ -34,7 +51,7 @@ repositories { ...@@ -34,7 +51,7 @@ repositories {
dependencies { dependencies {
implementation fileTree(dir: 'lib', include: ['*.jar']) implementation fileTree(dir: 'lib', include: ['*.jar'])
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.32' 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-core', version: '1.2.9'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
...@@ -49,6 +66,9 @@ dependencies { ...@@ -49,6 +66,9 @@ dependencies {
implementation group: 'org.greenrobot', name: 'eventbus-java', version: '3.3.1' implementation group: 'org.greenrobot', name: 'eventbus-java', version: '3.3.1'
implementation group: 'org.danilopianini', name: 'java-quadtree', version: '0.1.9' implementation group: 'org.danilopianini', name: 'java-quadtree', version: '0.1.9'
protobuf files('proto/')
} }
application { application {
...@@ -125,13 +145,47 @@ publishing { ...@@ -125,13 +145,47 @@ publishing {
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
name = 'sonatype' name = 'sonatype'
credentials(PasswordCredentials) 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 { signing {
sign publishing.publications.mavenJava sign publishing.publications.mavenJava
} }
......
...@@ -140,7 +140,7 @@ public class ResourceLoader { ...@@ -140,7 +140,7 @@ public class ResourceLoader {
} }
List<ScenePointEntry> scenePointList = new ArrayList<>(); List<ScenePointEntry> scenePointList = new ArrayList<>();
for (File file : folder.listFiles()) { for (File file : Objects.requireNonNull(folder.listFiles())) {
ScenePointConfig config = null; ScenePointConfig config = null;
Integer sceneId = null; Integer sceneId = null;
...@@ -190,7 +190,7 @@ public class ResourceLoader { ...@@ -190,7 +190,7 @@ public class ResourceLoader {
} else { } else {
// Load from BinOutput // Load from BinOutput
Pattern pattern = Pattern.compile("(?<=ConfigAvatar_)(.*?)(?=.json)"); Pattern pattern = Pattern.compile("(?<=ConfigAvatar_)(.*?)(?=.json)");
embryoList = new LinkedList<>(); embryoList = new LinkedList<>();
File folder = new File(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "BinOutput/Avatar/")); File folder = new File(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "BinOutput/Avatar/"));
File[] files = folder.listFiles(); File[] files = folder.listFiles();
...@@ -198,29 +198,29 @@ public class ResourceLoader { ...@@ -198,29 +198,29 @@ public class ResourceLoader {
Grasscutter.getLogger().error("Error loading ability embryos: no files found in " + folder.getAbsolutePath()); Grasscutter.getLogger().error("Error loading ability embryos: no files found in " + folder.getAbsolutePath());
return; return;
} }
for (File file : files) { for (File file : files) {
AvatarConfig config; AvatarConfig config;
String avatarName; String avatarName;
Matcher matcher = pattern.matcher(file.getName()); Matcher matcher = pattern.matcher(file.getName());
if (matcher.find()) { if (matcher.find()) {
avatarName = matcher.group(0); avatarName = matcher.group(0);
} else { } else {
continue; continue;
} }
try (FileReader fileReader = new FileReader(file)) { try (FileReader fileReader = new FileReader(file)) {
config = Grasscutter.getGsonFactory().fromJson(fileReader, AvatarConfig.class); config = Grasscutter.getGsonFactory().fromJson(fileReader, AvatarConfig.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
if (config.abilities == null) { if (config.abilities == null) {
continue; continue;
} }
int s = config.abilities.size(); int s = config.abilities.size();
AbilityEmbryoEntry al = new AbilityEmbryoEntry(avatarName, config.abilities.stream().map(Object::toString).toArray(size -> new String[s])); AbilityEmbryoEntry al = new AbilityEmbryoEntry(avatarName, config.abilities.stream().map(Object::toString).toArray(size -> new String[s]));
embryoList.add(al); embryoList.add(al);
...@@ -331,7 +331,7 @@ public class ResourceLoader { ...@@ -331,7 +331,7 @@ public class ResourceLoader {
GenshinData.getOpenConfigEntries().put(entry.getName(), entry); GenshinData.getOpenConfigEntries().put(entry.getName(), entry);
} }
} }
// BinOutput configs // BinOutput configs
private static class AvatarConfig { private static class AvatarConfig {
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = "CombineExcelConfigData.json")
public class CombineData {
}
...@@ -27,9 +27,10 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType; ...@@ -27,9 +27,10 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import emu.grasscutter.net.proto.MpSettingTypeOuterClass.MpSettingType; import emu.grasscutter.net.proto.MpSettingTypeOuterClass.MpSettingType;
import emu.grasscutter.net.proto.OnlinePlayerInfoOuterClass.OnlinePlayerInfo; import emu.grasscutter.net.proto.OnlinePlayerInfoOuterClass.OnlinePlayerInfo;
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason; 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.PlayerLocationInfoOuterClass.PlayerLocationInfo;
import emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; 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.GameServer;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
...@@ -70,7 +71,7 @@ public class GenshinPlayer { ...@@ -70,7 +71,7 @@ public class GenshinPlayer {
private TeamManager teamManager; private TeamManager teamManager;
private PlayerGachaInfo gachaInfo; private PlayerGachaInfo gachaInfo;
private PlayerProfile playerProfile; private PlayerProfile playerProfile;
private MpSettingType mpSetting = MpSettingType.MpSettingEnterAfterApply; private MpSettingType mpSetting = MpSettingType.MP_SETTING_ENTER_AFTER_APPLY;
private boolean showAvatar; private boolean showAvatar;
private ArrayList<AvatarProfileData> shownAvatars; private ArrayList<AvatarProfileData> shownAvatars;
private Set<Integer> rewardedLevels; private Set<Integer> rewardedLevels;
...@@ -587,7 +588,7 @@ public class GenshinPlayer { ...@@ -587,7 +588,7 @@ public class GenshinPlayer {
// Add to inventory // Add to inventory
boolean success = getInventory().addItem(item); boolean success = getInventory().addItem(item);
if (success) { 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)); this.sendPacket(new PacketItemAddHintNotify(item, ActionReason.SubfieldDrop));
} }
} }
...@@ -617,7 +618,7 @@ public class GenshinPlayer { ...@@ -617,7 +618,7 @@ public class GenshinPlayer {
.setMpSettingType(this.getMpSetting()) .setMpSettingType(this.getMpSetting())
.setNameCardId(this.getNameCardId()) .setNameCardId(this.getNameCardId())
.setSignature(this.getSignature()) .setSignature(this.getSignature())
.setAvatar(HeadImage.newBuilder().setAvatarId(this.getHeadImage())); .setAvatarId(HeadImage.newBuilder().setAvatarId(this.getHeadImage()).getAvatarId());
if (this.getWorld() != null) { if (this.getWorld() != null) {
onlineInfo.setCurPlayerNumInWorld(this.getWorld().getPlayers().indexOf(this) + 1); onlineInfo.setCurPlayerNumInWorld(this.getWorld().getPlayers().indexOf(this) + 1);
...@@ -652,21 +653,19 @@ public class GenshinPlayer { ...@@ -652,21 +653,19 @@ public class GenshinPlayer {
public SocialDetail.Builder getSocialDetail() { public SocialDetail.Builder getSocialDetail() {
SocialDetail.Builder social = SocialDetail.newBuilder() SocialDetail.Builder social = SocialDetail.newBuilder()
.setUid(this.getUid()) .setUid(this.getUid())
.setAvatar(HeadImage.newBuilder().setAvatarId(this.getHeadImage())) .setAvatarId(HeadImage.newBuilder().setAvatarId(this.getHeadImage()).getAvatarId())
.setNickname(this.getNickname()) .setNickname(this.getNickname())
.setSignature(this.getSignature()) .setSignature(this.getSignature())
.setLevel(this.getLevel()) .setLevel(this.getLevel())
.setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty()) .setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty())
.setWorldLevel(this.getWorldLevel()) .setWorldLevel(this.getWorldLevel())
.setUnk1(1)
.setUnk3(1)
.setNameCardId(this.getNameCardId()) .setNameCardId(this.getNameCardId())
.setFinishAchievementNum(0); .setFinishAchievementNum(0);
return social; return social;
} }
public WorldPlayerLocationInfo getWorldPlayerLocationInfo() { public PlayerWorldLocationInfoOuterClass.PlayerWorldLocationInfo getWorldPlayerLocationInfo() {
return WorldPlayerLocationInfo.newBuilder() return PlayerWorldLocationInfoOuterClass.PlayerWorldLocationInfo.newBuilder()
.setSceneId(this.getSceneId()) .setSceneId(this.getSceneId())
.setPlayerLoc(this.getPlayerLocationInfo()) .setPlayerLoc(this.getPlayerLocationInfo())
.build(); .build();
...@@ -691,7 +690,7 @@ public class GenshinPlayer { ...@@ -691,7 +690,7 @@ public class GenshinPlayer {
while (it.hasNext()) { while (it.hasNext()) {
CoopRequest req = it.next(); CoopRequest req = it.next();
if (req.isExpired()) { 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(); it.remove();
} }
} }
......
...@@ -202,7 +202,7 @@ public class GenshinScene { ...@@ -202,7 +202,7 @@ public class GenshinScene {
private void removePlayerAvatars(GenshinPlayer player) { private void removePlayerAvatars(GenshinPlayer player) {
Iterator<EntityAvatar> it = player.getTeamManager().getActiveTeam().iterator(); Iterator<EntityAvatar> it = player.getTeamManager().getActiveTeam().iterator();
while (it.hasNext()) { while (it.hasNext()) {
this.removeEntity(it.next(), VisionType.VisionRemove); this.removeEntity(it.next(), VisionType.VISION_REMOVE);
it.remove(); it.remove();
} }
} }
...@@ -233,7 +233,7 @@ public class GenshinScene { ...@@ -233,7 +233,7 @@ public class GenshinScene {
this.addEntityDirectly(entity); this.addEntityDirectly(entity);
} }
this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VisionBorn)); this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_BORN));
} }
private GenshinEntity removeEntityDirectly(GenshinEntity entity) { private GenshinEntity removeEntityDirectly(GenshinEntity entity) {
...@@ -241,7 +241,7 @@ public class GenshinScene { ...@@ -241,7 +241,7 @@ public class GenshinScene {
} }
public void removeEntity(GenshinEntity entity) { public void removeEntity(GenshinEntity entity) {
this.removeEntity(entity, VisionType.VisionDie); this.removeEntity(entity, VisionType.VISION_DIE);
} }
public synchronized void removeEntity(GenshinEntity entity, VisionType visionType) { public synchronized void removeEntity(GenshinEntity entity, VisionType visionType) {
...@@ -254,8 +254,8 @@ public class GenshinScene { ...@@ -254,8 +254,8 @@ public class GenshinScene {
public synchronized void replaceEntity(EntityAvatar oldEntity, EntityAvatar newEntity) { public synchronized void replaceEntity(EntityAvatar oldEntity, EntityAvatar newEntity) {
this.removeEntityDirectly(oldEntity); this.removeEntityDirectly(oldEntity);
this.addEntityDirectly(newEntity); this.addEntityDirectly(newEntity);
this.broadcastPacket(new PacketSceneEntityDisappearNotify(oldEntity, VisionType.VisionReplace)); this.broadcastPacket(new PacketSceneEntityDisappearNotify(oldEntity, VisionType.VISION_REPLACE));
this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VisionReplace, oldEntity.getId())); this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VISION_REPLACE, oldEntity.getId()));
} }
public void showOtherEntities(GenshinPlayer player) { public void showOtherEntities(GenshinPlayer player) {
...@@ -269,7 +269,7 @@ public class GenshinScene { ...@@ -269,7 +269,7 @@ public class GenshinScene {
entities.add(entity); entities.add(entity);
} }
player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VisionMeet)); player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_MEET));
} }
public void handleAttack(AttackResult result) { public void handleAttack(AttackResult result) {
...@@ -381,11 +381,11 @@ public class GenshinScene { ...@@ -381,11 +381,11 @@ public class GenshinScene {
if (toAdd.size() > 0) { if (toAdd.size() > 0) {
toAdd.stream().forEach(this::addEntityDirectly); toAdd.stream().forEach(this::addEntityDirectly);
this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VisionBorn)); this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_BORN));
} }
if (toRemove.size() > 0) { if (toRemove.size() > 0) {
toRemove.stream().forEach(this::removeEntityDirectly); 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 { ...@@ -425,7 +425,7 @@ public class GenshinScene {
return; return;
} }
this.broadcastPacketToOthers(gadget.getOwner(), new PacketSceneEntityDisappearNotify(gadget, VisionType.VisionDie)); this.broadcastPacketToOthers(gadget.getOwner(), new PacketSceneEntityDisappearNotify(gadget, VisionType.VISION_DIE));
} }
// Broadcasting // Broadcasting
......
...@@ -20,18 +20,11 @@ public class InvokeHandler<T> { ...@@ -20,18 +20,11 @@ public class InvokeHandler<T> {
public synchronized void addEntry(ForwardType forward, T entry) { public synchronized void addEntry(ForwardType forward, T entry) {
switch (forward) { switch (forward) {
case ForwardToAll: case FORWARD_TO_ALL -> entryListForwardAll.add(entry);
entryListForwardAll.add(entry); case FORWARD_TO_ALL_EXCEPT_CUR, FORWARD_TO_ALL_EXIST_EXCEPT_CUR -> entryListForwardAllExceptCur.add(entry);
break; case FORWARD_TO_HOST -> entryListForwardHost.add(entry);
case ForwardToAllExceptCur: default -> {
case ForwardToAllExistExceptCur: }
entryListForwardAllExceptCur.add(entry);
break;
case ForwardToHost:
entryListForwardHost.add(entry);
break;
default:
break;
} }
} }
......
...@@ -397,7 +397,7 @@ public class TeamManager { ...@@ -397,7 +397,7 @@ public class TeamManager {
this.setCurrentCharacterIndex(index); this.setCurrentCharacterIndex(index);
// Old entity motion state // Old entity motion state
oldEntity.setMotionState(MotionState.MotionStandby); oldEntity.setMotionState(MotionState.MOTION_STANDBY);
// Remove and Add // Remove and Add
getPlayer().getScene().replaceEntity(oldEntity, newEntity); getPlayer().getScene().replaceEntity(oldEntity, newEntity);
...@@ -476,7 +476,7 @@ public class TeamManager { ...@@ -476,7 +476,7 @@ public class TeamManager {
} }
// Teleport player // 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 // Set player position
player.setSceneId(3); player.setSceneId(3);
......
...@@ -64,7 +64,7 @@ public class World implements Iterable<GenshinPlayer> { ...@@ -64,7 +64,7 @@ public class World implements Iterable<GenshinPlayer> {
this.levelEntityId = getNextEntityId(EntityIdType.MPLEVEL); this.levelEntityId = getNextEntityId(EntityIdType.MPLEVEL);
this.worldLevel = player.getWorldLevel(); this.worldLevel = player.getWorldLevel();
this.isMultiplayer = isMultiplayer; this.isMultiplayer = isMultiplayer;
this.owner.getServer().registerWorld(this); this.owner.getServer().registerWorld(this);
} }
...@@ -197,7 +197,7 @@ public class World implements Iterable<GenshinPlayer> { ...@@ -197,7 +197,7 @@ public class World implements Iterable<GenshinPlayer> {
World world = new World(victim); World world = new World(victim);
world.addPlayer(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<GenshinPlayer> { ...@@ -219,12 +219,12 @@ public class World implements Iterable<GenshinPlayer> {
if (player.getScene() != null) { if (player.getScene() != null) {
oldScene = player.getScene(); oldScene = player.getScene();
// Dont deregister scenes if the player is going to tp back into them // Dont deregister scenes if the player is going to tp back into them
if (oldScene.getId() == sceneId) { if (oldScene.getId() == sceneId) {
oldScene.setDontDestroyWhenEmpty(true); oldScene.setDontDestroyWhenEmpty(true);
} }
oldScene.removePlayer(player); oldScene.removePlayer(player);
} }
...@@ -235,12 +235,12 @@ public class World implements Iterable<GenshinPlayer> { ...@@ -235,12 +235,12 @@ public class World implements Iterable<GenshinPlayer> {
if (oldScene != null) { if (oldScene != null) {
oldScene.setDontDestroyWhenEmpty(false); oldScene.setDontDestroyWhenEmpty(false);
} }
// Teleport packet // Teleport packet
if (oldScene == newScene) { 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 { } 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; return true;
} }
...@@ -281,7 +281,7 @@ public class World implements Iterable<GenshinPlayer> { ...@@ -281,7 +281,7 @@ public class World implements Iterable<GenshinPlayer> {
scene.onTick(); scene.onTick();
} }
} }
public void close() { public void close() {
} }
......
...@@ -778,7 +778,7 @@ public class GenshinAvatar { ...@@ -778,7 +778,7 @@ public class GenshinAvatar {
.setCoreProudSkillLevel(this.getCoreProudSkillLevel()) .setCoreProudSkillLevel(this.getCoreProudSkillLevel())
.putAllSkillLevelMap(this.getSkillLevelMap()) .putAllSkillLevelMap(this.getSkillLevelMap())
.addAllInherentProudSkillList(this.getProudSkillList()) .addAllInherentProudSkillList(this.getProudSkillList())
.putAllProudSkillExtraLevel(getProudSkillBonusMap()) .putAllProudSkillExtraLevelMap(getProudSkillBonusMap())
.setAvatarType(1) .setAvatarType(1)
.setBornTime(this.getBornTime()) .setBornTime(this.getBornTime())
.setFetterInfo(avatarFetter) .setFetterInfo(avatarFetter)
......
...@@ -101,13 +101,13 @@ public class EntityAvatar extends GenshinEntity { ...@@ -101,13 +101,13 @@ public class EntityAvatar extends GenshinEntity {
@Override @Override
public void onDeath(int killerId) { public void onDeath(int killerId) {
this.killedType = PlayerDieType.PlayerDieKillByMonster; this.killedType = PlayerDieType.PLAYER_DIE_KILL_BY_MONSTER;
this.killedBy = killerId; this.killedBy = killerId;
} }
public SceneAvatarInfo getSceneAvatarInfo() { public SceneAvatarInfo getSceneAvatarInfo() {
SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder() SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder()
.setPlayerId(this.getPlayer().getUid()) .setUid(this.getPlayer().getUid())
.setAvatarId(this.getAvatar().getAvatarId()) .setAvatarId(this.getAvatar().getAvatarId())
.setGuid(this.getAvatar().getGuid()) .setGuid(this.getAvatar().getGuid())
.setPeerId(this.getPlayer().getPeerId()) .setPeerId(this.getPlayer().getPeerId())
...@@ -145,7 +145,7 @@ public class EntityAvatar extends GenshinEntity { ...@@ -145,7 +145,7 @@ public class EntityAvatar extends GenshinEntity {
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
.setEntityId(getId()) .setEntityId(getId())
.setEntityType(ProtEntityType.ProtEntityAvatar) .setEntityType(ProtEntityType.PROT_ENTITY_AVATAR)
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
.setEntityClientData(EntityClientData.newBuilder()) .setEntityClientData(EntityClientData.newBuilder())
.setEntityAuthorityInfo(authority) .setEntityAuthorityInfo(authority)
...@@ -161,7 +161,7 @@ public class EntityAvatar extends GenshinEntity { ...@@ -161,7 +161,7 @@ public class EntityAvatar extends GenshinEntity {
if (entry.getIntKey() == 0) { if (entry.getIntKey() == 0) {
continue; 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); entityInfo.addFightPropList(fightProp);
} }
......
...@@ -6,6 +6,7 @@ import emu.grasscutter.game.World; ...@@ -6,6 +6,7 @@ import emu.grasscutter.game.World;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
import emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair; 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.EntityAuthorityInfoOuterClass.EntityAuthorityInfo;
import emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData; import emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData;
import emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo; import emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo;
...@@ -112,7 +113,7 @@ public class EntityClientGadget extends EntityGadget { ...@@ -112,7 +113,7 @@ public class EntityClientGadget extends EntityGadget {
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
.setEntityId(getId()) .setEntityId(getId())
.setEntityType(ProtEntityType.ProtEntityGadget) .setEntityType(ProtEntityType.PROT_ENTITY_GADGET)
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder())) .setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
.setEntityClientData(EntityClientData.newBuilder()) .setEntityClientData(EntityClientData.newBuilder())
...@@ -125,7 +126,7 @@ public class EntityClientGadget extends EntityGadget { ...@@ -125,7 +126,7 @@ public class EntityClientGadget extends EntityGadget {
.build(); .build();
entityInfo.addPropList(pair); entityInfo.addPropList(pair);
GadgetClientParam clientGadget = GadgetClientParam.newBuilder() ClientGadgetInfoOuterClass.ClientGadgetInfo clientGadget = ClientGadgetInfoOuterClass.ClientGadgetInfo.newBuilder()
.setCampId(this.getCampId()) .setCampId(this.getCampId())
.setCampType(this.getCampType()) .setCampType(this.getCampType())
.setOwnerEntityId(this.getOwnerEntityId()) .setOwnerEntityId(this.getOwnerEntityId())
......
...@@ -92,7 +92,7 @@ public class EntityItem extends EntityGadget { ...@@ -92,7 +92,7 @@ public class EntityItem extends EntityGadget {
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
.setEntityId(getId()) .setEntityId(getId())
.setEntityType(ProtEntityType.ProtEntityGadget) .setEntityType(ProtEntityType.PROT_ENTITY_GADGET)
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder())) .setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
.setEntityClientData(EntityClientData.newBuilder()) .setEntityClientData(EntityClientData.newBuilder())
...@@ -108,7 +108,7 @@ public class EntityItem extends EntityGadget { ...@@ -108,7 +108,7 @@ public class EntityItem extends EntityGadget {
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder() SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
.setGadgetId(this.getItemData().getGadgetId()) .setGadgetId(this.getItemData().getGadgetId())
.setTrifleItem(this.getItem().toProto()) .setTrifleItem(this.getItem().toProto())
.setBornType(GadgetBornType.GadgetBornInAir) .setBornType(GadgetBornType.GADGET_BORN_IN_AIR)
.setAuthorityPeerId(this.getWorld().getHostPeerId()) .setAuthorityPeerId(this.getWorld().getHostPeerId())
.setIsEnableInteract(true); .setIsEnableInteract(true);
......
...@@ -197,7 +197,7 @@ public class EntityMonster extends GenshinEntity { ...@@ -197,7 +197,7 @@ public class EntityMonster extends GenshinEntity {
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder() SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
.setEntityId(getId()) .setEntityId(getId())
.setEntityType(ProtEntityType.ProtEntityMonster) .setEntityType(ProtEntityType.PROT_ENTITY_MONSTER)
.setMotionInfo(this.getMotionInfo()) .setMotionInfo(this.getMotionInfo())
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder()) .addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
.setEntityClientData(EntityClientData.newBuilder()) .setEntityClientData(EntityClientData.newBuilder())
...@@ -208,7 +208,7 @@ public class EntityMonster extends GenshinEntity { ...@@ -208,7 +208,7 @@ public class EntityMonster extends GenshinEntity {
if (entry.getIntKey() == 0) { if (entry.getIntKey() == 0) {
continue; 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); entityInfo.addFightPropList(fightProp);
} }
...@@ -226,7 +226,7 @@ public class EntityMonster extends GenshinEntity { ...@@ -226,7 +226,7 @@ public class EntityMonster extends GenshinEntity {
.setAuthorityPeerId(getWorld().getHostPeerId()) .setAuthorityPeerId(getWorld().getHostPeerId())
.setPoseId(this.getPoseId()) .setPoseId(this.getPoseId())
.setBlockId(3001) .setBlockId(3001)
.setBornType(MonsterBornType.MonsterBornDefault) .setBornType(MonsterBornType.MONSTER_BORN_DEFAULT)
.setSpecialNameId(40); .setSpecialNameId(40);
if (getMonsterData().getDescribeData() != null) { if (getMonsterData().getDescribeData() != null) {
...@@ -240,7 +240,7 @@ public class EntityMonster extends GenshinEntity { ...@@ -240,7 +240,7 @@ public class EntityMonster extends GenshinEntity {
.setAbilityInfo(AbilitySyncStateInfo.newBuilder()) .setAbilityInfo(AbilitySyncStateInfo.newBuilder())
.build(); .build();
monsterInfo.setWeaponList(weaponInfo); monsterInfo.addWeaponList(weaponInfo);
} }
entityInfo.setMonster(monsterInfo); entityInfo.setMonster(monsterInfo);
......
...@@ -23,7 +23,7 @@ public abstract class GenshinEntity { ...@@ -23,7 +23,7 @@ public abstract class GenshinEntity {
public GenshinEntity(GenshinScene scene) { public GenshinEntity(GenshinScene scene) {
this.scene = scene; this.scene = scene;
this.moveState = MotionState.MotionNone; this.moveState = MotionState.MOTION_NONE;
} }
public int getId() { public int getId() {
......
...@@ -104,7 +104,7 @@ public class FriendsList { ...@@ -104,7 +104,7 @@ public class FriendsList {
} }
// Handle // Handle
if (result == DealAddFriendResultType.DealAddFriendAccept) { // Request accepted if (result == DealAddFriendResultType.DEAL_ADD_FRIEND_ACCEPT) { // Request accepted
myFriendship.setIsFriend(true); myFriendship.setIsFriend(true);
theirFriendship.setIsFriend(true); theirFriendship.setIsFriend(true);
......
package emu.grasscutter.game.friends; package emu.grasscutter.game.friends;
import emu.grasscutter.net.proto.PlatformTypeOuterClass;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
...@@ -91,16 +92,16 @@ public class Friendship { ...@@ -91,16 +92,16 @@ public class Friendship {
.setUid(getFriendProfile().getUid()) .setUid(getFriendProfile().getUid())
.setNickname(getFriendProfile().getName()) .setNickname(getFriendProfile().getName())
.setLevel(getFriendProfile().getPlayerLevel()) .setLevel(getFriendProfile().getPlayerLevel())
.setAvatar(HeadImage.newBuilder().setAvatarId(getFriendProfile().getAvatarId())) .setAvatarId(HeadImage.newBuilder().setAvatarId(getFriendProfile().getAvatarId()).getAvatarId())
.setWorldLevel(getFriendProfile().getWorldLevel()) .setWorldLevel(getFriendProfile().getWorldLevel())
.setSignature(getFriendProfile().getSignature()) .setSignature(getFriendProfile().getSignature())
.setOnlineState(getFriendProfile().isOnline() ? FriendOnlineState.FRIEND_ONLINE : FriendOnlineState.FRIEND_DISCONNECT) .setOnlineState(getFriendProfile().isOnline() ? FriendOnlineState.FRIEND_ONLINE : FriendOnlineState.FREIEND_DISCONNECT)
.setIsMpModeAvailable(true) .setIsMpModeAvailable(true)
.setLastActiveTime(getFriendProfile().getLastActiveTime()) .setLastActiveTime(getFriendProfile().getLastActiveTime())
.setNameCardId(getFriendProfile().getNameCard()) .setNameCardId(getFriendProfile().getNameCard())
.setParam(getFriendProfile().getDaysSinceLogin()) .setParam(getFriendProfile().getDaysSinceLogin())
.setUnk1(1) .setIsGameSource(true)
.setUnk2(3) .setPlatformType(PlatformTypeOuterClass.PlatformType.PC)
.build(); .build();
return proto; return proto;
......
...@@ -7,6 +7,7 @@ import emu.grasscutter.game.props.EnterReason; ...@@ -7,6 +7,7 @@ import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType; import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason; import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass;
import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpNotify; import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpNotify;
import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpResultNotify; import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpResultNotify;
...@@ -26,7 +27,7 @@ public class MultiplayerManager { ...@@ -26,7 +27,7 @@ public class MultiplayerManager {
public void applyEnterMp(GenshinPlayer player, int targetUid) { public void applyEnterMp(GenshinPlayer player, int targetUid) {
GenshinPlayer target = getServer().getPlayerByUid(targetUid); GenshinPlayer target = getServer().getPlayerByUid(targetUid);
if (target == null) { 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; return;
} }
...@@ -71,12 +72,12 @@ public class MultiplayerManager { ...@@ -71,12 +72,12 @@ public class MultiplayerManager {
// Sanity checks - Dont let the requesting player join if they are already in multiplayer // Sanity checks - Dont let the requesting player join if they are already in multiplayer
if (requester.getWorld().isMultiplayer()) { 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; return;
} }
// Response packet // Response packet
request.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(hostPlayer, isAgreed, PlayerApplyEnterMpReason.PlayerJudge)); request.getRequester().sendPacket(new PacketPlayerApplyEnterMpResultNotify(hostPlayer, isAgreed, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_JUDGE));
// Declined // Declined
if (!isAgreed) { if (!isAgreed) {
...@@ -92,7 +93,7 @@ public class MultiplayerManager { ...@@ -92,7 +93,7 @@ public class MultiplayerManager {
world.addPlayer(hostPlayer); world.addPlayer(hostPlayer);
// Rejoin packet // 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 // Set scene pos and id of requester to the host player's
...@@ -104,7 +105,7 @@ public class MultiplayerManager { ...@@ -104,7 +105,7 @@ public class MultiplayerManager {
hostPlayer.getWorld().addPlayer(requester); hostPlayer.getWorld().addPlayer(requester);
// Packet // 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) { public boolean leaveCoop(GenshinPlayer player) {
...@@ -125,7 +126,7 @@ public class MultiplayerManager { ...@@ -125,7 +126,7 @@ public class MultiplayerManager {
world.addPlayer(player); world.addPlayer(player);
// Packet // 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; return true;
} }
...@@ -152,7 +153,7 @@ public class MultiplayerManager { ...@@ -152,7 +153,7 @@ public class MultiplayerManager {
World world = new World(victim); World world = new World(victim);
world.addPlayer(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; return true;
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment