From 951767dc64352113f63c93321a6bd3d6dc0b14b5 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Tue, 8 Feb 2022 15:57:09 +0100 Subject: [PATCH] fix: synchronize confirmExpiry (#3481) Prevents that the MetaDataAccess is closed before setting the data --- .../core/plot/expiration/ExpireManager.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index 7e6af4b7d..69c635e2b 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -136,18 +136,18 @@ public class ExpireManager { } public void confirmExpiry(final PlotPlayer pp) { - try (final MetaDataAccess metaDataAccess = pp.accessTemporaryMetaData( - PlayerMetaDataKeys.TEMPORARY_IGNORE_EXPIRE_TASK)) { - if (metaDataAccess.isPresent()) { - return; - } - if (plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) { - final int num = plotsToDelete.size(); - while (!plotsToDelete.isEmpty()) { - Iterator iter = plotsToDelete.iterator(); - final Plot current = iter.next(); - if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) { - TaskManager.runTask(() -> { + TaskManager.runTask(() -> { + try (final MetaDataAccess metaDataAccess = pp.accessTemporaryMetaData( + PlayerMetaDataKeys.TEMPORARY_IGNORE_EXPIRE_TASK)) { + if (metaDataAccess.isPresent()) { + return; + } + if (plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) { + final int num = plotsToDelete.size(); + while (!plotsToDelete.isEmpty()) { + Iterator iter = plotsToDelete.iterator(); + final Plot current = iter.next(); + if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) { metaDataAccess.set(true); current.getCenter(pp::teleport); metaDataAccess.remove(); @@ -171,15 +171,15 @@ public class ExpireManager { cmd_keep, cmd_no_show_expir ); - }); - return; - } else { - iter.remove(); + return; + } else { + iter.remove(); + } } + plotsToDelete.clear(); } - plotsToDelete.clear(); } - } + }); } @@ -307,6 +307,7 @@ public class ExpireManager { this.running = 2; TaskManager.runTaskAsync(new Runnable() { private ConcurrentLinkedDeque plots = null; + @Override public void run() { final Runnable task = this;