mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-22 23:31:43 +01:00
Attempt to unregister placeholder api expansion multiple times on disable.
Affects issues: - Possibly fixed #3020
This commit is contained in:
parent
a66501353d
commit
c161d1c280
@ -22,6 +22,7 @@ import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Singleton
|
||||
public class BukkitPlaceholderRegistrar {
|
||||
@ -50,7 +51,17 @@ public class BukkitPlaceholderRegistrar {
|
||||
|
||||
public void unregister() {
|
||||
if (placeholderExtension != null) {
|
||||
placeholderExtension.unregister();
|
||||
boolean success = false;
|
||||
while (!success) {
|
||||
success = placeholderExtension.unregister();
|
||||
if (!success) {
|
||||
try {
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
||||
} catch (InterruptedException interrupted) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,13 @@ package com.djrapitops.plan.placeholder;
|
||||
|
||||
import com.djrapitops.plan.commands.use.Arguments;
|
||||
import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.utilities.dev.Untrusted;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -109,6 +112,18 @@ public final class PlanPlaceholders {
|
||||
* otherwise {@code null}
|
||||
*/
|
||||
public String onPlaceholderRequest(UUID uuid, @Untrusted String placeholder, @Untrusted List<String> parameters) {
|
||||
try {
|
||||
return tryReplacePlaceholder(uuid, placeholder, parameters);
|
||||
} catch (DBOpException e) {
|
||||
if (dbSystem.getDatabase().getState() == Database.State.CLOSED) {
|
||||
return "Plan Bug #3020, please report";
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String tryReplacePlaceholder(UUID uuid, String placeholder, List<String> parameters) {
|
||||
for (Entry<String, Function<String, Serializable>> entry : rawHandlers.entrySet()) {
|
||||
if (placeholder.startsWith(entry.getKey())) {
|
||||
return Objects.toString(entry.getValue().apply(placeholder));
|
||||
|
Loading…
Reference in New Issue
Block a user