mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-12 13:24:36 +01:00
Prevent the player from adding more than 1 of the same avatar if they had multiple paths
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user