Skip to content

Commit

Permalink
misc: 不要序列化PlayerMeta的uuid
Browse files Browse the repository at this point in the history
    - 转而在获取时为他们赋值
  • Loading branch information
MATRIX-feather committed Oct 12, 2024
1 parent b2299d1 commit 784ae29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public PlayerMeta getPlayerMeta(OfflinePlayer player)
var storedMeta = this.get(uuid.toString());
if (storedMeta != null)
{
initializePlayerMeta(storedMeta);
initializePlayerMeta(storedMeta, uuid);
trackedPlayerMetaMap.put(uuid, storedMeta);

return storedMeta;
Expand All @@ -228,13 +228,15 @@ public PlayerMeta getPlayerMeta(OfflinePlayer player)
return metaInstance;
}

private void initializePlayerMeta(PlayerMeta c)
private void initializePlayerMeta(PlayerMeta meta, UUID matchingUUID)
{
meta.uniqueId = matchingUUID;

//要设置给c.unlockedDisguises的列表
var list = new ObjectArrayList<DisguiseMeta>();

//原始列表
var unlockedDisguiseIdentifiers = c.getUnlockedDisguiseIdentifiers();
var unlockedDisguiseIdentifiers = meta.getUnlockedDisguiseIdentifiers();

//先对原始列表排序
unlockedDisguiseIdentifiers.sort(null);
Expand All @@ -247,12 +249,12 @@ private void initializePlayerMeta(PlayerMeta c)
if (type != null)
list.add(new DisguiseMeta(disguiseId, DisguiseTypes.fromId(disguiseId)));
else
logger.warn("Unknown disguise identifier data '%s' owned by '%s'".formatted(disguiseId, c.uniqueId));
logger.warn("Unknown disguise identifier data '%s' owned by '%s'".formatted(disguiseId, matchingUUID));
});

//设置可用的伪装列表并对其加锁
c.setUnlockedDisguises(list);
c.lockDisguiseList();
meta.setUnlockedDisguises(list);
meta.lockDisguiseList();
}

@Override
Expand Down Expand Up @@ -320,7 +322,7 @@ public void loadAll()
var meta = this.get(fileName);
if (meta == null) continue;

initializePlayerMeta(meta);
initializePlayerMeta(meta, uuid);

this.trackedPlayerMetaMap.put(uuid, meta);
count++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PlayerMeta
/**
* 玩家的UUID
*/
@Expose
@Expose(serialize = false)
public UUID uniqueId;

/**
Expand Down

0 comments on commit 784ae29

Please sign in to comment.