mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
Fix whitespace [skip actions]
This commit is contained in:
@@ -4,17 +4,17 @@ import lombok.NonNull;
|
||||
|
||||
public abstract class BasePlayerDataManager {
|
||||
protected transient Player player;
|
||||
|
||||
|
||||
public BasePlayerDataManager() {}
|
||||
|
||||
|
||||
public BasePlayerDataManager(@NonNull Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
if (this.player == null) {
|
||||
this.player = player;
|
||||
|
||||
@@ -4,15 +4,15 @@ import lombok.NonNull;
|
||||
|
||||
public abstract class BasePlayerManager {
|
||||
protected transient final Player player;
|
||||
|
||||
|
||||
public BasePlayerManager(@NonNull Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the player to the database
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,60 +8,60 @@ import dev.morphia.annotations.Entity;
|
||||
@Entity(useDiscriminator = false)
|
||||
public class PlayerCollectionRecords {
|
||||
private Map<Integer, CollectionRecord> records;
|
||||
|
||||
|
||||
private Map<Integer, CollectionRecord> getRecords() {
|
||||
if (records == null) {
|
||||
records = new HashMap<>();
|
||||
records = new HashMap<>();
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
public void addRecord(int configId, long expiredMillisecond){
|
||||
Map<Integer, CollectionRecord> 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;
|
||||
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;
|
||||
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() {}
|
||||
|
||||
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 int getConfigId() {
|
||||
return configId;
|
||||
}
|
||||
|
||||
public long getExpiredTime() {
|
||||
return expiredTime;
|
||||
}
|
||||
public long getExpiredTime() {
|
||||
return expiredTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import static emu.grasscutter.game.props.OpenState.*;
|
||||
public class PlayerOpenStateManager extends BasePlayerDataManager {
|
||||
// Map of all open states that this player has. Do not put default values here.
|
||||
private Map<Integer, Integer> map;
|
||||
|
||||
|
||||
/*
|
||||
//DO NOT MODIFY. Based on conversation of official server and client, game version 2.7
|
||||
private static Set<OpenState> newPlayerOpenStates = Set.of(OPEN_STATE_DERIVATIVE_MALL,OPEN_STATE_PHOTOGRAPH,OPEN_STATE_BATTLE_PASS,OPEN_STATE_SHOP_TYPE_GENESISCRYSTAL,OPEN_STATE_SHOP_TYPE_RECOMMANDED,
|
||||
@@ -27,7 +27,7 @@ public class PlayerOpenStateManager extends BasePlayerDataManager {
|
||||
OPEN_STATE_WEAPON_PROMOTE,OPEN_STATE_AVATAR_PROMOTE,OPEN_STATE_AVATAR_TALENT,OPEN_STATE_WEAPON_UPGRADE,OPEN_STATE_RESIN,OPEN_STATE_RELIQUARY_UPGRADE,
|
||||
OPEN_STATE_SHOP_TYPE_VIRTUAL_SHOP,OPEN_STATE_RELIQUARY_PROMOTE);
|
||||
*/
|
||||
|
||||
|
||||
// For development. Remove entry when properly implemented
|
||||
// TODO - Set as boolean in OpenState
|
||||
public static final Set<OpenState> DEV_OPEN_STATES = Stream.of(OpenState.values())
|
||||
@@ -38,25 +38,25 @@ public class PlayerOpenStateManager extends BasePlayerDataManager {
|
||||
super(player);
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getOpenStateMap() {
|
||||
if (this.map == null) this.map = new HashMap<>();
|
||||
return this.map;
|
||||
}
|
||||
public Map<Integer, Integer> getOpenStateMap() {
|
||||
if (this.map == null) this.map = new HashMap<>();
|
||||
return this.map;
|
||||
}
|
||||
|
||||
public int getOpenState(OpenState openState) {
|
||||
return this.map.getOrDefault(openState.getValue(), 0);
|
||||
}
|
||||
|
||||
|
||||
public void setOpenState(OpenState openState, Integer value) {
|
||||
Integer previousValue = this.map.getOrDefault(openState.getValue(),0);
|
||||
if(value != previousValue) {
|
||||
if (value != previousValue) {
|
||||
this.map.put(openState.getValue(), value);
|
||||
player.getSession().send(new PacketOpenStateChangeNotify(openState.getValue(),value));
|
||||
}
|
||||
}
|
||||
|
||||
public void setOpenStates(Map<OpenState,Integer> openStatesChanged) {
|
||||
for(Map.Entry<OpenState, Integer> entry : openStatesChanged.entrySet()) {
|
||||
for (Map.Entry<OpenState, Integer> entry : openStatesChanged.entrySet()) {
|
||||
setOpenState(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -70,4 +70,4 @@ public class PlayerOpenStateManager extends BasePlayerDataManager {
|
||||
.filter(s -> s.getUnlockLevel() > 1 && s.getUnlockLevel() <= this.player.getLevel())
|
||||
.forEach(s -> this.setOpenState(s, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,75 +10,75 @@ import emu.grasscutter.game.avatar.Avatar;
|
||||
|
||||
@Entity
|
||||
public class TeamInfo {
|
||||
private String name;
|
||||
private List<Integer> avatars;
|
||||
|
||||
public TeamInfo() {
|
||||
this.name = "";
|
||||
this.avatars = new ArrayList<>(GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
||||
}
|
||||
private String name;
|
||||
private List<Integer> avatars;
|
||||
|
||||
public TeamInfo(List<Integer> avatars) {
|
||||
this.name = "";
|
||||
this.avatars = avatars;
|
||||
}
|
||||
public TeamInfo() {
|
||||
this.name = "";
|
||||
this.avatars = new ArrayList<>(GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public TeamInfo(List<Integer> avatars) {
|
||||
this.name = "";
|
||||
this.avatars = avatars;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<Integer> getAvatars() {
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return avatars.size();
|
||||
}
|
||||
|
||||
public boolean contains(Avatar avatar) {
|
||||
return getAvatars().contains(avatar.getAvatarId());
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean addAvatar(Avatar avatar) {
|
||||
if (contains(avatar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getAvatars().add(avatar.getAvatarId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeAvatar(int slot) {
|
||||
if (size() <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getAvatars().remove(slot);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void copyFrom(TeamInfo team) {
|
||||
copyFrom(team, GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
||||
}
|
||||
|
||||
public void copyFrom(TeamInfo team, int maxTeamSize) {
|
||||
// Clone avatar ids from team to copy from
|
||||
List<Integer> avatarIds = new ArrayList<>(team.getAvatars());
|
||||
|
||||
// Clear current avatar list first
|
||||
this.getAvatars().clear();
|
||||
|
||||
// Copy from team
|
||||
int len = Math.min(avatarIds.size(), maxTeamSize);
|
||||
for (int i = 0; i < len; i++) {
|
||||
int id = avatarIds.get(i);
|
||||
this.getAvatars().add(id);
|
||||
}
|
||||
}
|
||||
public List<Integer> getAvatars() {
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return avatars.size();
|
||||
}
|
||||
|
||||
public boolean contains(Avatar avatar) {
|
||||
return getAvatars().contains(avatar.getAvatarId());
|
||||
}
|
||||
|
||||
public boolean addAvatar(Avatar avatar) {
|
||||
if (contains(avatar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getAvatars().add(avatar.getAvatarId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeAvatar(int slot) {
|
||||
if (size() <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getAvatars().remove(slot);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void copyFrom(TeamInfo team) {
|
||||
copyFrom(team, GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
||||
}
|
||||
|
||||
public void copyFrom(TeamInfo team, int maxTeamSize) {
|
||||
// Clone avatar ids from team to copy from
|
||||
List<Integer> avatarIds = new ArrayList<>(team.getAvatars());
|
||||
|
||||
// Clear current avatar list first
|
||||
this.getAvatars().clear();
|
||||
|
||||
// Copy from team
|
||||
int len = Math.min(avatarIds.size(), maxTeamSize);
|
||||
for (int i = 0; i < len; i++) {
|
||||
int id = avatarIds.get(i);
|
||||
this.getAvatars().add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user