HashMaps need to be Concurrent

This commit is contained in:
Xephi59 2015-06-29 03:02:07 +02:00
parent 108bb5c357
commit d84cd6549b
3 changed files with 8 additions and 12 deletions

View File

@ -1,14 +1,14 @@
package fr.xephi.authme.cache.auth;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
public class PlayerCache {
private static PlayerCache singleton = null;
private HashMap<String, PlayerAuth> cache;
private ConcurrentHashMap<String, PlayerAuth> cache;
private PlayerCache() {
cache = new HashMap<String, PlayerAuth>();
cache = new ConcurrentHashMap<String, PlayerAuth>();
}
public void addPlayer(PlayerAuth auth) {

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.cache.limbo;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -18,13 +18,13 @@ import fr.xephi.authme.settings.Settings;
public class LimboCache {
private static LimboCache singleton = null;
public HashMap<String, LimboPlayer> cache;
public ConcurrentHashMap<String, LimboPlayer> cache;
private FileCache playerData;
public AuthMe plugin;
private LimboCache(AuthMe plugin) {
this.plugin = plugin;
this.cache = new HashMap<String, LimboPlayer>();
this.cache = new ConcurrentHashMap<String, LimboPlayer>();
this.playerData = new FileCache(plugin);
}
@ -52,8 +52,7 @@ public class LimboCache {
playerGroup = playerData.readCache(player).getGroup();
operator = playerData.readCache(player).getOperator();
flying = playerData.readCache(player).isFlying();
} catch (Exception e)
{
} catch (Exception e) {
ConsoleLogger.showError("Some error on reading cache of " + name);
}
} else {

View File

@ -43,7 +43,6 @@ import fr.xephi.authme.Utils;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
@ -60,14 +59,12 @@ public class AuthMePlayerListener implements Listener {
private Messages m = Messages.getInstance();
public AuthMe plugin;
private DataSource data;
private FileCache playerBackup;
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<String, Boolean>();
private List<String> antibot = new ArrayList<String>();
public AuthMePlayerListener(AuthMe plugin, DataSource data) {
this.plugin = plugin;
this.data = data;
this.playerBackup = new FileCache(plugin);
}
@EventHandler(priority = EventPriority.LOWEST)