From 52ac9cd75e8d29ebd93dc30ca84317394e45adfe Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Mon, 24 Apr 2023 20:56:20 -0400 Subject: [PATCH] Remove obsolete code --- .../grasscutter/game/player/TeamManager.java | 9 +- .../send/PacketSceneTeamUpdateNotify.java | 93 +++++++++---------- 2 files changed, 48 insertions(+), 54 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index b17313452..eefd8963d 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -438,11 +438,6 @@ public final class TeamManager extends BasePlayerDataManager { this.usingTrialTeam = true; } - /** Displays the trial avatars. Picks the last avatar in the team. */ - public void trialAvatarTeamPostUpdate() { - this.trialAvatarTeamPostUpdate(this.getActiveTeam().size() - 1); - } - /** * Displays the trial avatars. * @@ -1035,7 +1030,7 @@ public final class TeamManager extends BasePlayerDataManager { this.addTrialAvatar( trialAvatarId, questId, - questId == 0 + questId != 0 ? GrantReason.GRANT_REASON_BY_QUEST : GrantReason.GRANT_REASON_BY_TRIAL_AVATAR_ACTIVITY); @@ -1073,11 +1068,11 @@ public final class TeamManager extends BasePlayerDataManager { public void removeTrialAvatar(List trialAvatarIds) { if (!this.isUsingTrialTeam()) throw new RuntimeException("Player is not using a trial team."); + this.removeTrialAvatarTeam(trialAvatarIds); this.getPlayer() .sendPacket( new PacketAvatarDelNotify( trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList())); - this.removeTrialAvatarTeam(trialAvatarIds); // Update the team. if (trialAvatarIds.size() == 1) this.getPlayer().sendPacket(new PacketAvatarTeamUpdateNotify()); 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 f1cf8c77d..198f5a46d 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTeamUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneTeamUpdateNotify.java @@ -1,47 +1,46 @@ -package emu.grasscutter.server.packet.send; - -import emu.grasscutter.game.entity.EntityAvatar; -import emu.grasscutter.game.player.Player; -import emu.grasscutter.net.packet.BasePacket; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; -import emu.grasscutter.net.proto.SceneTeamAvatarOuterClass.SceneTeamAvatar; -import emu.grasscutter.net.proto.SceneTeamUpdateNotifyOuterClass.SceneTeamUpdateNotify; - -public class PacketSceneTeamUpdateNotify extends BasePacket { - - public PacketSceneTeamUpdateNotify(Player player) { - super(PacketOpcodes.SceneTeamUpdateNotify); - - SceneTeamUpdateNotify.Builder proto = - SceneTeamUpdateNotify.newBuilder().setIsInMp(player.getWorld().isMultiplayer()); - - for (Player p : player.getWorld().getPlayers()) { - for (EntityAvatar entityAvatar : p.getTeamManager().getActiveTeam()) { - SceneTeamAvatar.Builder avatarProto = - SceneTeamAvatar.newBuilder() - .setPlayerUid(p.getUid()) - .setAvatarGuid(entityAvatar.getAvatar().getGuid()) - .setSceneId(p.getSceneId()) - .setEntityId(entityAvatar.getId()) - .setSceneEntityInfo(entityAvatar.toProto()) - .setWeaponGuid(entityAvatar.getAvatar().getWeapon().getGuid()) - .setWeaponEntityId(entityAvatar.getWeaponEntityId()) - .setIsPlayerCurAvatar(p.getTeamManager().getCurrentAvatarEntity() == entityAvatar) - .setIsOnScene(p.getTeamManager().getCurrentAvatarEntity() == entityAvatar) - .setAvatarAbilityInfo(AbilitySyncStateInfo.newBuilder()) - .setWeaponAbilityInfo(AbilitySyncStateInfo.newBuilder()) - .setAbilityControlBlock(entityAvatar.getAbilityControlBlock()); - - if (player.getWorld().isMultiplayer()) { - avatarProto.setAvatarInfo(entityAvatar.getAvatar().toProto()); - avatarProto.setSceneAvatarInfo(entityAvatar.getSceneAvatarInfo()); // why mihoyo... - } - - proto.addSceneTeamAvatarList(avatarProto); - } - } - - this.setData(proto); - } -} +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.game.player.Player; +import emu.grasscutter.net.packet.BasePacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; +import emu.grasscutter.net.proto.SceneTeamAvatarOuterClass.SceneTeamAvatar; +import emu.grasscutter.net.proto.SceneTeamUpdateNotifyOuterClass.SceneTeamUpdateNotify; + +public class PacketSceneTeamUpdateNotify extends BasePacket { + + public PacketSceneTeamUpdateNotify(Player player) { + super(PacketOpcodes.SceneTeamUpdateNotify); + + var proto = SceneTeamUpdateNotify.newBuilder() + .setIsInMp(player.getWorld().isMultiplayer()); + + for (var p : player.getWorld().getPlayers()) { + for (var entityAvatar : p.getTeamManager().getActiveTeam()) { + var avatarProto = + SceneTeamAvatar.newBuilder() + .setPlayerUid(p.getUid()) + .setAvatarGuid(entityAvatar.getAvatar().getGuid()) + .setSceneId(p.getSceneId()) + .setEntityId(entityAvatar.getId()) + .setSceneEntityInfo(entityAvatar.toProto()) + .setWeaponGuid(entityAvatar.getAvatar().getWeapon().getGuid()) + .setWeaponEntityId(entityAvatar.getWeaponEntityId()) + .setIsPlayerCurAvatar(p.getTeamManager().getCurrentAvatarEntity() == entityAvatar) + .setIsOnScene(p.getTeamManager().getCurrentAvatarEntity() == entityAvatar) + .setAvatarAbilityInfo(AbilitySyncStateInfo.newBuilder()) + .setWeaponAbilityInfo(AbilitySyncStateInfo.newBuilder()) + .setAbilityControlBlock(entityAvatar.getAbilityControlBlock()); + + if (player.getWorld().isMultiplayer()) { + avatarProto.setAvatarInfo(entityAvatar.getAvatar().toProto()); + avatarProto.setSceneAvatarInfo(entityAvatar.getSceneAvatarInfo()); // why mihoyo... + } + + proto.addSceneTeamAvatarList(avatarProto); + } + } + + this.setData(proto); + } +}