mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 06:14:45 +01:00
Fix error with hero paths on login if they dont exist in the database
This commit is contained in:
@@ -72,7 +72,7 @@ public class AvatarStorage extends BasePlayerManager implements Iterable<GameAva
|
|||||||
/**
|
/**
|
||||||
* Updates hero types for players. Will create hero types if they dont exist already.
|
* Updates hero types for players. Will create hero types if they dont exist already.
|
||||||
*/
|
*/
|
||||||
public void setupHeroPaths() {
|
public void validateHeroPaths() {
|
||||||
for (HeroExcel heroExcel : GameData.getHeroExcelMap().values()) {
|
for (HeroExcel heroExcel : GameData.getHeroExcelMap().values()) {
|
||||||
if (getHeroPaths().containsKey(heroExcel.getId())) continue;
|
if (getHeroPaths().containsKey(heroExcel.getId())) continue;
|
||||||
|
|
||||||
@@ -108,6 +108,9 @@ public class AvatarStorage extends BasePlayerManager implements Iterable<GameAva
|
|||||||
this.heroPaths.put(heroPath.getId(), heroPath);
|
this.heroPaths.put(heroPath.getId(), heroPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Setup hero paths if they dont exist
|
||||||
|
this.validateHeroPaths();
|
||||||
|
|
||||||
// Load avatars
|
// Load avatars
|
||||||
Stream<GameAvatar> stream = LunarCore.getGameDatabase().getObjects(GameAvatar.class, "ownerUid", this.getPlayer().getUid());
|
Stream<GameAvatar> stream = LunarCore.getGameDatabase().getObjects(GameAvatar.class, "ownerUid", this.getPlayer().getUid());
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class Player {
|
|||||||
this.gachaInfo = new PlayerGachaInfo();
|
this.gachaInfo = new PlayerGachaInfo();
|
||||||
|
|
||||||
// Setup hero paths
|
// Setup hero paths
|
||||||
this.getAvatars().setupHeroPaths();
|
this.getAvatars().validateHeroPaths();
|
||||||
|
|
||||||
// Give us the main character
|
// Give us the main character
|
||||||
// TODO script tutorial
|
// TODO script tutorial
|
||||||
@@ -622,9 +622,6 @@ public class Player {
|
|||||||
this.getChallengeManager().loadFromDatabase();
|
this.getChallengeManager().loadFromDatabase();
|
||||||
this.getRogueManager().loadFromDatabase();
|
this.getRogueManager().loadFromDatabase();
|
||||||
|
|
||||||
// Post database load
|
|
||||||
this.getAvatars().setupHeroPaths();
|
|
||||||
|
|
||||||
// Update stamina
|
// Update stamina
|
||||||
this.updateStamina();
|
this.updateStamina();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user