EternalCore icon indicating copy to clipboard operation
EternalCore copied to clipboard

[api] Delay always uses the expireAfterWrite duration time instead of the custom duration in the markDelay method.

Open Jakubk15 opened this issue 3 months ago • 0 comments

public Delay(Supplier<Duration> delayProvider) {
        this.delaySettings = delayProvider;

        this.delays = CacheBuilder.newBuilder()
            .expireAfterWrite(delayProvider.get())
            .build();
    }

public void markDelay(T key, Duration delay) {
        this.delays.put(key, Instant.now().plus(delay));
    }

Problematic example:

Delay<String> delay = new Delay<>(() -> Duration.ofSeconds(10)); // cache expiry: 10s

// Mark delay for 60s
delay.markDelay("player1", Duration.ofSeconds(60));

// After 10s: entry physically disappears from cache
// After 15s: hasDelay("player1") will return FALSE, although theoretically it should be true for 45 more seconds.

Jakubk15 avatar Sep 06 '25 20:09 Jakubk15