Commit b266854c authored by GanyusLeftHorn's avatar GanyusLeftHorn Committed by Melledy
Browse files

Handle existing players who might already have passed a level.

parent af7bbdaa
...@@ -463,7 +463,7 @@ public class Player { ...@@ -463,7 +463,7 @@ public class Player {
this.updateProfile(); this.updateProfile();
// Handle OpenState unlocks from level-up. // Handle OpenState unlocks from level-up.
this.getOpenStateManager().onPlayerLevelUp(); this.getOpenStateManager().unlockLevelDependentStates();
return true; return true;
} }
...@@ -1535,7 +1535,11 @@ public class Player { ...@@ -1535,7 +1535,11 @@ public class Player {
this.forgingManager.sendForgeDataNotify(); this.forgingManager.sendForgeDataNotify();
this.resinManager.onPlayerLogin(); this.resinManager.onPlayerLogin();
this.cookingManager.sendCookDataNofity(); this.cookingManager.sendCookDataNofity();
// Unlock in case this is an existing user that reached a level before we implemented unlocking.
this.openStateManager.unlockLevelDependentStates();
this.openStateManager.onPlayerLogin(); this.openStateManager.onPlayerLogin();
getTodayMoonCard(); // The timer works at 0:0, some users log in after that, use this method to check if they have received a reward today or not. If not, send the reward. getTodayMoonCard(); // The timer works at 0:0, some users log in after that, use this method to check if they have received a reward today or not. If not, send the reward.
// Battle Pass trigger // Battle Pass trigger
......
...@@ -55,11 +55,9 @@ public class PlayerOpenStateManager { ...@@ -55,11 +55,9 @@ public class PlayerOpenStateManager {
public void setOpenState(OpenState openState, Integer value) { public void setOpenState(OpenState openState, Integer value) {
Integer previousValue = this.map.getOrDefault(openState.getValue(),0); Integer previousValue = this.map.getOrDefault(openState.getValue(),0);
if(!(value == previousValue)) { if(value != previousValue) {
this.map.put(openState.getValue(), value); this.map.put(openState.getValue(), value);
player.getSession().send(new PacketOpenStateChangeNotify(openState.getValue(),value)); player.getSession().send(new PacketOpenStateChangeNotify(openState.getValue(),value));
} else {
Grasscutter.getLogger().debug("Warning: OpenState {} is already set to {}!", openState, value);
} }
} }
...@@ -73,9 +71,9 @@ public class PlayerOpenStateManager { ...@@ -73,9 +71,9 @@ public class PlayerOpenStateManager {
player.getSession().send(new PacketOpenStateUpdateNotify(this)); player.getSession().send(new PacketOpenStateUpdateNotify(this));
} }
public void onPlayerLevelUp() { public void unlockLevelDependentStates() {
Stream.of(OpenState.values()) Stream.of(OpenState.values())
.filter(s -> s.getUnlockLevel() == this.player.getLevel()) .filter(s -> s.getUnlockLevel() > 1 && s.getUnlockLevel() <= this.player.getLevel())
.forEach(s -> this.setOpenState(s, 1)); .forEach(s -> this.setOpenState(s, 1));
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment