mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
Move PlayerManagers and GameServerSystems around
This commit is contained in:
@@ -31,7 +31,6 @@ import emu.grasscutter.game.mail.MailHandler;
|
||||
import emu.grasscutter.game.managers.CookingManager;
|
||||
import emu.grasscutter.game.managers.FurnitureManager;
|
||||
import emu.grasscutter.game.managers.ResinManager;
|
||||
import emu.grasscutter.game.managers.collection.CollectionRecordStore;
|
||||
import emu.grasscutter.game.managers.deforestation.DeforestationManager;
|
||||
import emu.grasscutter.game.managers.energy.EnergyManager;
|
||||
import emu.grasscutter.game.managers.forging.ActiveForgeData;
|
||||
@@ -158,7 +157,7 @@ public class Player {
|
||||
private TowerData towerData;
|
||||
private PlayerGachaInfo gachaInfo;
|
||||
private PlayerOpenStateManager openStateManager;
|
||||
private CollectionRecordStore collectionRecordStore;
|
||||
private PlayerCollectionRecords collectionRecordStore;
|
||||
private ArrayList<ShopLimit> shopLimit;
|
||||
|
||||
@Getter private transient GameHome home;
|
||||
@@ -213,7 +212,7 @@ public class Player {
|
||||
this.flyCloakList = new HashSet<>();
|
||||
this.costumeList = new HashSet<>();
|
||||
this.towerData = new TowerData();
|
||||
this.collectionRecordStore = new CollectionRecordStore();
|
||||
this.collectionRecordStore = new PlayerCollectionRecords();
|
||||
this.unlockedForgingBlueprints = new HashSet<>();
|
||||
this.unlockedCombines = new HashSet<>();
|
||||
this.unlockedFurniture = new HashSet<>();
|
||||
@@ -1148,9 +1147,9 @@ public class Player {
|
||||
this.battlePassManager.getMissions().values().removeIf(mission -> mission.getData() == null);
|
||||
}
|
||||
|
||||
public CollectionRecordStore getCollectionRecordStore() {
|
||||
public PlayerCollectionRecords getCollectionRecordStore() {
|
||||
if(this.collectionRecordStore==null){
|
||||
this.collectionRecordStore = new CollectionRecordStore();
|
||||
this.collectionRecordStore = new PlayerCollectionRecords();
|
||||
}
|
||||
return collectionRecordStore;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
@Entity
|
||||
public class PlayerCollectionRecords {
|
||||
private Map<Integer, CollectionRecord> records;
|
||||
|
||||
private Map<Integer, CollectionRecord> getRecords() {
|
||||
if (records == null) {
|
||||
records = new HashMap<>();
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
public void addRecord(int configId, long expiredMillisecond){
|
||||
Map<Integer, CollectionRecord> records;
|
||||
synchronized (records = getRecords()) {
|
||||
records.put(configId, new CollectionRecord(configId, expiredMillisecond + System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean findRecord(int configId) {
|
||||
Map<Integer, CollectionRecord> records;
|
||||
synchronized (records = getRecords()) {
|
||||
CollectionRecord record = records.get(configId);
|
||||
|
||||
if (record == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean expired = record.getExpiredTime() < System.currentTimeMillis();
|
||||
|
||||
if (expired) {
|
||||
records.remove(configId);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
public static class CollectionRecord {
|
||||
private int configId;
|
||||
private long expiredTime;
|
||||
|
||||
@Deprecated // Morphia
|
||||
public CollectionRecord() {}
|
||||
|
||||
public CollectionRecord(int configId, long expiredTime) {
|
||||
this.configId = configId;
|
||||
this.expiredTime = expiredTime;
|
||||
}
|
||||
|
||||
public int getConfigId() {
|
||||
return configId;
|
||||
}
|
||||
|
||||
public long getExpiredTime() {
|
||||
return expiredTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user