Skip to content

Commit c841ffb

Browse files
authored
Merge pull request #649 from Multiverse/fix/handling-state
Delay handling state to end of profile writes
2 parents 1341aa0 + a6e6ad7 commit c841ffb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/org/mvplugins/multiverse/inventories/handleshare/PlayerShareHandlingState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
77
import org.mvplugins.multiverse.inventories.share.Sharable;
88

9-
import java.util.HashMap;
109
import java.util.Map;
1110
import java.util.UUID;
11+
import java.util.concurrent.ConcurrentHashMap;
1212

1313
/**
1414
* Keeps track of players who are currently having their sharable handling processed.
@@ -26,7 +26,7 @@ public final class PlayerShareHandlingState {
2626

2727
@Inject
2828
PlayerShareHandlingState() {
29-
this.playerAffectedProfiles = new HashMap<>();
29+
this.playerAffectedProfiles = new ConcurrentHashMap<>();
3030
}
3131

3232
void setPlayerAffectedProfiles(Player player, AffectedProfiles status) {

src/main/java/org/mvplugins/multiverse/inventories/handleshare/ShareHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ private void updatePlayer() {
9393
for (PersistingProfile readProfile : affectedProfiles.getReadProfiles()) {
9494
ShareHandlingUpdater.updatePlayer(inventories, player, readProfile);
9595
}
96-
playerShareHandlingState.removePlayerAffectedProfiles(player);
9796
}
9897

9998
private CompletableFuture<Void> updateProfiles(ProfileDataSnapshot snapshot) {
@@ -104,7 +103,8 @@ private CompletableFuture<Void> updateProfiles(ProfileDataSnapshot snapshot) {
104103
return CompletableFuture.allOf(affectedProfiles.getWriteProfiles()
105104
.stream()
106105
.map(writeProfile -> updatePersistingProfile(writeProfile, snapshot))
107-
.toArray(CompletableFuture[]::new));
106+
.toArray(CompletableFuture[]::new))
107+
.thenRun(() -> playerShareHandlingState.removePlayerAffectedProfiles(player));
108108
}
109109

110110
private CompletableFuture<Void> updatePersistingProfile(PersistingProfile persistingProfile, ProfileDataSnapshot snapshot) {

0 commit comments

Comments
 (0)