mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-11-20 10:09:25 +00:00
Use strings for cachemap key, should prevent accidental key issues.
This commit is contained in:
parent
812de5c35c
commit
3a50850734
1 changed files with 7 additions and 11 deletions
|
@ -18,14 +18,13 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class UserMap extends CacheLoader<UUID, User> implements IConf
|
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||||
{
|
{
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private final transient Cache<UUID, User> users;
|
private final transient Cache<String, User> users;
|
||||||
private final transient ConcurrentSkipListSet<UUID> keys = new ConcurrentSkipListSet<UUID>();
|
private final transient ConcurrentSkipListSet<UUID> keys = new ConcurrentSkipListSet<UUID>();
|
||||||
private final transient ConcurrentSkipListMap<String, UUID> names = new ConcurrentSkipListMap<String, UUID>();
|
private final transient ConcurrentSkipListMap<String, UUID> names = new ConcurrentSkipListMap<String, UUID>();
|
||||||
private final transient ConcurrentSkipListMap<UUID, ArrayList<String>> history = new ConcurrentSkipListMap<UUID, ArrayList<String>>();
|
private final transient ConcurrentSkipListMap<UUID, ArrayList<String>> history = new ConcurrentSkipListMap<UUID, ArrayList<String>>();
|
||||||
|
@ -92,7 +91,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||||
if (names.containsKey(sanitizedName))
|
if (names.containsKey(sanitizedName))
|
||||||
{
|
{
|
||||||
final UUID uuid = names.get(sanitizedName);
|
final UUID uuid = names.get(sanitizedName);
|
||||||
return users.get(uuid);
|
return getUser(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
final File userFile = getUserFileFromString(sanitizedName);
|
final File userFile = getUserFileFromString(sanitizedName);
|
||||||
|
@ -105,10 +104,6 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (ExecutionException ex)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch (UncheckedExecutionException ex)
|
catch (UncheckedExecutionException ex)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -119,7 +114,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return users.get(uuid);
|
return users.get(uuid.toString());
|
||||||
}
|
}
|
||||||
catch (ExecutionException ex)
|
catch (ExecutionException ex)
|
||||||
{
|
{
|
||||||
|
@ -149,8 +144,9 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User load(final UUID uuid) throws Exception
|
public User load(final String stringUUID) throws Exception
|
||||||
{
|
{
|
||||||
|
UUID uuid = UUID.fromString(stringUUID);
|
||||||
Player player = ess.getServer().getPlayer(uuid);
|
Player player = ess.getServer().getPlayer(uuid);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue