Skip to content

Commit

Permalink
Hide resin from map when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Birdulon committed Aug 21, 2022
1 parent a436ae9 commit 4b03770
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package emu.grasscutter.server.packet.send;

import static emu.grasscutter.config.Configuration.GAME_OPTIONS;

import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.OpenStateData;
import emu.grasscutter.game.player.Player;
Expand All @@ -19,17 +21,21 @@ public PacketOpenStateUpdateNotify(Player player) {

OpenStateUpdateNotify.Builder proto = OpenStateUpdateNotify.newBuilder();

for (OpenStateData state : GameData.getOpenStateList()) {
GameData.getOpenStateList().stream().map(OpenStateData::getId).forEach(id -> {
if ((id == 45) && !GAME_OPTIONS.resinOptions.resinUsage) {
proto.putOpenStateMap(45, 0); // Remove resin from map
return;
}
// If the player has an open state stored in their map, then it would always override any default value
if (player.getOpenStates().containsKey(state.getId())) {
proto.putOpenStateMap(state.getId(), player.getProgressManager().getOpenState(state.getId()));
if (player.getOpenStates().containsKey(id)) {
proto.putOpenStateMap(id, player.getProgressManager().getOpenState(id));
}
// Otherwise, add the state if it is contained in the set of default open states.
else if (PlayerProgressManager.DEFAULT_OPEN_STATES.contains(state.getId())) {
proto.putOpenStateMap(state.getId(), 1);
else if (PlayerProgressManager.DEFAULT_OPEN_STATES.contains(id)) {
proto.putOpenStateMap(id, 1);
}
}
});

this.setData(proto);
}
}

0 comments on commit 4b03770

Please sign in to comment.