Fix showcase not updating when new characters/discs are added

This commit is contained in:
Melledy
2025-11-21 02:05:36 -08:00
parent e25d58d7f5
commit fdd4264b40
4 changed files with 67 additions and 13 deletions

View File

@@ -15,12 +15,16 @@ import emu.nebula.game.player.PlayerChangeInfo;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.Getter;
import lombok.Setter;
@Getter
public class CharacterStorage extends PlayerManager {
private final Int2ObjectMap<GameCharacter> characters;
private final Int2ObjectMap<GameDisc> discs;
@Setter private boolean updateCharHandbook;
@Setter private boolean updateDiscHandbook;
public CharacterStorage(Player player) {
super(player);
@@ -63,6 +67,9 @@ public class CharacterStorage extends PlayerManager {
// Save to database
character.save();
// Set flag for player to update character skins in their handbook
this.setUpdateCharHandbook(true);
// Add to characters
this.characters.put(character.getCharId(), character);
return character;
@@ -138,6 +145,9 @@ public class CharacterStorage extends PlayerManager {
// Save to database
disc.save();
// Set flag for player to update discs in their handbook
this.setUpdateDiscHandbook(true);
// Add to discs
this.discs.put(disc.getDiscId(), disc);
return disc;

View File

@@ -245,7 +245,7 @@ public class GameCharacter implements GameDatabaseObject {
// Set advance skin
this.skin = this.getData().getAdvanceSkinId();
// Send packets
// Add next packages
this.getPlayer().addNextPackage(
NetMsgId.character_skin_gain_notify,
Skin.newInstance().setNew(UI32.newInstance().setValue(this.getSkin()))
@@ -254,6 +254,9 @@ public class GameCharacter implements GameDatabaseObject {
NetMsgId.character_skin_change_notify,
SkinChange.newInstance().setCharId(this.getCharId()).setSkinId(this.getSkin())
);
// Set flag for player to update character skins in their handbook
this.getPlayer().getCharacters().setUpdateCharHandbook(true);
}
// Save to database

View File

@@ -152,12 +152,15 @@ public class Inventory extends PlayerManager implements GameDatabaseObject {
// Save to database
Nebula.getGameDatabase().addToSet(this, this.getUid(), "extraSkins", id);
// Send packet
// Send packets
this.getPlayer().addNextPackage(
NetMsgId.character_skin_gain_notify,
Skin.newInstance().setNew(UI32.newInstance().setValue(id))
);
// Set flag for player to update character skins in their handbook
this.getPlayer().getCharacters().setUpdateCharHandbook(true);
// Success
return true;
}