mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-30 06:13:52 +00:00
Fix trial avatar removal
it is still *sort of* broken when combined with early leaving a domain
This commit is contained in:
parent
b77c75a296
commit
ed3186a2b2
@ -64,7 +64,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
|
|
||||||
public TeamManager() {
|
public TeamManager() {
|
||||||
this.mpTeam = new TeamInfo();
|
this.mpTeam = new TeamInfo();
|
||||||
this.avatars = new ArrayList<>();
|
this.avatars = Collections.synchronizedList(new ArrayList<>());
|
||||||
this.gadgets = new HashSet<>();
|
this.gadgets = new HashSet<>();
|
||||||
this.teamResonances = new IntOpenHashSet();
|
this.teamResonances = new IntOpenHashSet();
|
||||||
this.teamResonancesConfig = new IntOpenHashSet();
|
this.teamResonancesConfig = new IntOpenHashSet();
|
||||||
@ -551,10 +551,13 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
scene, player.getAvatars().getAvatarById(avatarId)
|
scene, player.getAvatars().getAvatarById(avatarId)
|
||||||
)));
|
)));
|
||||||
} else {
|
} else {
|
||||||
var index = 0;
|
|
||||||
// Restores all avatars from the player's avatar storage.
|
// Restores all avatars from the player's avatar storage.
|
||||||
// If the avatar is already in the team, it will not be added.
|
// If the avatar is already in the team, it will not be added.
|
||||||
for (var avatar : this.getCurrentTeamInfo().getAvatars()) {
|
// TODO: Fix order in which avatars are added.
|
||||||
|
// Currently, they are added from last to first.
|
||||||
|
var avatars = this.getCurrentTeamInfo().getAvatars();
|
||||||
|
for (var index = 0; index < avatars.size(); index++) {
|
||||||
|
var avatar = avatars.get(index);
|
||||||
if (this.getActiveTeam().stream()
|
if (this.getActiveTeam().stream()
|
||||||
.map(entity -> entity.getAvatar().getAvatarId())
|
.map(entity -> entity.getAvatar().getAvatarId())
|
||||||
.toList()
|
.toList()
|
||||||
@ -564,10 +567,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
var avatarData = player.getAvatars().getAvatarById(avatar);
|
var avatarData = player.getAvatars().getAvatarById(avatar);
|
||||||
if (avatarData == null) continue;
|
if (avatarData == null) continue;
|
||||||
|
|
||||||
this.getActiveTeam()
|
this.getActiveTeam().add(index, new EntityAvatar(scene, avatarData));
|
||||||
.add(
|
|
||||||
index++,
|
|
||||||
new EntityAvatar(scene, avatarData));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1091,6 +1091,10 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
* @param trialAvatarIds List of trial avatar IDs.
|
* @param trialAvatarIds List of trial avatar IDs.
|
||||||
*/
|
*/
|
||||||
public void removeTrialAvatar(List<Integer> trialAvatarIds) {
|
public void removeTrialAvatar(List<Integer> trialAvatarIds) {
|
||||||
|
// Check if the player is using a trial team.
|
||||||
|
if (!this.isUsingTrialTeam())
|
||||||
|
throw new IllegalStateException("Player is not using trial team.");
|
||||||
|
|
||||||
this.getPlayer()
|
this.getPlayer()
|
||||||
.sendPacket(
|
.sendPacket(
|
||||||
new PacketAvatarDelNotify(
|
new PacketAvatarDelNotify(
|
||||||
|
@ -16,6 +16,10 @@ public class ExecRemoveTrialAvatar extends QuestExecHandler {
|
|||||||
Grasscutter.getLogger()
|
Grasscutter.getLogger()
|
||||||
.debug("Removed trial avatar from team for quest {}", quest.getSubQuestId());
|
.debug("Removed trial avatar from team for quest {}", quest.getSubQuestId());
|
||||||
return true;
|
return true;
|
||||||
|
} catch (IllegalStateException ignored) {
|
||||||
|
// The player does not have any trial avatars equipped.
|
||||||
|
Grasscutter.getLogger().warn("Attempted to remove trial avatars from player with none equipped.");
|
||||||
|
return true;
|
||||||
} catch (RuntimeException exception) {
|
} catch (RuntimeException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user