fix: synchronize confirmExpiry (#3481)

Prevents that the MetaDataAccess is closed before setting the data
This commit is contained in:
Pierre Maurice Schwang 2022-02-08 15:57:09 +01:00 committed by GitHub
parent 16928b05f1
commit 951767dc64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,6 +136,7 @@ public class ExpireManager {
} }
public void confirmExpiry(final PlotPlayer<?> pp) { public void confirmExpiry(final PlotPlayer<?> pp) {
TaskManager.runTask(() -> {
try (final MetaDataAccess<Boolean> metaDataAccess = pp.accessTemporaryMetaData( try (final MetaDataAccess<Boolean> metaDataAccess = pp.accessTemporaryMetaData(
PlayerMetaDataKeys.TEMPORARY_IGNORE_EXPIRE_TASK)) { PlayerMetaDataKeys.TEMPORARY_IGNORE_EXPIRE_TASK)) {
if (metaDataAccess.isPresent()) { if (metaDataAccess.isPresent()) {
@ -147,7 +148,6 @@ public class ExpireManager {
Iterator<Plot> iter = plotsToDelete.iterator(); Iterator<Plot> iter = plotsToDelete.iterator();
final Plot current = iter.next(); final Plot current = iter.next();
if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) { if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) {
TaskManager.runTask(() -> {
metaDataAccess.set(true); metaDataAccess.set(true);
current.getCenter(pp::teleport); current.getCenter(pp::teleport);
metaDataAccess.remove(); metaDataAccess.remove();
@ -171,7 +171,6 @@ public class ExpireManager {
cmd_keep, cmd_keep,
cmd_no_show_expir cmd_no_show_expir
); );
});
return; return;
} else { } else {
iter.remove(); iter.remove();
@ -180,6 +179,7 @@ public class ExpireManager {
plotsToDelete.clear(); plotsToDelete.clear();
} }
} }
});
} }
@ -307,6 +307,7 @@ public class ExpireManager {
this.running = 2; this.running = 2;
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
private ConcurrentLinkedDeque<Plot> plots = null; private ConcurrentLinkedDeque<Plot> plots = null;
@Override @Override
public void run() { public void run() {
final Runnable task = this; final Runnable task = this;