mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-06 14:46:32 +02:00
Revert "Add spawn location cache to reduce blocking on player respawn."
This reverts commit 7804516793
.
This commit is contained in:
@@ -8,29 +8,18 @@ import java.io.File;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
|
||||||
public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule
|
public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule
|
||||||
{
|
{
|
||||||
private ConcurrentMap<String, Location> spawns;
|
|
||||||
|
|
||||||
public SpawnStorage(final IEssentials ess)
|
public SpawnStorage(final IEssentials ess)
|
||||||
{
|
{
|
||||||
super(ess, Spawns.class);
|
super(ess, Spawns.class);
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void reloadConfig()
|
|
||||||
{
|
|
||||||
super.reloadConfig();
|
|
||||||
spawns = new ConcurrentHashMap<String, Location>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getStorageFile()
|
public File getStorageFile()
|
||||||
{
|
{
|
||||||
@@ -63,8 +52,6 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
spawns.clear();
|
|
||||||
|
|
||||||
if ("default".equalsIgnoreCase(group))
|
if ("default".equalsIgnoreCase(group))
|
||||||
{
|
{
|
||||||
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
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)
|
public Location getSpawn(final String group)
|
||||||
{
|
{
|
||||||
Location spawnLocation;
|
acquireReadLock();
|
||||||
if (spawns.containsKey(group))
|
try
|
||||||
{
|
{
|
||||||
spawnLocation = spawns.get(group);
|
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))
|
||||||
|
{
|
||||||
|
return getWorldSpawn();
|
||||||
|
}
|
||||||
|
return spawnMap.get(groupName);
|
||||||
}
|
}
|
||||||
else
|
finally
|
||||||
{
|
{
|
||||||
acquireReadLock();
|
unlock();
|
||||||
try
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
spawns.put(group, spawnLocation);
|
|
||||||
}
|
}
|
||||||
return spawnLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location getWorldSpawn()
|
private Location getWorldSpawn()
|
||||||
|
Reference in New Issue
Block a user