Skip to content

Commit

Permalink
Fixed race condition in map color cache generation
Browse files Browse the repository at this point in the history
- Updated YamipaPlugin class

> Fixes `java.lang.IllegalStateException: java.lang.IllegalStateException: Cache is already build or is currently being build`
  • Loading branch information
josemmo committed Jun 17, 2023
1 parent 0c6cce2 commit 178c464
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.josemmo.bukkit.plugin;

import io.josemmo.bukkit.plugin.commands.ImageCommandBridge;
import io.josemmo.bukkit.plugin.renderer.FakeEntity;
import io.josemmo.bukkit.plugin.renderer.FakeImage;
import io.josemmo.bukkit.plugin.renderer.ImageRenderer;
import io.josemmo.bukkit.plugin.renderer.ItemService;
import io.josemmo.bukkit.plugin.renderer.*;
import io.josemmo.bukkit.plugin.storage.ImageStorage;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
Expand All @@ -13,6 +10,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.Color;
import java.nio.file.Path;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -107,12 +105,14 @@ public void onEnable() {
// Create thread pool
scheduler = Executors.newScheduledThreadPool(6);

// Warm-up ProtocolLib
// Warm-up plugin dependencies
fine("Waiting for ProtocolLib to be ready...");
scheduler.execute(() -> {
FakeEntity.waitForProtocolLib();
fine("ProtocolLib is now ready");
});
fine("Triggered map color cache warm-up");
FakeMap.pixelToIndex(Color.RED.getRGB()); // Ask for a color index to force cache generation

// Initialize bStats
Function<Integer, String> toStats = number -> {
Expand Down

0 comments on commit 178c464

Please sign in to comment.