From adfd0e6674c864819d51ca7e198e769ecc5fc686 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Sun, 17 Jan 2016 13:19:14 +0100 Subject: [PATCH] Should fix #824 --- .../plot/object/PlotHandler.java | 17 +++++--- .../plot/util/MainUtil.java | 43 ++++--------------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java index 6141a1bb9..bc2d48805 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -1,14 +1,15 @@ package com.intellectualcrafters.plot.object; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; +import org.bukkit.Bukkit; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; public class PlotHandler { public static HashSet getOwners(final Plot plot) { @@ -41,7 +42,11 @@ public class PlotHandler { if (!plot.isMerged()) { return false; } - for (Plot current : MainUtil.getConnectedPlots(plot)) { + Set plots; + synchronized (Bukkit.getServer()) { + plots = MainUtil.getConnectedPlots(plot); + } + for (Plot current : plots) { if (current.owner.equals(uuid)) { return true; } diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 7671b5cd6..e60c86147 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -20,23 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util; -import java.nio.charset.StandardCharsets; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.regex.Matcher; - import com.google.common.collect.BiMap; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; @@ -44,24 +27,16 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.ConsolePlayer; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotCluster; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotSettings; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.object.RunnableVal; -import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.object.*; import com.plotsquared.listener.PlotListener; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; + /** * plot functions * @@ -2415,7 +2390,7 @@ public class MainUtil { public static HashSet connected_cache; public static HashSet regions_cache; - public static HashSet getConnectedPlots(Plot plot) { + public static synchronized HashSet getConnectedPlots(Plot plot) { if (plot == null) { return null; }