From 375bb77abeda88e5ab5f9d9591bd219c52467563 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Thu, 20 Apr 2023 00:58:23 -0400 Subject: [PATCH] Attempt to keep parity with `Grasscutter-Quests` & Fix add trial avatar issue --- .../grasscutter/game/player/TeamManager.java | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index ff6a9d3fb..9ecaed5cd 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -132,7 +132,7 @@ public final class TeamManager extends BasePlayerDataManager { } public EntityAvatar getCurrentAvatarEntity() { - return this.getActiveTeam().get(currentCharacterIndex); + return this.getActiveTeam().get(this.currentCharacterIndex); } public boolean isSpawned() { @@ -431,7 +431,7 @@ public final class TeamManager extends BasePlayerDataManager { this.setPreviousIndex(this.getCurrentCharacterIndex()); if (save) { - var originalTeam = getCurrentTeamInfo(); + var originalTeam = this.getCurrentTeamInfo(); this.getTrialAvatarTeam().copyFrom(originalTeam); } else this.getActiveTeam().clear(); @@ -480,15 +480,14 @@ public final class TeamManager extends BasePlayerDataManager { /** * Get the GUID of a trial avatar. * - * @param avatarId The avatar ID. + * @param trialAvatarId The avatar ID. * @return The GUID of the avatar. */ - public long getTrialAvatarGuid(int avatarId) { - return getTrialAvatars().values().stream() - .filter(avatar -> avatar.getTrialAvatarId() == avatarId) + public long getTrialAvatarGuid(int trialAvatarId) { + return this.getTrialAvatars().values().stream() + .filter(avatar -> avatar.getTrialAvatarId() == trialAvatarId) .map(Avatar::getGuid) - .findFirst() - .orElse(0L); + .findFirst().orElse(0L); } /** Rollback changes from using a trial avatar team. */ @@ -515,9 +514,9 @@ public final class TeamManager extends BasePlayerDataManager { /** * Removes a collection of avatars from the trial avatar team. * - * @param avatarIds The avatar IDs to remove. + * @param trialAvatarIds The avatar IDs to remove. */ - public void removeTrialAvatarTeam(List avatarIds) { + public void removeTrialAvatarTeam(List trialAvatarIds) { var player = this.getPlayer(); // Disable the trial team. @@ -525,16 +524,16 @@ public final class TeamManager extends BasePlayerDataManager { this.trialAvatarTeam = new TeamInfo(); // Remove the avatars from the team. - avatarIds.forEach( - avatarId -> { + trialAvatarIds.forEach( + trialAvatarId -> { this.getActiveTeam() .forEach( x -> player .getScene() .removeEntity(x, VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE)); - this.getActiveTeam().removeIf(x -> x.getAvatar().getTrialAvatarId() == avatarId); - this.getTrialAvatars().values().removeIf(x -> x.getTrialAvatarId() == avatarId); + this.getActiveTeam().removeIf(x -> x.getAvatar().getTrialAvatarId() == trialAvatarId); + this.getTrialAvatars().values().removeIf(x -> x.getTrialAvatarId() == trialAvatarId); }); // Re-add the avatars to the team. @@ -1021,19 +1020,19 @@ public final class TeamManager extends BasePlayerDataManager { /** * Adds a list of trial avatars to the player's team. * - * @param avatarIds List of trial avatar IDs. + * @param trialAvatarIds List of trial avatar IDs. * @param questId The ID of the quest this trial team is associated with. * @param save Whether to retain the currently equipped avatars. */ - public void addTrialAvatars(List avatarIds, int questId, boolean save) { + public void addTrialAvatars(List trialAvatarIds, int questId, boolean save) { this.setupTrialAvatars(save); // Perform initial setup. // Add the avatars to the team. - avatarIds.forEach( - avatarId -> { + trialAvatarIds.forEach( + trialAvatarId -> { var result = this.addTrialAvatar( - avatarId, + trialAvatarId, questId, questId == 0 ? GrantReason.GRANT_REASON_BY_QUEST @@ -1043,7 +1042,7 @@ public final class TeamManager extends BasePlayerDataManager { }); // Update the team. - this.trialAvatarTeamPostUpdate(questId == 0 ? getActiveTeam().size() - 1 : 0); + this.trialAvatarTeamPostUpdate(questId != 0 ? this.getActiveTeam().size() - 1 : 0); } /** Removes all trial avatars from the player's team. */ @@ -1059,26 +1058,26 @@ public final class TeamManager extends BasePlayerDataManager { * Removes a trial avatar from the player's team. Additionally, unlocks the ability to change the * team configuration. * - * @param avatarId The ID of the avatar. + * @param trialAvatarId The ID of the avatar. */ - public void removeTrialAvatar(int avatarId) { - this.removeTrialAvatar(List.of(avatarId)); + public void removeTrialAvatar(int trialAvatarId) { + this.removeTrialAvatar(List.of(trialAvatarId)); } /** * Removes a collection of trial avatars from the player's team. * - * @param avatarIds List of trial avatar IDs. + * @param trialAvatarIds List of trial avatar IDs. */ - public void removeTrialAvatar(List avatarIds) { + public void removeTrialAvatar(List trialAvatarIds) { if (!this.isUsingTrialTeam()) throw new RuntimeException("Player is not using a trial team."); this.getPlayer() .sendPacket( - new PacketAvatarDelNotify(avatarIds.stream().map(this::getTrialAvatarGuid).toList())); - this.removeTrialAvatarTeam(avatarIds); + new PacketAvatarDelNotify(trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList())); + this.removeTrialAvatarTeam(trialAvatarIds); // Update the team. - if (avatarIds.size() == 1) this.getPlayer().sendPacket(new PacketAvatarTeamUpdateNotify()); + if (trialAvatarIds.size() == 1) this.getPlayer().sendPacket(new PacketAvatarTeamUpdateNotify()); } }