Prevent the player from adding more than 1 of the same avatar if they had multiple paths

This commit is contained in:
Melledy
2024-07-31 00:20:04 -07:00
parent 0af791d800
commit a5750e3df2
2 changed files with 11 additions and 11 deletions

View File

@@ -5,7 +5,6 @@ import java.util.stream.Stream;
import org.bson.types.ObjectId;
import emu.lunarcore.GameConstants;
import emu.lunarcore.LunarCore;
import emu.lunarcore.data.GameData;
import emu.lunarcore.data.excel.AvatarExcel;
@@ -91,9 +90,17 @@ public class AvatarStorage extends BasePlayerManager implements Iterable<GameAva
return false;
}
// Dont add more than 1 main character
if (avatar.isHero() && this.hasAvatar(GameConstants.TRAILBLAZER_AVATAR_ID)) {
return false;
// Check if avatar has multiple paths
var pathExcel = GameData.getMultiplePathAvatarExcelMap().get(avatar.getAvatarId());
if (pathExcel != null) {
if (pathExcel.isDefault()) {
// Apply path to avatar
var path = this.getMultiPathById(avatar.getAvatarId());
avatar.setMultiPath(path);
} else {
// Skip if not a default path
return false;
}
}
// Set owner first

View File

@@ -85,13 +85,6 @@ public class GameAvatar implements GameEntity, IAvatar {
this.setExcel(excel);
}
public GameAvatar(AvatarMultiPath path) {
this();
this.avatarId = GameConstants.TRAILBLAZER_AVATAR_ID;
this.timestamp = System.currentTimeMillis() / 1000;
this.setMultiPath(path);
}
@Override
public Scene getScene() {
return this.getOwner().getScene();