Skip to content

Commit

Permalink
Testing to fix issue with hologram and stats
Browse files Browse the repository at this point in the history
  • Loading branch information
AerWyn81 committed Oct 22, 2024
1 parent 5486633 commit 4890554
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("java")
}

version = "2.6.7"
version = "2.6.8"

allprojects {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.file.Files;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -311,7 +312,7 @@ public static void close() {
}

public static boolean hasHead(UUID playerUuid, UUID headUuid) throws InternalException {
if (_cacheHeads.containsKey(playerUuid) && !_cacheHeads.get(playerUuid).isEmpty())
if (_cacheHeads.containsKey(playerUuid))
return _cacheHeads.get(playerUuid).contains(headUuid);

return storage.hasHead(playerUuid, headUuid);
Expand All @@ -321,19 +322,23 @@ public static void addHead(UUID playerUuid, UUID headUuid) throws InternalExcept
storage.addHead(playerUuid, headUuid);
database.addHead(playerUuid, headUuid);

StorageService.invalidateCachePlayer(playerUuid);
_cacheHeads.get(playerUuid).add(headUuid);

if (!_cacheTop.isEmpty()) {
_cacheTop.clear();
}
}

public static Boolean containsPlayer(UUID playerUuid) throws InternalException {
return storage.containsPlayer(playerUuid) || database.containsPlayer(playerUuid);
}

public static BukkitFutureResult<List<UUID>> getHeadsPlayer(UUID playerUuid) {
if (_cacheHeads.containsKey(playerUuid))
return BukkitFutureResult.of(HeadBlocks.getInstance(), CompletableFuture.completedFuture(_cacheHeads.get(playerUuid)));

return CompletableBukkitFuture.supplyAsync(HeadBlocks.getInstance(), () -> {
try {
if (_cacheHeads.containsKey(playerUuid) && !_cacheHeads.get(playerUuid).isEmpty())
return _cacheHeads.get(playerUuid);

var headsUuid = database.getHeadsPlayer(playerUuid);
_cacheHeads.compute(playerUuid, (key, playerHeads) -> {
if (playerHeads == null) {
Expand Down

0 comments on commit 4890554

Please sign in to comment.