feat: ability to register new achievements

This commit is contained in:
ハムスケ ハム 2023-08-20 10:46:49 +09:00 committed by KingRainbow44
parent 873d190e46
commit 87d58d2a6f
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -318,6 +318,18 @@ public class Achievements {
this.player = player; this.player = player;
} }
this.registerNewAchievementsIfExist();
this.player.sendPacket(new PacketAchievementAllDataNotify(this.player)); this.player.sendPacket(new PacketAchievementAllDataNotify(this.player));
} }
private void registerNewAchievementsIfExist() {
GameData.getAchievementDataMap().values().stream()
.filter(AchievementData::isUsed)
.filter(a -> !this.achievementList.containsKey(a.getId()))
.forEach(a -> {
Grasscutter.getLogger().info("Registering a new achievement (id: {})", a.getId());
this.achievementList.put(a.getId(), new Achievement(AchievementStatus.UNFINISHED, a.getId(), a.getProgress(), 0, 0));
});
this.save();
}
} }