Skip to content

Commit

Permalink
GH-590 Fix home save after override home. (#590)
Browse files Browse the repository at this point in the history
* Fix home save after override home.

* Await before save.
  • Loading branch information
vLuckyyy authored Dec 22, 2023
1 parent 1b4df1d commit 09f7409
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ private HomeManager(HomeRepository repository) {
}

public void createHome(User user, String name, Location location) {
Home home = new Home(user.getUniqueId(), name, location);
Map<String, Home> userHomes = this.homes.computeIfAbsent(user.getUniqueId(), k -> new HashMap<>());
if (this.hasHomeWithSpecificName(user, name)) {
this.repository.deleteHome(user, name).then(completable -> {
Home home = new Home(user.getUniqueId(), name, location);

userHomes.put(name, home);
Map<String, Home> userHomes = this.homes.computeIfAbsent(user.getUniqueId(), k -> new HashMap<>());
userHomes.put(name, home);

this.repository.saveHome(home);
this.repository.saveHome(home);
});
}
}

public void deleteHome(User user, String name) {
Expand Down

0 comments on commit 09f7409

Please sign in to comment.