diff options
author | KHobbits <rob@khobbits.co.uk> | 2014-06-17 23:27:46 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2014-06-17 23:27:46 +0100 |
commit | 50a815bdb9288a5900899d6d5fa2dbb053caa9cc (patch) | |
tree | 59830b306dc37f4af9e8185249abfbbb1901dcc1 /EssentialsSpawn/src/com/earth2me | |
parent | 1690b9d83d01519be1c55a097396b2a090068ea3 (diff) | |
download | Essentials-50a815bdb9288a5900899d6d5fa2dbb053caa9cc.tar Essentials-50a815bdb9288a5900899d6d5fa2dbb053caa9cc.tar.gz Essentials-50a815bdb9288a5900899d6d5fa2dbb053caa9cc.tar.lz Essentials-50a815bdb9288a5900899d6d5fa2dbb053caa9cc.tar.xz Essentials-50a815bdb9288a5900899d6d5fa2dbb053caa9cc.zip |
Revert "Add spawn location cache to reduce blocking on player respawn."
This reverts commit 7804516793148becfe648c4491fea60829460957.
Diffstat (limited to 'EssentialsSpawn/src/com/earth2me')
-rw-r--r-- | EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java | 61 |
1 files changed, 17 insertions, 44 deletions
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,16 +8,12 @@ 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<Spawns> implements IEssentialsModule { - private ConcurrentMap<String, Location> spawns; - public SpawnStorage(final IEssentials ess) { super(ess, Spawns.class); @@ -25,13 +21,6 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE } @Override - public final void reloadConfig() - { - super.reloadConfig(); - spawns = new ConcurrentHashMap<String, Location>(); - } - - @Override public File getStorageFile() { return new File(ess.getDataFolder(), "spawn.yml"); @@ -63,8 +52,6 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> 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<Spawns> 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<String, Location> 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<String, Location> 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() |