mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Change unlocked scenes from lists to sets
This commit is contained in:
@@ -80,6 +80,7 @@ import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@Entity(value = "players", useDiscriminator = false)
|
||||
@@ -111,7 +112,7 @@ public class Player {
|
||||
@Getter private Set<Integer> nameCardList;
|
||||
@Getter private Set<Integer> flyCloakList;
|
||||
@Getter private Set<Integer> costumeList;
|
||||
@Getter private Set<Integer> rewardedLevels;
|
||||
@Getter @Setter private Set<Integer> rewardedLevels;
|
||||
@Getter @Setter private Set<Integer> realmList;
|
||||
@Getter private Set<Integer> unlockedForgingBlueprints;
|
||||
@Getter private Set<Integer> unlockedCombines;
|
||||
@@ -120,10 +121,10 @@ public class Player {
|
||||
@Getter private Map<Long, ExpeditionInfo> expeditionInfo;
|
||||
@Getter private Map<Integer, Integer> unlockedRecipies;
|
||||
@Getter private List<ActiveForgeData> activeForges;
|
||||
@Getter private Map<Integer,Integer> questGlobalVariables;
|
||||
@Getter private Map<Integer, Integer> questGlobalVariables;
|
||||
@Getter private Map<Integer, Integer> openStates;
|
||||
@Getter @Setter private Map<Integer, List<Integer>> unlockedSceneAreas;
|
||||
@Getter @Setter private Map<Integer, List<Integer>> unlockedScenePoints;
|
||||
@Getter @Setter private Map<Integer, Set<Integer>> unlockedSceneAreas;
|
||||
@Getter @Setter private Map<Integer, Set<Integer>> unlockedScenePoints;
|
||||
|
||||
@Transient private long nextGuid = 0;
|
||||
@Transient @Getter @Setter private int peerId;
|
||||
@@ -388,6 +389,14 @@ public class Player {
|
||||
return expeditionLimit;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedSceneAreas(int sceneId) {
|
||||
return this.unlockedSceneAreas.computeIfAbsent(sceneId, i -> new CopyOnWriteArraySet<>());
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedScenePoints(int sceneId) {
|
||||
return this.unlockedScenePoints.computeIfAbsent(sceneId, i -> new CopyOnWriteArraySet<>());
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_LEVEL);
|
||||
}
|
||||
@@ -881,10 +890,6 @@ public class Player {
|
||||
return this.birthday.getDay() > 0;
|
||||
}
|
||||
|
||||
public void setRewardedLevels(Set<Integer> rewardedLevels) {
|
||||
this.rewardedLevels = rewardedLevels;
|
||||
}
|
||||
|
||||
public SocialDetail.Builder getSocialDetail() {
|
||||
List<SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo> socialShowAvatarInfoList = new ArrayList<>();
|
||||
if (this.isOnline()) {
|
||||
|
||||
@@ -44,19 +44,8 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
|
||||
// Auto-unlock the first statue and map area, until we figure out how to make
|
||||
// that particular statue interactable.
|
||||
if (!this.player.getUnlockedScenePoints().containsKey(3)) {
|
||||
this.player.getUnlockedScenePoints().put(3, new ArrayList<>());
|
||||
}
|
||||
if (!this.player.getUnlockedScenePoints().get(3).contains(7)) {
|
||||
this.player.getUnlockedScenePoints().get(3).add(7);
|
||||
}
|
||||
|
||||
if (!this.player.getUnlockedSceneAreas().containsKey(3)) {
|
||||
this.player.getUnlockedSceneAreas().put(3, new ArrayList<>());
|
||||
}
|
||||
if (!this.player.getUnlockedSceneAreas().get(3).contains(1)) {
|
||||
this.player.getUnlockedSceneAreas().get(3).add(1);
|
||||
}
|
||||
this.player.getUnlockedScenePoints(3).add(7);
|
||||
this.player.getUnlockedSceneAreas(3).add(1);
|
||||
}
|
||||
|
||||
/******************************************************************************************************************
|
||||
@@ -211,16 +200,13 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
String key = sceneId + "_" + pointId;
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(key);
|
||||
|
||||
if (scenePointEntry == null || this.player.getUnlockedScenePoints().getOrDefault(sceneId, List.of()).contains(pointId)) {
|
||||
if (scenePointEntry == null || this.player.getUnlockedScenePoints(sceneId).contains(pointId)) {
|
||||
this.player.sendPacket(new PacketUnlockTransPointRsp(Retcode.RET_FAIL));
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the point to the list of unlocked points for its scene.
|
||||
if (!this.player.getUnlockedScenePoints().containsKey(sceneId)) {
|
||||
this.player.getUnlockedScenePoints().put(sceneId, new ArrayList<>());
|
||||
}
|
||||
this.player.getUnlockedScenePoints().get(sceneId).add(pointId);
|
||||
this.player.getUnlockedScenePoints(sceneId).add(pointId);
|
||||
|
||||
// Give primogems and Adventure EXP for unlocking.
|
||||
var primos = new GameItem(GameData.getItemDataMap().get(201), 5);
|
||||
@@ -240,16 +226,8 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
}
|
||||
|
||||
public void unlockSceneArea(int sceneId, int areaId) {
|
||||
// Check whether this area is already unlocked.
|
||||
if (this.player.getUnlockedSceneAreas().getOrDefault(sceneId, List.of()).contains(areaId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the area to the list of unlocked areas in its scene.
|
||||
if (!this.player.getUnlockedSceneAreas().containsKey(sceneId)) {
|
||||
this.player.getUnlockedSceneAreas().put(sceneId, new ArrayList<>());
|
||||
}
|
||||
this.player.getUnlockedSceneAreas().get(sceneId).add(areaId);
|
||||
this.player.getUnlockedSceneAreas(sceneId).add(areaId);
|
||||
|
||||
// Send packet.
|
||||
this.player.sendPacket(new PacketSceneAreaUnlockNotify(sceneId, areaId));
|
||||
|
||||
Reference in New Issue
Block a user