Skip to content

Commit

Permalink
check for null on highlight cache previous state load
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Oct 20, 2023
1 parent c0fa7fe commit aaab816
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/xaeroplus/module/impl/NewChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class NewChunks extends Module {

public void setNewChunksCache(boolean disk) {
try {
Long2LongMap map = newChunksCache.getHighlightsState();
final Long2LongMap map = newChunksCache.getHighlightsState();
newChunksCache.onDisable();
if (disk) {
newChunksCache = new ChunkHighlightSavingCache(DATABASE_NAME);
Expand All @@ -61,7 +61,7 @@ public void setNewChunksCache(boolean disk) {
}
if (this.isEnabled()) {
newChunksCache.onEnable();
newChunksCache.loadPreviousState(map);
if (map != null) newChunksCache.loadPreviousState(map);
}
} catch (final Exception e) {
XaeroPlus.LOGGER.error("Error closing new chunks cache", e);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xaeroplus/module/impl/OldChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void setOldChunksCache(boolean disk) {
}
if (this.isEnabled()) {
oldChunksCache.onEnable();
oldChunksCache.loadPreviousState(map);
if (map != null) oldChunksCache.loadPreviousState(map);
}
} catch (final Exception e) {
XaeroPlus.LOGGER.error("Error closing old chunks cache", e);
Expand All @@ -100,7 +100,7 @@ public void setOldChunksCache(boolean disk) {
}
if (this.isEnabled()) {
modernChunksCache.onEnable();
modernChunksCache.loadPreviousState(map);
if (map != null) modernChunksCache.loadPreviousState(map);
}
} catch (final Exception e) {
XaeroPlus.LOGGER.error("Error closing modern chunks cache", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public Long2LongMap getHighlightsState() {
}

public void loadPreviousState(final Long2LongMap state) {
if (state == null) return;
try {
if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) {
chunks.putAll(state);
Expand Down

0 comments on commit aaab816

Please sign in to comment.