From 548615956158000da8f2c9eb8a5f00882a7be1e8 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 17 Jun 2014 23:27:46 +0100 Subject: Revert "Add spawn location cache to reduce blocking on player respawn." This reverts commit 7c013fa437252147a8c20f8eab07e4a0db8a3cc5. --- .../earth2me/essentials/spawn/SpawnStorage.java | 61 ++++++---------------- 1 file changed, 17 insertions(+), 44 deletions(-) (limited to 'EssentialsSpawn') diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java index c8e12563c..36b6f9662 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java @@ -8,29 +8,18 @@ import java.io.File; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; import org.bukkit.Location; import org.bukkit.World; public class SpawnStorage extends AsyncStorageObjectHolder implements IEssentialsModule { - private ConcurrentMap spawns; - public SpawnStorage(final IEssentials ess) { super(ess, Spawns.class); reloadConfig(); } - @Override - public final void reloadConfig() - { - super.reloadConfig(); - spawns = new ConcurrentHashMap(); - } - @Override public File getStorageFile() { @@ -63,8 +52,6 @@ public class SpawnStorage extends AsyncStorageObjectHolder implements IE unlock(); } - spawns.clear(); - if ("default".equalsIgnoreCase(group)) { loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); @@ -73,43 +60,29 @@ public class SpawnStorage extends AsyncStorageObjectHolder implements IE public Location getSpawn(final String group) { - Location spawnLocation; - if (spawns.containsKey(group)) - { - spawnLocation = spawns.get(group); - } - else + acquireReadLock(); + try { - acquireReadLock(); - try + if (getData().getSpawns() == null || group == null) { - if (getData().getSpawns() == null || group == null) - { - return getWorldSpawn(); - } - final Map spawnMap = getData().getSpawns(); - String groupName = group.toLowerCase(Locale.ENGLISH); - if (!spawnMap.containsKey(groupName)) - { - groupName = "default"; - } - if (!spawnMap.containsKey(groupName)) - { - spawnLocation = getWorldSpawn(); - } - else - { - spawnLocation = spawnMap.get(groupName); - } + return getWorldSpawn(); } - finally + final Map spawnMap = getData().getSpawns(); + String groupName = group.toLowerCase(Locale.ENGLISH); + if (!spawnMap.containsKey(groupName)) { - unlock(); + groupName = "default"; } - - spawns.put(group, spawnLocation); + if (!spawnMap.containsKey(groupName)) + { + return getWorldSpawn(); + } + return spawnMap.get(groupName); + } + finally + { + unlock(); } - return spawnLocation; } private Location getWorldSpawn() -- cgit v1.2.3